CodeSampleX

Beispiel

is-core-module 2.16.2

Verifiziertes Beispiel für npm is-core-module 2.16.2. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand: isCore function correctly…

sha256:685d5cc13ee5bec5f7dd6c641669d7e97d5613f6c5c7f09bf0564aa05cd59f59

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

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-20

Fall

HOW
Ziel
verify pkg:npm/is-core-module@2.16.2
Pakete
Umgebung
node 22.23.2
Erstellt
2026-08-20T17:29:46Z

Contract

  1. isCore function correctly identifies built-in Node.js core modules
  2. isCore recognizes node-prefixed core module specifiers
  3. isCore returns false for non-core module identifiers
  4. isCore evaluates module availability against specified Node.js version ranges
  5. isCore throws TypeError when an invalid non-string nodeVersion is provided for version-scoped modules

Dateien

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

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 pkg:npm/is-core-module@2.16.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/is-core-module@2.16.2
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - runtime: node@22.23.2

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:0b83b1f5665a94f375d026ed646171520fe68cfe62c1ee292df4353da51e22b4","constraints":{"executionContext":"node"},"contract":["isCore function correctly identifies built-in Node.js core modules","isCore recognizes node-prefixed core module specifiers","isCore returns false for non-core module identifiers","isCore evaluates module availability against specified Node.js version ranges","isCore throws TypeError when an invalid non-string nodeVersion is provided for version-scoped modules"],"goal":"verify pkg:npm/is-core-module@2.16.2","kind":"HOW","packages":["pkg:npm/is-core-module@2.16.2"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/is-core-module@2.16.2"],"schemaVersion":1,"subject":"pkg:npm/is-core-module@2.16.2","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-is-core-module",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-is-core-module",
      "version": "1.0.0",
      "dependencies": {
        "is-core-module": "2.16.2"
      }
    },
    "node_modules/function-bind": {
      "version": "1.1.2",
      "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
      "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
      "license": "MIT",
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    },
    "node_modules/hasown": {
      "version": "2.0.4",
      "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz",
      "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==",
      "license": "MIT",
      "dependencies": {
        "function-bind": "^1.1.2"
      },
      "engines": {
        "node": ">= 0.4"
      }
    },
    "node_modules/is-core-module": {
      "version": "2.16.2",
      "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.2.tgz",
      "integrity": "sha512-evOr8xfXKxE6qSR0hSXL2r3sd7ALj8+7jQEUvPYcm5sgZFdJ+AYzT6yNmJenvIYQBgIGwfwz08sL8zoL7yq2BA==",
      "license": "MIT",
      "dependencies": {
        "hasown": "^2.0.3"
      },
      "engines": {
        "node": ">= 0.4"
      },
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    }
  }
}
package.json
{
  "name": "sample-is-core-module",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of is-core-module",
  "main": "src/index.js",
  "dependencies": {
    "is-core-module": "2.16.2"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/is-core-module@2.16.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/is-core-module@2.16.2"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "runtime": "node@22.23.2"
  }
}
src/index.js
const isCore = require('is-core-module');

/**
 * Checks whether a given module identifier is a Node.js core module.
 * @param {string} moduleName - The module name or specifier (e.g. 'fs', 'path', 'node:test')
 * @param {string} [nodeVersion] - Optional target Node.js version string (e.g. '18.0.0')
 * @returns {boolean} True if the module is a core module in the given/current Node.js version
 */
function checkIsCore(moduleName, nodeVersion) {
  return isCore(moduleName, nodeVersion);
}

module.exports = {
  isCore,
  checkIsCore
};
test/contract.mjs
import assert from 'node:assert';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const { isCore, checkIsCore } = require('../src/index.js');

// 1. Export verification
assert.strictEqual(typeof isCore, 'function', 'isCore should be a function');
assert.strictEqual(typeof checkIsCore, 'function', 'checkIsCore should be a function');

// 2. Standard built-in core modules
assert.strictEqual(isCore('fs'), true, 'fs is a core module');
assert.strictEqual(isCore('path'), true, 'path is a core module');
assert.strictEqual(isCore('http'), true, 'http is a core module');
assert.strictEqual(isCore('events'), true, 'events is a core module');
assert.strictEqual(isCore('stream'), true, 'stream is a core module');

// 3. node: prefixed core module specifiers
assert.strictEqual(isCore('node:fs'), true, 'node:fs is a core module');
assert.strictEqual(isCore('node:path'), true, 'node:path is a core module');
assert.strictEqual(isCore('node:test'), true, 'node:test is a core module');
assert.strictEqual(checkIsCore('node:buffer'), true, 'node:buffer is a core module');

// 4. Non-core module specifiers
assert.strictEqual(isCore('express'), false, 'express is not a core module');
assert.strictEqual(isCore('not-a-core-module'), false, 'nonexistent name is not a core module');
assert.strictEqual(checkIsCore('lodash'), false, 'lodash is not a core module');

// 5. Version-specific core module checks
assert.strictEqual(isCore('worker_threads', '10.0.0'), false, 'worker_threads was not in Node 10.0.0');
assert.strictEqual(isCore('worker_threads', '12.0.0'), true, 'worker_threads is in Node 12.0.0');
assert.strictEqual(isCore('node:test', '16.0.0'), false, 'node:test was not in Node 16.0.0');
assert.strictEqual(isCore('node:test', '18.0.0'), true, 'node:test is in Node 18.0.0');
assert.strictEqual(checkIsCore('fs', '0.10.0'), true, 'fs was in Node 0.10.0');

// 6. Throws TypeError when invalid non-string nodeVersion is provided for version-checked module
assert.throws(() => {
  isCore('worker_threads', 18);
}, TypeError);

assert.throws(() => {
  isCore('node:test', {});
}, TypeError);

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

Ursprungs-Seeder

anonym