CodeSampleX

Пример

@jest/get-type 30.1.0: getType

Проверенный пример — npm @jest/get-type 30.1.0: getType. Контракт выполнен на node 22 · linux debian/x64 · docker и пройден: getType identifies JavaScript…

sha256:81bf725f2df5024bdf2d0c6b67f5921e6ba253d8463420a59de6bcf1b148545e

Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла. Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди. 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-05

Кейс

HOW
Цель
verify @jest/get-type.getType in pkg:npm/%40jest/get-type@30.1.0
Пакеты
Символы
  • @jest/get-type.getType
Окружение
node 22.23.2
Создан
2026-09-05T23:53:57Z

Контракт

  1. getType identifies JavaScript primitives: undefined, null, boolean, number, string, symbol, and bigint
  2. getType identifies built-in collection and object types: array, map, set, date, and regexp
  3. getType distinguishes plain objects and functions from specialized built-ins

Файлы

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

Скачать артефакт с исходным кодом (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 @jest/get-type.getType in pkg:npm/%40jest/get-type@30.1.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40jest/get-type@30.1.0
Demonstrate these symbols/APIs:
  - @jest/get-type.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.
csx.json
{"case":{"caseId":"case:sha256:36de8895f4a0173af1e3fcc7329f4a21ac5e2601eadde7ed740509b8e9b261c8","contract":["getType identifies JavaScript primitives: undefined, null, boolean, number, string, symbol, and bigint","getType identifies built-in collection and object types: array, map, set, date, and regexp","getType distinguishes plain objects and functions from specialized built-ins"],"goal":"verify @jest/get-type.getType in pkg:npm/%40jest/get-type@30.1.0","kind":"HOW","packages":["pkg:npm/%40jest/get-type@30.1.0"],"schemaVersion":1,"symbols":["@jest/get-type.getType"]},"contractCommand":["node","test/contract.cjs"],"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/%40jest/get-type@30.1.0"],"schemaVersion":1,"subject":"pkg:npm/%40jest/get-type@30.1.0","symbols":["@jest/get-type.getType"],"verifierAdapter":"node-typescript@1"}
index.js
'use strict';

const { getType } = require('@jest/get-type');

function categorizeValue(value) {
  return getType(value);
}

module.exports = {
  getType,
  categorizeValue
};
package-lock.json
{
  "name": "sample-jest-get-type",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-jest-get-type",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@jest/get-type": "30.1.0"
      }
    },
    "node_modules/@jest/get-type": {
      "version": "30.1.0",
      "resolved": "https://registry.npmjs.org/@jest/get-type/-/get-type-30.1.0.tgz",
      "integrity": "sha512-eMbZE2hUnx1WV0pmURZY9XoXPkUYjpc55mb0CrhtdWLtzMQPFvu/rZkTLZFTsdaVQa+Tr4eWAteqcUzoawq/uA==",
      "license": "MIT",
      "engines": {
        "node": "^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0"
      }
    }
  }
}
package.json
{
  "name": "sample-jest-get-type",
  "version": "1.0.0",
  "private": true,
  "description": "verify @jest/get-type.getType in pkg:npm/%40jest/get-type@30.1.0",
  "main": "index.js",
  "scripts": {
    "test": "node test/contract.cjs"
  },
  "dependencies": {
    "@jest/get-type": "30.1.0"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify @jest/get-type.getType in pkg:npm/%40jest/get-type@30.1.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40jest/get-type@30.1.0"
  ],
  "symbols": [
    "@jest/get-type.getType"
  ]
}
test/contract.cjs
'use strict';

const assert = require('node:assert/strict');
const { getType, categorizeValue } = require('../index.js');
const jestGetType = require('@jest/get-type');

// Verify exported functions
assert.strictEqual(typeof jestGetType.getType, 'function', 'getType must be exported as a function');
assert.strictEqual(typeof getType, 'function', 'getType must be re-exported');
assert.strictEqual(typeof categorizeValue, 'function', 'categorizeValue helper must be a function');

// Assertion 1: getType identifies JavaScript primitives: undefined, null, boolean, number, string, symbol, and bigint
assert.strictEqual(getType(undefined), 'undefined');
assert.strictEqual(getType(null), 'null');
assert.strictEqual(getType(true), 'boolean');
assert.strictEqual(getType(false), 'boolean');
assert.strictEqual(getType(0), 'number');
assert.strictEqual(getType(42), 'number');
assert.strictEqual(getType(-3.14), 'number');
assert.strictEqual(getType(NaN), 'number');
assert.strictEqual(getType(Infinity), 'number');
assert.strictEqual(getType(''), 'string');
assert.strictEqual(getType('hello world'), 'string');
assert.strictEqual(getType(Symbol('sym')), 'symbol');
assert.strictEqual(getType(Symbol.for('key')), 'symbol');
assert.strictEqual(getType(0n), 'bigint');
assert.strictEqual(getType(9007199254740991n), 'bigint');

// Assertion 2: getType identifies built-in collection and object types: array, map, set, date, and regexp
assert.strictEqual(getType([]), 'array');
assert.strictEqual(getType([1, 2, 3]), 'array');
assert.strictEqual(getType(new Array(5)), 'array');
assert.strictEqual(getType(new Map()), 'map');
assert.strictEqual(getType(new Set()), 'set');
assert.strictEqual(getType(new Date()), 'date');
assert.strictEqual(getType(/abc/), 'regexp');
assert.strictEqual(getType(new RegExp('xyz')), 'regexp');

// Assertion 3: getType distinguishes plain objects and functions from specialized built-ins
assert.strictEqual(getType({}), 'object');
assert.strictEqual(getType({ a: 1, b: 'two' }), 'object');
assert.strictEqual(getType(Object.create(null)), 'object');
assert.strictEqual(getType(() => {}), 'function');
assert.strictEqual(getType(function named() {}), 'function');
assert.strictEqual(getType(async () => {}), 'function');

// Helper function validation
assert.strictEqual(categorizeValue('test'), 'string');
assert.strictEqual(categorizeValue([10]), 'array');
assert.strictEqual(categorizeValue({ key: 'value' }), 'object');

console.log('Contract tests passed successfully.');

Исходный сидер

аноним