CodeSampleX

Beispiel

boolean 3.2.0: boolean

Verifiziertes Beispiel für npm boolean 3.2.0: boolean. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand: boolean parses truthy strings…

sha256:5e6426300ffc798b7788b0c84ddbbed2b5d3e2a7b438657ce4f1738a5af2a46e

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

Fall

HOW
Ziel
verify boolean.boolean in pkg:npm/boolean@3.2.0
Pakete
Symbole
  • boolean.boolean
Umgebung
node 22.23.2
Erstellt
2026-09-06T11:22:23Z

Contract

  1. boolean parses truthy strings including true, t, yes, y, on, and 1 case-insensitively and trimmed
  2. boolean returns true for numeric 1 and boolean true
  3. boolean returns false for falsy strings, numbers other than 1, null, undefined, objects, and unknown strings
  4. boolean supports boxed String, Number, and Boolean objects
  5. boolean module exports the boolean function under the boolean property

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 boolean.boolean in pkg:npm/boolean@3.2.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/boolean@3.2.0
Demonstrate these symbols/APIs:
  - boolean.boolean

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:9eee6490e5b0194eaf26425a8c6398fe1757abc76ecaf40f02d009e30d1372c6","contract":["boolean parses truthy strings including true, t, yes, y, on, and 1 case-insensitively and trimmed","boolean returns true for numeric 1 and boolean true","boolean returns false for falsy strings, numbers other than 1, null, undefined, objects, and unknown strings","boolean supports boxed String, Number, and Boolean objects","boolean module exports the boolean function under the boolean property"],"goal":"verify boolean.boolean in pkg:npm/boolean@3.2.0","kind":"HOW","packages":["pkg:npm/boolean@3.2.0"],"schemaVersion":1,"symbols":["boolean.boolean"]},"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","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/boolean@3.2.0"],"schemaVersion":1,"subject":"pkg:npm/boolean@3.2.0","symbols":["boolean.boolean"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-boolean",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-boolean",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "boolean": "3.2.0"
      }
    },
    "node_modules/boolean": {
      "version": "3.2.0",
      "resolved": "https://registry.npmjs.org/boolean/-/boolean-3.2.0.tgz",
      "integrity": "sha512-d0II/GO9uf9lfUHH2BQsjxzRJZBdsjgsBiW4BvhWk/3qoKwQFjIDVN19PfX8F2D/r9PCMTtLWjYVCFrpeYUzsw==",
      "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-boolean",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room code sample for boolean.boolean in boolean@3.2.0",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "boolean": "3.2.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify boolean.boolean in pkg:npm/boolean@3.2.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/boolean@3.2.0"
  ],
  "symbols": [
    "boolean.boolean"
  ]
}
src/index.js
const { boolean } = require('boolean');

/**
 * Converts a string, number, boolean, or boxed object to a boolean using boolean.boolean.
 *
 * @param {*} value - The value to parse as a boolean.
 * @returns {boolean} True if the value represents a truthy boolean, false otherwise.
 */
function parseBoolean(value) {
  return boolean(value);
}

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

const require = createRequire(import.meta.url);
const booleanModule = require('boolean');
const { boolean, parseBoolean } = require('../src/index.js');

// 1. Module export verification: boolean is exported as a function on the module
assert.equal(typeof booleanModule.boolean, 'function', 'boolean should be exported as a function on boolean package');
assert.equal(typeof boolean, 'function', 'boolean should be a function');
assert.equal(typeof parseBoolean, 'function', 'parseBoolean wrapper should be a function');
assert.equal(booleanModule.boolean, boolean, 'imported boolean should match booleanModule.boolean');

// 2. Truthy string parsing with case-insensitivity and trimming
const truthyStrings = [
  'true', 'TRUE', 'True', 't', 'T',
  'yes', 'YES', 'Yes', 'y', 'Y',
  'on', 'ON', 'On',
  '1',
  '  true  ', '\tYES\n', '  on  '
];
for (const val of truthyStrings) {
  assert.equal(boolean(val), true, `boolean(${JSON.stringify(val)}) should return true`);
  assert.equal(parseBoolean(val), true, `parseBoolean(${JSON.stringify(val)}) should return true`);
}

// 3. Numeric 1 and boolean true
assert.equal(boolean(1), true, 'boolean(1) should return true');
assert.equal(boolean(true), true, 'boolean(true) should return true');
assert.equal(parseBoolean(1), true, 'parseBoolean(1) should return true');
assert.equal(parseBoolean(true), true, 'parseBoolean(true) should return true');

// 4. Falsy strings, non-1 numbers, null, undefined, empty objects, and arbitrary strings
const falsyValues = [
  'false', 'FALSE', 'False', 'f', 'F',
  'no', 'NO', 'No', 'n', 'N',
  'off', 'OFF', 'Off',
  '0',
  '  false  ', '\tno\n',
  0, -1, 2, 42, NaN, Infinity, -Infinity,
  null, undefined,
  {}, [], () => {},
  'arbitrary', 'unknown', 'invalid', ''
];
for (const val of falsyValues) {
  assert.equal(boolean(val), false, `boolean(${String(val)}) should return false`);
  assert.equal(parseBoolean(val), false, `parseBoolean(${String(val)}) should return false`);
}

// 5. Boxed String, Number, and Boolean objects
assert.equal(boolean(new String('true')), true, 'boolean(new String("true")) should return true');
assert.equal(boolean(new String('yes')), true, 'boolean(new String("yes")) should return true');
assert.equal(boolean(new String('false')), false, 'boolean(new String("false")) should return false');
assert.equal(boolean(new Number(1)), true, 'boolean(new Number(1)) should return true');
assert.equal(boolean(new Number(0)), false, 'boolean(new Number(0)) should return false');
assert.equal(boolean(new Number(42)), false, 'boolean(new Number(42)) should return false');
assert.equal(boolean(new Boolean(true)), true, 'boolean(new Boolean(true)) should return true');
assert.equal(boolean(new Boolean(false)), false, 'boolean(new Boolean(false)) should return false');

console.log('Contract passed: boolean.boolean in pkg:npm/boolean@3.2.0');

Ursprungs-Seeder

anonym