CodeSampleX

Exemple

@jest/get-type 30.1.0: getType, isPrimitive

Échantillon vérifié pour npm @jest/get-type 30.1.0: getType, isPrimitive. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi.

sha256:087f804549111071559eb04b87e3622369039a395db0d1699ae8f8b2ab6dc59a

Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré. Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes. MIT-0

Preuves d'exécution

L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.

Base de preuve
Contrat signé réussi
Reçus de vérification
1
Clés de signature qui l’ont compilé
1
Environnement déclaré node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5…
2026-08-27

Cas

HOW
Objectif
verify pkg:npm/%40jest/get-type@30.1.0
Paquets
Symboles
  • getType
  • isPrimitive
Environnement
node 22.23.2
Créé
2026-08-27T22:45:45Z

Contrat

  1. getType returns string identifier for primitive types: undefined, null, boolean, number, string, symbol, and bigint
  2. getType returns string identifier for object instances: array, object, regexp, map, set, date, and function
  3. isPrimitive returns true for primitive values (including null and undefined) and false for objects, arrays, and functions

Fichiers

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

Télécharger l’artefact source (tar.gz)

Code source

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 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:
  - getType
  - isPrimitive

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:2f92d58a947e278892f60c4fb12fc7680fc503f2323192ee8bccba6d546fa4de","contract":["getType returns string identifier for primitive types: undefined, null, boolean, number, string, symbol, and bigint","getType returns string identifier for object instances: array, object, regexp, map, set, date, and function","isPrimitive returns true for primitive values (including null and undefined) and false for objects, arrays, and functions"],"goal":"verify pkg:npm/%40jest/get-type@30.1.0","kind":"HOW","packages":["pkg:npm/%40jest/get-type@30.1.0"],"schemaVersion":1,"symbols":["getType","isPrimitive"]},"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":["getType","isPrimitive"],"verifierAdapter":"node-typescript@1"}
index.js
'use strict';

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

function describeValue(value) {
  return {
    type: getType(value),
    isPrimitive: isPrimitive(value)
  };
}

module.exports = {
  describeValue,
  getType,
  isPrimitive
};
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 getType and isPrimitive 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 pkg:npm/%40jest/get-type@30.1.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40jest/get-type@30.1.0"
  ],
  "symbols": [
    "getType",
    "isPrimitive"
  ]
}
test/contract.cjs
'use strict';

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

// 1. Verify function exports
assert.strictEqual(typeof jestGetType.getType, 'function', 'getType must be a function');
assert.strictEqual(typeof jestGetType.isPrimitive, 'function', 'isPrimitive must be a function');
assert.strictEqual(typeof describeValue, 'function', 'describeValue must be a function');

// 2. getType primitive types
assert.strictEqual(jestGetType.getType(undefined), 'undefined');
assert.strictEqual(jestGetType.getType(null), 'null');
assert.strictEqual(jestGetType.getType(true), 'boolean');
assert.strictEqual(jestGetType.getType(false), 'boolean');
assert.strictEqual(jestGetType.getType(42), 'number');
assert.strictEqual(jestGetType.getType(NaN), 'number');
assert.strictEqual(jestGetType.getType('jest'), 'string');
assert.strictEqual(jestGetType.getType(''), 'string');
assert.strictEqual(jestGetType.getType(Symbol('sym')), 'symbol');
assert.strictEqual(jestGetType.getType(100n), 'bigint');

// 3. getType reference and object types
assert.strictEqual(jestGetType.getType([]), 'array');
assert.strictEqual(jestGetType.getType([1, 2, 3]), 'array');
assert.strictEqual(jestGetType.getType({}), 'object');
assert.strictEqual(jestGetType.getType({ key: 'val' }), 'object');
assert.strictEqual(jestGetType.getType(/test-pattern/i), 'regexp');
assert.strictEqual(jestGetType.getType(new RegExp('test')), 'regexp');
assert.strictEqual(jestGetType.getType(new Map()), 'map');
assert.strictEqual(jestGetType.getType(new Set()), 'set');
assert.strictEqual(jestGetType.getType(new Date()), 'date');
assert.strictEqual(jestGetType.getType(() => {}), 'function');
assert.strictEqual(jestGetType.getType(function named() {}), 'function');
assert.strictEqual(jestGetType.getType(async () => {}), 'function');

// 4. isPrimitive validation
assert.strictEqual(jestGetType.isPrimitive(undefined), true);
assert.strictEqual(jestGetType.isPrimitive(null), true);
assert.strictEqual(jestGetType.isPrimitive(true), true);
assert.strictEqual(jestGetType.isPrimitive(false), true);
assert.strictEqual(jestGetType.isPrimitive(0), true);
assert.strictEqual(jestGetType.isPrimitive('text'), true);
assert.strictEqual(jestGetType.isPrimitive(Symbol.for('id')), true);
assert.strictEqual(jestGetType.isPrimitive(99999999999999999999n), true);

assert.strictEqual(jestGetType.isPrimitive({}), false);
assert.strictEqual(jestGetType.isPrimitive([]), false);
assert.strictEqual(jestGetType.isPrimitive(/regex/), false);
assert.strictEqual(jestGetType.isPrimitive(new Map()), false);
assert.strictEqual(jestGetType.isPrimitive(new Set()), false);
assert.strictEqual(jestGetType.isPrimitive(new Date()), false);
assert.strictEqual(jestGetType.isPrimitive(() => {}), false);

// 5. Helper function describeValue verification
const descString = describeValue('sample');
assert.deepStrictEqual(descString, { type: 'string', isPrimitive: true });

const descMap = describeValue(new Map());
assert.deepStrictEqual(descMap, { type: 'map', isPrimitive: false });

const descNull = describeValue(null);
assert.deepStrictEqual(descNull, { type: 'null', isPrimitive: true });

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

Seeder d'origine

anonyme