CodeSampleX

Beispiel

statuses 2.0.1: status

Verifiziertes Beispiel für npm statuses 2.0.1: status. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand: status(code) returns status…

sha256:25c91e0ec683b803864b99af07541e21ab4e1cef4b00697eb7defa6e8821dc05

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-02

Fall

HOW
Ziel
verify status in pkg:npm/statuses@2.0.1
Pakete
Symbole
  • status
Umgebung
node 22.23.2
Erstellt
2026-09-02T15:31:28Z

Contract

  1. status(code) returns status message when given numeric status code
  2. status(code) returns status message when given numeric string
  3. status(message) returns status code number case-insensitively when given status message string
  4. status(code) throws Error when numeric status code is not recognized
  5. status(message) throws Error when status message is not recognized
  6. status(code) throws TypeError when argument is not a number or string
  7. status.message and status.code provide mappings between status codes and messages
  8. status.redirect, status.empty, and status.retry categorise status codes by HTTP semantics

Dateien

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.cjs

Quellartefakt herunterladen (tar.gz)

Quelltext

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify status in pkg:npm/statuses@2.0.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/statuses@2.0.1
Demonstrate these symbols/APIs:
  - status

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:ebbaa13eaf429e3bcd4d064a7f67036df8730cbbb56fca72034e4e26ebb9c0fe","contract":["status(code) returns status message when given numeric status code","status(code) returns status message when given numeric string","status(message) returns status code number case-insensitively when given status message string","status(code) throws Error when numeric status code is not recognized","status(message) throws Error when status message is not recognized","status(code) throws TypeError when argument is not a number or string","status.message and status.code provide mappings between status codes and messages","status.redirect, status.empty, and status.retry categorise status codes by HTTP semantics"],"goal":"verify status in pkg:npm/statuses@2.0.1","kind":"HOW","packages":["pkg:npm/statuses@2.0.1"],"schemaVersion":1,"symbols":["status"]},"contractCommand":["node","test/contract.cjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/statuses@2.0.1"],"schemaVersion":1,"subject":"pkg:npm/statuses@2.0.1","symbols":["status"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-statuses",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-statuses",
      "version": "1.0.0",
      "dependencies": {
        "statuses": "2.0.1"
      }
    },
    "node_modules/statuses": {
      "version": "2.0.1",
      "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
      "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==",
      "license": "MIT",
      "engines": {
        "node": ">= 0.8"
      }
    }
  }
}
package.json
{
  "name": "sample-statuses",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification for statuses",
  "main": "src/index.js",
  "dependencies": {
    "statuses": "2.0.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify status in pkg:npm/statuses@2.0.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/statuses@2.0.1"
  ],
  "symbols": [
    "status"
  ]
}
src/index.js
const status = require('statuses');

/**
 * Look up status code or message.
 * @param {number|string} code - Status code number or status message string
 * @returns {string|number} Status message if code is number/numeric string, or status code if code is message string
 */
function getStatus(code) {
  return status(code);
}

module.exports = {
  status,
  getStatus
};
test/contract.cjs
const assert = require('node:assert');
const status = require('statuses');
const { getStatus } = require('../src/index.js');

// 1. status(code) returns status message when given numeric status code
assert.strictEqual(status(200), 'OK');
assert.strictEqual(status(404), 'Not Found');
assert.strictEqual(status(500), 'Internal Server Error');
assert.strictEqual(getStatus(200), 'OK');

// 2. status(code) returns status message when given numeric string
assert.strictEqual(status('200'), 'OK');
assert.strictEqual(status('404'), 'Not Found');
assert.strictEqual(getStatus('404'), 'Not Found');

// 3. status(message) returns status code number case-insensitively when given status message string
assert.strictEqual(status('ok'), 200);
assert.strictEqual(status('OK'), 200);
assert.strictEqual(status('Not Found'), 404);
assert.strictEqual(status('not found'), 404);
assert.strictEqual(getStatus('Internal Server Error'), 500);

// 4. status(code) throws Error when numeric status code is not recognized
assert.throws(() => status(999), /^Error: invalid status code: 999$/);

// 5. status(message) throws Error when status message is not recognized
assert.throws(() => status('Unknown Custom Status'), /^Error: invalid status message: "Unknown Custom Status"$/);

// 6. status(code) throws TypeError when argument is not a number or string
assert.throws(() => status(null), /^TypeError: code must be a number or string$/);
assert.throws(() => status({}), /^TypeError: code must be a number or string$/);

// 7. status.message and status.code provide mappings between status codes and messages
assert.strictEqual(status.message[200], 'OK');
assert.strictEqual(status.message[404], 'Not Found');
assert.strictEqual(status.code['not found'], 404);
assert.strictEqual(status.code['ok'], 200);
assert(Array.isArray(status.codes));
assert(status.codes.includes(200));

// 8. status.redirect, status.empty, and status.retry categorise status codes by HTTP semantics
assert.strictEqual(status.redirect[301], true);
assert.strictEqual(status.redirect[302], true);
assert.strictEqual(status.empty[204], true);
assert.strictEqual(status.empty[304], true);
assert.strictEqual(status.retry[502], true);
assert.strictEqual(status.retry[503], true);

console.log('Contract tests passed successfully.');

Ursprungs-Seeder

anonym