CodeSampleX

Exemple

caniuse-lite 1.0.30001809

Échantillon vérifié pour npm caniuse-lite 1.0.30001809. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi.

sha256:d48f542445447037d8db0fe373d0608532c32a60a8026b2f27b6b798f6644f8b

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
2
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 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-26
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-07

Cas

HOW
Objectif
verify pkg:npm/caniuse-lite@1.0.30001809
Paquets
Créé
2026-08-26T06:52:09Z

Contrat

  1. getAgent(browserName) returns browser metadata including name, prefix, and supported versions
  2. getFeature(featureName) unpacks and returns feature title, status, and browser support stats
  3. getFeatureSupport(featureName, browserName, version) returns support status string or null for invalid queries
  4. isFeatureSupported(featureName, browserName, version) returns true for supported browser versions and false otherwise
  5. getRegionStats(regionData) unpacks regional browser usage statistics

Fichiers

  • PROMPT.md
  • csx.json
  • index.mjs
  • 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 pkg:npm/caniuse-lite@1.0.30001809
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/caniuse-lite@1.0.30001809

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:b665d2079a5acefe0c3887b7ebe0f23ca335f2a7ce8bfaf5d4c32012a256bbb4","contract":["getAgent(browserName) returns browser metadata including name, prefix, and supported versions","getFeature(featureName) unpacks and returns feature title, status, and browser support stats","getFeatureSupport(featureName, browserName, version) returns support status string or null for invalid queries","isFeatureSupported(featureName, browserName, version) returns true for supported browser versions and false otherwise","getRegionStats(regionData) unpacks regional browser usage statistics"],"goal":"verify pkg:npm/caniuse-lite@1.0.30001809","kind":"HOW","packages":["pkg:npm/caniuse-lite@1.0.30001809"],"schemaVersion":1},"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/caniuse-lite@1.0.30001809"],"schemaVersion":1,"subject":"pkg:npm/caniuse-lite@1.0.30001809","verifierAdapter":"node-typescript@1"}
index.mjs
import { agents, feature, features, region } from 'caniuse-lite';

export function getAgent(browserName) {
  return agents[browserName] ?? null;
}

export function getFeature(featureName) {
  const raw = features[featureName];
  if (!raw) return null;
  return feature(raw);
}

export function getFeatureSupport(featureName, browserName, version) {
  const feat = getFeature(featureName);
  if (!feat || !feat.stats || !feat.stats[browserName]) return null;
  return feat.stats[browserName][version] ?? null;
}

export function isFeatureSupported(featureName, browserName, version) {
  const support = getFeatureSupport(featureName, browserName, version);
  if (!support) return false;
  return support.startsWith('y');
}

export function getRegionStats(regionData) {
  return region(regionData);
}
package-lock.json
{
  "name": "sample-caniuse-lite",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-caniuse-lite",
      "version": "1.0.0",
      "dependencies": {
        "caniuse-lite": "1.0.30001809"
      }
    },
    "node_modules/caniuse-lite": {
      "version": "1.0.30001809",
      "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001809.tgz",
      "integrity": "sha512-xxWVywk6a6Arlk+hymeycyn/VgqEfLDxupvhH/xiY5SJ/18kmi9o6MiO320DCUzypORHLtvh0I4i04tUhCNHNQ==",
      "funding": [
        {
          "type": "opencollective",
          "url": "https://opencollective.com/browserslist"
        },
        {
          "type": "tidelift",
          "url": "https://tidelift.com/funding/github/npm/caniuse-lite"
        },
        {
          "type": "github",
          "url": "https://github.com/sponsors/ai"
        }
      ],
      "license": "CC-BY-4.0"
    }
  }
}
package.json
{
  "name": "sample-caniuse-lite",
  "version": "1.0.0",
  "description": "Clean-room verification sample for caniuse-lite",
  "type": "module",
  "private": true,
  "dependencies": {
    "caniuse-lite": "1.0.30001809"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/caniuse-lite@1.0.30001809",
  "kind": "HOW",
  "packages": [
    "pkg:npm/caniuse-lite@1.0.30001809"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import usRegion from 'caniuse-lite/data/regions/US.js';
import {
  getAgent,
  getFeature,
  getFeatureSupport,
  isFeatureSupported,
  getRegionStats
} from '../index.mjs';

// 1. getAgent(browserName) returns browser metadata including name, prefix, and supported versions
const chromeAgent = getAgent('chrome');
assert.ok(chromeAgent !== null, 'Chrome agent should exist');
assert.equal(chromeAgent.browser, 'Chrome');
assert.equal(chromeAgent.prefix, 'webkit');
assert.ok(Array.isArray(chromeAgent.versions), 'Versions should be an array');
assert.ok(chromeAgent.versions.includes('150'), 'Versions should include version 150');
assert.equal(typeof chromeAgent.usage_global['150'], 'number');
assert.equal(getAgent('nonexistent_browser'), null);

// 2. getFeature(featureName) unpacks and returns feature title, status, and browser support stats
const fetchFeature = getFeature('fetch');
assert.ok(fetchFeature !== null, 'Fetch feature should exist');
assert.equal(fetchFeature.title, 'Fetch');
assert.equal(typeof fetchFeature.status, 'string');
assert.ok(fetchFeature.stats && typeof fetchFeature.stats === 'object');
assert.equal(getFeature('nonexistent_feature'), null);

// 3. getFeatureSupport(featureName, browserName, version) returns support status string or null for invalid queries
assert.equal(getFeatureSupport('fetch', 'chrome', '100'), 'y');
assert.equal(getFeatureSupport('fetch', 'ie', '11'), 'n');
assert.equal(getFeatureSupport('css-grid', 'ie', '11'), 'a x #2');
assert.equal(getFeatureSupport('fetch', 'chrome', 'invalid_ver_9999'), null);
assert.equal(getFeatureSupport('nonexistent_feature', 'chrome', '100'), null);

// 4. isFeatureSupported(featureName, browserName, version) returns true for supported browser versions and false otherwise
assert.equal(isFeatureSupported('fetch', 'chrome', '100'), true);
assert.equal(isFeatureSupported('fetch', 'ie', '11'), false);
assert.equal(isFeatureSupported('css-grid', 'chrome', '60'), true);
assert.equal(isFeatureSupported('css-grid', 'chrome', '57'), true);
assert.equal(isFeatureSupported('css-grid', 'ie', '11'), false);
assert.equal(isFeatureSupported('nonexistent_feature', 'chrome', '100'), false);

// 5. getRegionStats(regionData) unpacks regional browser usage statistics
const usStats = getRegionStats(usRegion);
assert.ok(usStats && typeof usStats === 'object');
assert.ok('chrome' in usStats);
assert.equal(typeof usStats.chrome['150'], 'number');

console.log('All caniuse-lite@1.0.30001809 contract assertions passed.');

Seeder d'origine

anonyme