CodeSampleX

Exemple

type-detect 4.0.8: type-detect

Échantillon vérifié pour npm type-detect 4.0.8: type-detect. Le contrat s'est exécuté sur node 22 · linux debian/x64 · docker et a réussi.

sha256:0e13cb3cbded458027e8fbdbabf92fcb5a6ed61f74235a793614e1b6a62bc033

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é linux 24 · ubuntu · glibc 2.39 x64 npm

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
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-02

Cas

HOW
Objectif
verify type-detect in pkg:npm/type-detect@4.0.8
Paquets
Symboles
  • type-detect
Créé
2026-09-02T07:41:19Z

Contrat

  1. type-detect returns exact lowercase type names for primitives including null, undefined, boolean, number, string, symbol, and bigint
  2. type-detect identifies standard built-in objects including Array, Object, Map, Set, WeakMap, WeakSet, Date, and RegExp
  3. type-detect returns function for standard functions, arrow functions, async functions, and generator functions
  4. type-detect identifies binary array structures including ArrayBuffer, DataView, and Uint8Array
  5. type-detect returns Error for Error instances and built-in error subclasses, and Promise for Promises

Fichiers

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

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 type-detect in pkg:npm/type-detect@4.0.8
Kind: HOW

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

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:7a34039c3df660e0fd0c722fcae77f7808b0a31377cb057ae78dcb5ec7598815","contract":["type-detect returns exact lowercase type names for primitives including null, undefined, boolean, number, string, symbol, and bigint","type-detect identifies standard built-in objects including Array, Object, Map, Set, WeakMap, WeakSet, Date, and RegExp","type-detect returns function for standard functions, arrow functions, async functions, and generator functions","type-detect identifies binary array structures including ArrayBuffer, DataView, and Uint8Array","type-detect returns Error for Error instances and built-in error subclasses, and Promise for Promises"],"goal":"verify type-detect in pkg:npm/type-detect@4.0.8","kind":"HOW","packages":["pkg:npm/type-detect@4.0.8"],"schemaVersion":1,"symbols":["type-detect"]},"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":["type-detect"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-type-detect",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-type-detect",
      "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": "sample-type-detect",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "dependencies": {
    "type-detect": "4.0.8"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify type-detect in pkg:npm/type-detect@4.0.8",
  "kind": "HOW",
  "packages": [
    "pkg:npm/type-detect@4.0.8"
  ],
  "symbols": [
    "type-detect"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import type from 'type-detect';

// 1. type-detect returns exact lowercase type names for primitives including null, undefined, boolean, number, string, symbol, and bigint
assert.equal(type(null), 'null');
assert.equal(type(undefined), 'undefined');
assert.equal(type(true), 'boolean');
assert.equal(type(false), 'boolean');
assert.equal(type(0), 'number');
assert.equal(type(NaN), 'number');
assert.equal(type(Infinity), 'number');
assert.equal(type(''), 'string');
assert.equal(type('sample-string'), 'string');
assert.equal(type(Symbol('sample-symbol')), 'symbol');
assert.equal(type(10n), 'bigint');

// 2. type-detect identifies standard built-in objects including Array, Object, Map, Set, WeakMap, WeakSet, Date, and RegExp
assert.equal(type([]), 'Array');
assert.equal(type([1, 2, 3]), 'Array');
assert.equal(type({}), 'Object');
assert.equal(type({ key: 'val' }), 'Object');
assert.equal(type(new Map()), 'Map');
assert.equal(type(new Set()), 'Set');
assert.equal(type(new WeakMap()), 'WeakMap');
assert.equal(type(new WeakSet()), 'WeakSet');
assert.equal(type(new Date()), 'Date');
assert.equal(type(/^[a-z]+$/i), 'RegExp');

// 3. type-detect returns function for standard functions, arrow functions, async functions, and generator functions
assert.equal(type(function named() {}), 'function');
assert.equal(type(() => {}), 'function');
assert.equal(type(async () => {}), 'function');
assert.equal(type(function* gen() {}), 'function');

// 4. type-detect identifies binary array structures including ArrayBuffer, DataView, and Uint8Array
assert.equal(type(new ArrayBuffer(16)), 'ArrayBuffer');
assert.equal(type(new DataView(new ArrayBuffer(16))), 'DataView');
assert.equal(type(new Uint8Array(8)), 'Uint8Array');
assert.equal(type(new Int32Array(8)), 'Int32Array');

// 5. type-detect returns Error for Error instances and built-in error subclasses, and Promise for Promises
assert.equal(type(new Error('generic error')), 'Error');
assert.equal(type(new TypeError('type error')), 'Error');
assert.equal(type(new RangeError('range error')), 'Error');
assert.equal(type(Promise.resolve(42)), 'Promise');

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

Seeder d'origine

anonyme