CodeSampleX

샘플

boolean 3.2.0: isBooleanable

검증된 샘플 — npm boolean 3.2.0: isBooleanable. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: isBooleanable returns true for truthy strings…

sha256:f2f2fcec40894bdf8b8f316c3dd3fddf3d83d1213d54dfb2f4ca6adb66f62516

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

검증 실행 환경

환경 컨트랙트 단계 실행일
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

케이스

HOW
목표
verify boolean.isBooleanable in pkg:npm/boolean@3.2.0
패키지
심벌
  • boolean.isBooleanable
환경
node 22.23.2
생성일
2026-09-06T11:58:19Z

컨트랙트

  1. isBooleanable returns true for truthy strings including true, t, yes, y, on, and 1 case-insensitively and trimmed
  2. isBooleanable returns true for falsy strings including false, f, no, n, off, and 0 case-insensitively and trimmed
  3. isBooleanable returns true for numeric 0, numeric 1, and boolean true and false
  4. isBooleanable returns true for boxed String, Number, and Boolean objects representing boolean values
  5. isBooleanable returns false for non-boolean numbers, arbitrary strings, null, undefined, and objects

파일

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

소스 아티팩트 내려받기 (tar.gz)

소스

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.isBooleanable 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.isBooleanable

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:ef422e2a88eb73c8388a5d8d39bbc866e098826aba0edc3df27adb962c45eef8","contract":["isBooleanable returns true for truthy strings including true, t, yes, y, on, and 1 case-insensitively and trimmed","isBooleanable returns true for falsy strings including false, f, no, n, off, and 0 case-insensitively and trimmed","isBooleanable returns true for numeric 0, numeric 1, and boolean true and false","isBooleanable returns true for boxed String, Number, and Boolean objects representing boolean values","isBooleanable returns false for non-boolean numbers, arbitrary strings, null, undefined, and objects"],"goal":"verify boolean.isBooleanable in pkg:npm/boolean@3.2.0","kind":"HOW","packages":["pkg:npm/boolean@3.2.0"],"schemaVersion":1,"symbols":["boolean.isBooleanable"]},"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.isBooleanable"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-boolean-is-booleanable",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-boolean-is-booleanable",
      "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-is-booleanable",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room code sample for boolean.isBooleanable in pkg:npm/boolean@3.2.0",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "boolean": "3.2.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify boolean.isBooleanable in pkg:npm/boolean@3.2.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/boolean@3.2.0"
  ],
  "symbols": [
    "boolean.isBooleanable"
  ]
}
src/index.js
const { isBooleanable, boolean } = require('boolean');

/**
 * Validates whether a given value can be interpreted as a boolean.
 *
 * Recognized truthy representations:
 * - 'true', 't', 'yes', 'y', 'on', '1' (case-insensitive, trimmed)
 * - 1
 * - true
 *
 * Recognized falsy representations:
 * - 'false', 'f', 'no', 'n', 'off', '0' (case-insensitive, trimmed)
 * - 0
 * - false
 *
 * Also supports boxed String, Number, and Boolean objects.
 *
 * @param {*} value - The input value to check.
 * @returns {boolean} True if the value is booleanable, false otherwise.
 */
function checkIsBooleanable(value) {
  return isBooleanable(value);
}

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

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

// 1. Export verification
assert.equal(typeof isBooleanable, 'function', 'isBooleanable should be exported as a function');
assert.equal(typeof checkIsBooleanable, 'function', 'checkIsBooleanable should be exported as a function');

// 2. Truthy strings (case-insensitive and whitespace-tolerant)
const truthyStrings = ['true', 'TRUE', 'True', 't', 'T', 'yes', 'YES', 'y', 'Y', 'on', 'ON', '1', '  true  ', '\tyes\n', ' ON '];
for (const val of truthyStrings) {
  assert.equal(isBooleanable(val), true, `isBooleanable(${JSON.stringify(val)}) should be true`);
  assert.equal(checkIsBooleanable(val), true, `checkIsBooleanable(${JSON.stringify(val)}) should be true`);
}

// 3. Falsy strings (case-insensitive and whitespace-tolerant)
const falsyStrings = ['false', 'FALSE', 'False', 'f', 'F', 'no', 'NO', 'n', 'N', 'off', 'OFF', '0', '  false  ', '\tno\n', ' OFF '];
for (const val of falsyStrings) {
  assert.equal(isBooleanable(val), true, `isBooleanable(${JSON.stringify(val)}) should be true`);
  assert.equal(checkIsBooleanable(val), true, `checkIsBooleanable(${JSON.stringify(val)}) should be true`);
}

// 4. Numeric 0, 1 and boolean literals
assert.equal(isBooleanable(0), true, 'isBooleanable(0) should be true');
assert.equal(isBooleanable(1), true, 'isBooleanable(1) should be true');
assert.equal(isBooleanable(true), true, 'isBooleanable(true) should be true');
assert.equal(isBooleanable(false), true, 'isBooleanable(false) should be true');
assert.equal(checkIsBooleanable(0), true, 'checkIsBooleanable(0) should be true');
assert.equal(checkIsBooleanable(1), true, 'checkIsBooleanable(1) should be true');
assert.equal(checkIsBooleanable(true), true, 'checkIsBooleanable(true) should be true');
assert.equal(checkIsBooleanable(false), true, 'checkIsBooleanable(false) should be true');

// 5. Boxed String, Number, and Boolean objects
assert.equal(isBooleanable(new String('true')), true, 'isBooleanable(new String("true")) should be true');
assert.equal(isBooleanable(new String('false')), true, 'isBooleanable(new String("false")) should be true');
assert.equal(isBooleanable(new String('YES')), true, 'isBooleanable(new String("YES")) should be true');
assert.equal(isBooleanable(new String('off')), true, 'isBooleanable(new String("off")) should be true');
assert.equal(isBooleanable(new Number(1)), true, 'isBooleanable(new Number(1)) should be true');
assert.equal(isBooleanable(new Number(0)), true, 'isBooleanable(new Number(0)) should be true');
assert.equal(isBooleanable(new Boolean(true)), true, 'isBooleanable(new Boolean(true)) should be true');
assert.equal(isBooleanable(new Boolean(false)), true, 'isBooleanable(new Boolean(false)) should be true');

// 6. Non-boolean numbers, arbitrary strings, null, undefined, and objects
const nonBooleanables = [
  'foo', 'bar', '2', '-1', 'truthy', 'falsy', 'null', 'undefined',
  2, -1, 100, 3.14, NaN, Infinity, -Infinity,
  null, undefined,
  {}, [], () => {}, Symbol('test'), new Date()
];
for (const val of nonBooleanables) {
  assert.equal(isBooleanable(val), false, `isBooleanable(${String(val)}) should be false`);
  assert.equal(checkIsBooleanable(val), false, `checkIsBooleanable(${String(val)}) should be false`);
}

console.log('All boolean.isBooleanable contract tests passed successfully.');

오리진 시더

익명