示例
boolean 3.2.0: isBooleanable
已验证示例 — npm boolean 3.2.0: isBooleanable. contract 在 node 22 · linux debian/x64 · docker 上运行并通过: isBooleanable returns true for truthy strings including true…
sha256:f2f2fcec40894bdf8b8f316c3dd3fddf3d83d1213d54dfb2f4ca6adb66f62516
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
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
契约
- 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
文件
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
源代码
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.
{"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"}
{
"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"
}
}
}
{
"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"
}
}
{
"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"
]
}
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
};
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.');
原始种子者
匿名