CodeSampleX

Beispiel

node-abi 3.96.0: getAbi

Verifiziertes Beispiel für npm node-abi 3.96.0: getAbi. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand: getAbi is exported as a…

sha256:bf3bbdaadd28e3cdaa5def9366ccc19c22e9e865631eb5b6880c9f392bc60b0c

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 linux 24 · ubuntu · glibc 2.39 x64 npm

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-07

Fall

HOW
Ziel
verify getAbi in pkg:npm/node-abi@3.96.0
Pakete
Symbole
  • getAbi
Erstellt
2026-09-07T03:37:20Z

Contract

  1. getAbi is exported as a function from node-abi
  2. getAbi resolves the ABI version string for standard Node.js release targets
  3. getAbi supports version strings with leading 'v'
  4. getAbi defaults to node runtime when runtime parameter is omitted
  5. getAbi returns process.versions.modules when target parameter is omitted
  6. getAbi resolves the ABI version string for Electron release targets
  7. getAbi resolves the ABI version string for node-webkit release targets
  8. getAbi returns the input unchanged when a numeric ABI string is passed
  9. getAbi throws error when queried with unsupported target version

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 getAbi in pkg:npm/node-abi@3.96.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/node-abi@3.96.0
Demonstrate these symbols/APIs:
  - getAbi

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:7a4a34427e1ce4c36d459bc23c9ee52dfa113555a5c6e4934530bf0edeb742d8","contract":["getAbi is exported as a function from node-abi","getAbi resolves the ABI version string for standard Node.js release targets","getAbi supports version strings with leading 'v'","getAbi defaults to node runtime when runtime parameter is omitted","getAbi returns process.versions.modules when target parameter is omitted","getAbi resolves the ABI version string for Electron release targets","getAbi resolves the ABI version string for node-webkit release targets","getAbi returns the input unchanged when a numeric ABI string is passed","getAbi throws error when queried with unsupported target version"],"goal":"verify getAbi in pkg:npm/node-abi@3.96.0","kind":"HOW","packages":["pkg:npm/node-abi@3.96.0"],"schemaVersion":1,"symbols":["getAbi"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/node-abi@3.96.0"],"schemaVersion":1,"subject":"pkg:npm/node-abi@3.96.0","symbols":["getAbi"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-node-abi",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-node-abi",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "node-abi": "3.96.0"
      }
    },
    "node_modules/node-abi": {
      "version": "3.96.0",
      "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.96.0.tgz",
      "integrity": "sha512-rebQ/lz7i0EkoLzUVSrKRzA69zMkwLp95kKMWoMDkkM00Suxz0D7zEQPwRml5fQum24mj7bPvmlgLAmu2JCiYg==",
      "license": "MIT",
      "dependencies": {
        "semver": "^7.3.5"
      },
      "engines": {
        "node": ">=10"
      }
    },
    "node_modules/semver": {
      "version": "7.8.5",
      "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
      "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
      "license": "ISC",
      "bin": {
        "semver": "bin/semver.js"
      },
      "engines": {
        "node": ">=10"
      }
    }
  }
}
package.json
{
  "name": "sample-node-abi",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room code sample for node-abi getAbi in node-abi@3.96.0",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "node-abi": "3.96.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify getAbi in pkg:npm/node-abi@3.96.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/node-abi@3.96.0"
  ],
  "symbols": [
    "getAbi"
  ]
}
src/index.js
const nodeAbi = require('node-abi');

/**
 * Resolves the Node, Electron, or node-webkit ABI version string for a given target runtime version.
 *
 * @param {string} [target] - Runtime version string (e.g. '22.0.0', 'v22.0.0', or numeric ABI string).
 * @param {string} [runtime='node'] - Target runtime ('node', 'electron', 'node-webkit').
 * @returns {string} The ABI version string.
 */
function resolveAbi(target, runtime = 'node') {
  return nodeAbi.getAbi(target, runtime);
}

module.exports = {
  nodeAbi,
  getAbi: nodeAbi.getAbi,
  resolveAbi
};
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const {
  nodeAbi,
  getAbi,
  resolveAbi
} = require('../src/index.js');

async function runTests() {
  // 1. getAbi is exported as a function from node-abi
  assert.equal(typeof nodeAbi.getAbi, 'function', 'nodeAbi.getAbi must be a function');
  assert.equal(typeof getAbi, 'function', 'getAbi must be a function');
  assert.equal(typeof resolveAbi, 'function', 'resolveAbi helper must be a function');

  // 2. getAbi resolves the ABI version string for standard Node.js release targets
  assert.equal(resolveAbi('22.0.0', 'node'), '127', 'Node 22.0.0 should map to ABI 127');
  assert.equal(resolveAbi('20.0.0', 'node'), '115', 'Node 20.0.0 should map to ABI 115');
  assert.equal(resolveAbi('18.0.0', 'node'), '108', 'Node 18.0.0 should map to ABI 108');

  // 3. getAbi supports version strings with leading 'v'
  assert.equal(resolveAbi('v22.0.0', 'node'), '127', 'Node v22.0.0 with leading v should map to ABI 127');

  // 4. getAbi defaults to node runtime when runtime parameter is omitted
  assert.equal(resolveAbi('22.0.0'), '127', 'Omitting runtime should default to node');

  // 5. getAbi returns process.versions.modules when target parameter is omitted
  assert.equal(resolveAbi(), process.versions.modules, 'Omitting target should return current process ABI');

  // 6. getAbi resolves the ABI version string for Electron release targets
  assert.equal(resolveAbi('30.0.0', 'electron'), '123', 'Electron 30.0.0 should map to ABI 123');
  assert.equal(resolveAbi('28.0.0', 'electron'), '119', 'Electron 28.0.0 should map to ABI 119');

  // 7. getAbi resolves the ABI version string for node-webkit release targets
  assert.equal(resolveAbi('0.26.5', 'node-webkit'), '59', 'node-webkit 0.26.5 should map to ABI 59');

  // 8. getAbi returns the input unchanged when a numeric ABI string is passed
  assert.equal(resolveAbi('127'), '127', 'Passing numeric ABI string should return itself');

  // 9. getAbi throws error when queried with unsupported target version
  assert.throws(
    () => resolveAbi('999.0.0', 'node'),
    /Could not detect abi for version 999\.0\.0/,
    'getAbi should throw on unsupported version'
  );

  console.log('All contract assertions for node-abi getAbi passed successfully.');
}

runTests().catch((err) => {
  console.error('Contract test failed:', err);
  process.exit(1);
});

Ursprungs-Seeder

anonym