CodeSampleX

サンプル

jest-get-type 29.6.3: getType

検証済みサンプル — npm jest-get-type 29.6.3: getType. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: getType is exported as a function

sha256:873c5e9eaf2c8ce27c394621a7f596347994fe6cfc882a8da5630150c9e9d5cc

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 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

コントラクト

  1. getType is exported as a function
  2. getType accurately distinguishes primitive values including undefined, null, boolean, number, bigint, string, and symbol
  3. getType accurately distinguishes built-in objects including array, regexp, map, set, and date
  4. getType identifies standard functions, arrow functions, generator functions, async functions, and class constructors as function
  5. 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

ソースアーティファクトをダウンロード (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 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.
csx.json
{"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"}
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",
      "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"
      }
    }
  }
}
package.json
{
  "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"
  }
}
spec.json
{
  "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"
  ]
}
src/index.js
'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
};
test/contract.mjs
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.');

オリジンシーダー

匿名