CodeSampleX

샘플

type-detect 4.0.8: type detection for primitives, built-ins, and complex JavaScript objects using type-detect

검증된 샘플 — npm type-detect 4.0.8: type detection for primitives, built-ins, and complex JavaScript objects using type-detect. node 22 · linux alpine/x64 …

sha256:cdbd7ba6fa2e2fa4e23268791e70644ce520d8ed87a8521630dbf86f26941c24

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. 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@1node:22-alpine@sha256:c610fcdfb1d5…
2026-08-27

케이스

HOW
목표
type detection for primitives, built-ins, and complex JavaScript objects using type-detect
패키지
심벌
  • typeDetect
생성일
2026-08-27T21:21:10Z

컨트랙트

  1. typeDetect(null) === "null"
  2. typeDetect(undefined) === "undefined"
  3. typeDetect(42) === "number"
  4. typeDetect(NaN) === "number"
  5. typeDetect("hello") === "string"
  6. typeDetect(true) === "boolean"
  7. typeDetect(Symbol("test")) === "symbol"
  8. typeDetect(100n) === "bigint"
  9. typeDetect([]) === "Array"
  10. typeDetect({}) === "Object"
  11. typeDetect(new Map()) === "Map"
  12. typeDetect(new Set()) === "Set"
  13. typeDetect(new WeakMap()) === "WeakMap"
  14. typeDetect(new WeakSet()) === "WeakSet"
  15. typeDetect(Promise.resolve()) === "Promise"
  16. typeDetect(/regex/g) === "RegExp"
  17. typeDetect(new Date()) === "Date"
  18. typeDetect(new Error("err")) === "Error"
  19. typeDetect(new Uint8Array(8)) === "Uint8Array"
  20. typeDetect(new ArrayBuffer(16)) === "ArrayBuffer"
  21. typeDetect(new DataView(new ArrayBuffer(16))) === "DataView"
  22. typeDetect(() => {}) === "function"
  23. typeDetect(function named() {}) === "function"

파일

  • PROMPT.md
  • csx.json
  • index.mjs
  • package-lock.json
  • package.json
  • spec.json
  • 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: type detection for primitives, built-ins, and complex JavaScript objects using type-detect
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/type-detect@4.0.8
Demonstrate these symbols/APIs:
  - typeDetect

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:2553da6ffcd6a1cd3e0f9ea093ea32a7c618d2c92c5f8bd42ae6263d6b35beef","contract":["typeDetect(null) === \"null\"","typeDetect(undefined) === \"undefined\"","typeDetect(42) === \"number\"","typeDetect(NaN) === \"number\"","typeDetect(\"hello\") === \"string\"","typeDetect(true) === \"boolean\"","typeDetect(Symbol(\"test\")) === \"symbol\"","typeDetect(100n) === \"bigint\"","typeDetect([]) === \"Array\"","typeDetect({}) === \"Object\"","typeDetect(new Map()) === \"Map\"","typeDetect(new Set()) === \"Set\"","typeDetect(new WeakMap()) === \"WeakMap\"","typeDetect(new WeakSet()) === \"WeakSet\"","typeDetect(Promise.resolve()) === \"Promise\"","typeDetect(/regex/g) === \"RegExp\"","typeDetect(new Date()) === \"Date\"","typeDetect(new Error(\"err\")) === \"Error\"","typeDetect(new Uint8Array(8)) === \"Uint8Array\"","typeDetect(new ArrayBuffer(16)) === \"ArrayBuffer\"","typeDetect(new DataView(new ArrayBuffer(16))) === \"DataView\"","typeDetect(() =\u003e {}) === \"function\"","typeDetect(function named() {}) === \"function\""],"goal":"type detection for primitives, built-ins, and complex JavaScript objects using type-detect","kind":"HOW","packages":["pkg:npm/type-detect@4.0.8"],"schemaVersion":1,"symbols":["typeDetect"]},"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/type-detect@4.0.8"],"schemaVersion":1,"subject":"pkg:npm/type-detect@4.0.8","symbols":["typeDetect"],"verifierAdapter":"node-typescript@1"}
index.mjs
import typeDetect from 'type-detect';

/**
 * Returns the exact type of the given value.
 * Distinguishes primitives, built-ins, and complex objects.
 *
 * @param {*} value
 * @returns {string}
 */
export function identifyType(value) {
  return typeDetect(value);
}

export default typeDetect;
package-lock.json
{
  "name": "type-detect-sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "type-detect-sample",
      "version": "1.0.0",
      "dependencies": {
        "type-detect": "4.0.8"
      }
    },
    "node_modules/type-detect": {
      "version": "4.0.8",
      "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz",
      "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==",
      "license": "MIT",
      "engines": {
        "node": ">=4"
      }
    }
  }
}
package.json
{
  "name": "type-detect-sample",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "dependencies": {
    "type-detect": "4.0.8"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "type detection for primitives, built-ins, and complex JavaScript objects using type-detect",
  "kind": "HOW",
  "packages": [
    "pkg:npm/type-detect@4.0.8"
  ],
  "symbols": [
    "typeDetect"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import typeDetect from 'type-detect';
import { identifyType } from '../index.mjs';

// Primitive types
assert.equal(typeDetect(null), 'null');
assert.equal(typeDetect(undefined), 'undefined');
assert.equal(typeDetect(42), 'number');
assert.equal(typeDetect(NaN), 'number');
assert.equal(typeDetect('hello'), 'string');
assert.equal(typeDetect(true), 'boolean');
assert.equal(typeDetect(Symbol('test')), 'symbol');
assert.equal(typeDetect(100n), 'bigint');

// Built-in objects and collections
assert.equal(typeDetect([]), 'Array');
assert.equal(typeDetect({}), 'Object');
assert.equal(typeDetect(new Map()), 'Map');
assert.equal(typeDetect(new Set()), 'Set');
assert.equal(typeDetect(new WeakMap()), 'WeakMap');
assert.equal(typeDetect(new WeakSet()), 'WeakSet');
assert.equal(typeDetect(Promise.resolve()), 'Promise');
assert.equal(typeDetect(/regex/g), 'RegExp');
assert.equal(typeDetect(new Date()), 'Date');
assert.equal(typeDetect(new Error('err')), 'Error');
assert.equal(typeDetect(new Uint8Array(8)), 'Uint8Array');
assert.equal(typeDetect(new ArrayBuffer(16)), 'ArrayBuffer');
assert.equal(typeDetect(new DataView(new ArrayBuffer(16))), 'DataView');

// Functions
assert.equal(typeDetect(() => {}), 'function');
assert.equal(typeDetect(function named() {}), 'function');

// identifyType helper wrapper
assert.equal(identifyType([1, 2, 3]), 'Array');
assert.equal(identifyType(new Map()), 'Map');

console.log('Contract passed');

오리진 시더

익명