示例
jest-get-type 29.6.3: getType
已验证示例 — npm jest-get-type 29.6.3: getType. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: getType is exported as a function
sha256:873c5e9eaf2c8ce27c394621a7f596347994fe6cfc882a8da5630150c9e9d5cc
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
linux 24 · ubuntu · glibc 2.39 x64 npm
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-21 |
案例
HOW- 目标
- verify pkg:npm/jest-get-type@29.6.3
- 符号
-
- getType
- 创建时间
- 2026-08-21T05:49:24Z
契约
- getType is exported as a function
- getType accurately distinguishes primitive values including undefined, null, boolean, number, bigint, string, and symbol
- getType accurately distinguishes built-in objects including array, regexp, map, set, and date
- getType identifies standard functions, arrow functions, generator functions, async functions, and class constructors as function
- getType identifies plain objects and objects created with Object.create(null) as object
文件
- 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 pkg:npm/jest-get-type@29.6.3
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/jest-get-type@29.6.3
Demonstrate these symbols/APIs:
- getType
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:9746989da034b3481bc7bb5b424817f37091684d7f8eee54c873402ecc42504b","contract":["getType is exported as a function","getType accurately distinguishes primitive values including undefined, null, boolean, number, bigint, string, and symbol","getType accurately distinguishes built-in objects including array, regexp, map, set, and date","getType identifies standard functions, arrow functions, generator functions, async functions, and class constructors as function","getType identifies plain objects and objects created with Object.create(null) as object"],"goal":"verify pkg:npm/jest-get-type@29.6.3","kind":"HOW","packages":["pkg:npm/jest-get-type@29.6.3"],"schemaVersion":1,"symbols":["getType"]},"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/jest-get-type@29.6.3"],"schemaVersion":1,"subject":"pkg:npm/jest-get-type@29.6.3","symbols":["getType"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-jest-get-type",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-jest-get-type",
"version": "1.0.0",
"dependencies": {
"jest-get-type": "29.6.3"
}
},
"node_modules/jest-get-type": {
"version": "29.6.3",
"resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.6.3.tgz",
"integrity": "sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==",
"license": "MIT",
"engines": {
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
}
}
}
{
"name": "sample-jest-get-type",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of jest-get-type",
"main": "src/index.js",
"dependencies": {
"jest-get-type": "29.6.3"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/jest-get-type@29.6.3",
"kind": "HOW",
"packages": [
"pkg:npm/jest-get-type@29.6.3"
],
"symbols": [
"getType"
]
}
'use strict';
const { getType, isPrimitive } = require('jest-get-type');
/**
* Returns the exact type string for any JavaScript value.
* @param {*} value
* @returns {string}
*/
function identifyType(value) {
return getType(value);
}
module.exports = {
getType,
isPrimitive,
identifyType
};
import assert from 'node:assert';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const { getType, isPrimitive, identifyType } = require('../src/index.js');
// 1. Export verification
assert.strictEqual(typeof getType, 'function', 'getType should be a function');
assert.strictEqual(typeof isPrimitive, 'function', 'isPrimitive should be a function');
assert.strictEqual(typeof identifyType, 'function', 'identifyType should be a function');
// 2. Primitive values
assert.strictEqual(getType(undefined), 'undefined', 'undefined should return "undefined"');
assert.strictEqual(getType(null), 'null', 'null should return "null"');
assert.strictEqual(getType(true), 'boolean', 'true should return "boolean"');
assert.strictEqual(getType(false), 'boolean', 'false should return "boolean"');
assert.strictEqual(getType(0), 'number', '0 should return "number"');
assert.strictEqual(getType(-42.5), 'number', '-42.5 should return "number"');
assert.strictEqual(getType(NaN), 'number', 'NaN should return "number"');
assert.strictEqual(getType(Infinity), 'number', 'Infinity should return "number"');
assert.strictEqual(getType(-Infinity), 'number', '-Infinity should return "number"');
assert.strictEqual(getType(0n), 'bigint', '0n should return "bigint"');
assert.strictEqual(getType(9007199254740991n), 'bigint', '9007199254740991n should return "bigint"');
assert.strictEqual(getType(''), 'string', 'empty string should return "string"');
assert.strictEqual(getType('jest-get-type'), 'string', 'string should return "string"');
assert.strictEqual(getType(Symbol('sym')), 'symbol', 'symbol should return "symbol"');
assert.strictEqual(getType(Symbol.iterator), 'symbol', 'well-known symbol should return "symbol"');
// 3. Built-in objects
assert.strictEqual(getType([]), 'array', '[] should return "array"');
assert.strictEqual(getType([1, 2, 3]), 'array', '[1, 2, 3] should return "array"');
assert.strictEqual(getType(new Array(5)), 'array', 'new Array() should return "array"');
assert.strictEqual(getType(/test/i), 'regexp', '/test/i should return "regexp"');
assert.strictEqual(getType(new RegExp('test')), 'regexp', 'new RegExp() should return "regexp"');
assert.strictEqual(getType(new Map()), 'map', 'new Map() should return "map"');
assert.strictEqual(getType(new Set()), 'set', 'new Set() should return "set"');
assert.strictEqual(getType(new Date()), 'date', 'new Date() should return "date"');
// 4. Functions and classes
function standardFunction() {}
const arrowFunction = () => {};
function* generatorFunction() {}
async function asyncFunction() {}
class SampleClass {}
assert.strictEqual(getType(standardFunction), 'function', 'standard function should return "function"');
assert.strictEqual(getType(arrowFunction), 'function', 'arrow function should return "function"');
assert.strictEqual(getType(generatorFunction), 'function', 'generator function should return "function"');
assert.strictEqual(getType(asyncFunction), 'function', 'async function should return "function"');
assert.strictEqual(getType(SampleClass), 'function', 'class constructor should return "function"');
// 5. Plain objects
assert.strictEqual(getType({}), 'object', '{} should return "object"');
assert.strictEqual(getType({ a: 1, b: 'test' }), 'object', 'object with properties should return "object"');
assert.strictEqual(getType(Object.create(null)), 'object', 'Object.create(null) should return "object"');
// 6. Wrapper function consistency
assert.strictEqual(identifyType('hello'), 'string');
assert.strictEqual(identifyType([1, 2]), 'array');
assert.strictEqual(identifyType(null), 'null');
// 7. isPrimitive helper checks
assert.strictEqual(isPrimitive(123), true);
assert.strictEqual(isPrimitive('text'), true);
assert.strictEqual(isPrimitive(null), true);
assert.strictEqual(isPrimitive(undefined), true);
assert.strictEqual(isPrimitive(Symbol('s')), true);
assert.strictEqual(isPrimitive(10n), true);
assert.strictEqual(isPrimitive({}), false);
assert.strictEqual(isPrimitive([]), false);
console.log('Contract tests passed successfully.');
原始种子者
匿名