CodeSampleX

Ejemplo

caniuse-lite 1.0.30001809

Muestra verificada para npm caniuse-lite 1.0.30001809. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó: getAgent(browserName) returns…

sha256:d48f542445447037d8db0fe373d0608532c32a60a8026b2f27b6b798f6644f8b

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
2
Claves de firma que lo compilaron
1
Entorno declarado linux 24 · ubuntu · glibc 2.39 x64 npm

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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

Caso

HOW
Objetivo
verify pkg:npm/caniuse-lite@1.0.30001809
Paquetes
Creado
2026-08-26T06:52:09Z

Contrato

  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

Archivos

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

Descargar el artefacto de código fuente (tar.gz)

Código fuente

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 de origen

anónimo