CodeSampleX

Ejemplo

baseline-browser-mapping 2.11.23: getAllVersions

Muestra verificada para npm baseline-browser-mapping 2.11.23: getAllVersions. El contrato se ejecutó en node 22 · linux debian/x64 · docker y pasó.

sha256:e020a0145d8efaef934ce1200aef88e8f1f2c458de224c0b016ce43b3f9c8327

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
1
Claves de firma que lo compilaron
1
Entorno declarado node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Entornos de las ejecuciones de verificación

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

Caso

HOW
Objetivo
verify baseline-browser-mapping.getAllVersions in pkg:npm/baseline-browser-mapping@2.11.23
Paquetes
Símbolos
  • baseline-browser-mapping.getAllVersions
Entorno
node 22.23.2
Creado
2026-11-21T21:55:18Z

Contrato

  1. getAllVersions returns a sorted array of core browser versions starting with pre_baseline and wa_compatible booleans by default
  2. getAllVersions returns a nested map keyed by browser and version when outputFormat is object
  3. getAllVersions returns quoted CSV with browser, version, year, wa_compatible, release_date, engine, and engine_version headers when outputFormat is csv
  4. getAllVersions includes downstream browser entries with engine metadata when includeDownstreamBrowsers is true and includes kai_os only when includeKaiOS is also true
  5. getAllVersions replaces wa_compatible with optional supports values (widely or newly) across array, object, and csv outputs when useSupports is true
  6. getAllVersions throws an Error when includeKaiOS is true and includeDownstreamBrowsers is false

Archivos

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

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 baseline-browser-mapping.getAllVersions in pkg:npm/baseline-browser-mapping@2.11.23
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/baseline-browser-mapping@2.11.23
Demonstrate these symbols/APIs:
  - baseline-browser-mapping.getAllVersions
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

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:780ae9fb3ab4cd35cdf0a664e2f069725752c6318c1895960c30c1731acda874","constraints":{"executionContext":"node"},"contract":["getAllVersions returns a sorted array of core browser versions starting with pre_baseline and wa_compatible booleans by default","getAllVersions returns a nested map keyed by browser and version when outputFormat is object","getAllVersions returns quoted CSV with browser, version, year, wa_compatible, release_date, engine, and engine_version headers when outputFormat is csv","getAllVersions includes downstream browser entries with engine metadata when includeDownstreamBrowsers is true and includes kai_os only when includeKaiOS is also true","getAllVersions replaces wa_compatible with optional supports values (widely or newly) across array, object, and csv outputs when useSupports is true","getAllVersions throws an Error when includeKaiOS is true and includeDownstreamBrowsers is false"],"goal":"verify baseline-browser-mapping.getAllVersions in pkg:npm/baseline-browser-mapping@2.11.23","kind":"HOW","packages":["pkg:npm/baseline-browser-mapping@2.11.23"],"schemaVersion":1,"symbols":["baseline-browser-mapping.getAllVersions"]},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/baseline-browser-mapping@2.11.23"],"schemaVersion":1,"subject":"pkg:npm/baseline-browser-mapping@2.11.23","symbols":["baseline-browser-mapping.getAllVersions"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "baseline-browser-mapping-getallversions-sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "baseline-browser-mapping-getallversions-sample",
      "version": "1.0.0",
      "dependencies": {
        "baseline-browser-mapping": "2.11.23"
      }
    },
    "node_modules/baseline-browser-mapping": {
      "version": "2.11.23",
      "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.23.tgz",
      "integrity": "sha512-le521dGVfxM7yRX0EikCoSz+rOK+hHzdDt/E7mG1jOJB/6WAAUuwVroLwaB7ApaUsz5Q0kFlDXLSA9MheUIfRQ==",
      "license": "Apache-2.0",
      "bin": {
        "baseline-browser-mapping": "dist/cli.cjs"
      },
      "engines": {
        "node": ">=6.0.0"
      }
    }
  }
}
package.json
{
  "name": "baseline-browser-mapping-getallversions-sample",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "baseline-browser-mapping": "2.11.23"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify baseline-browser-mapping.getAllVersions in pkg:npm/baseline-browser-mapping@2.11.23",
  "kind": "HOW",
  "packages": [
    "pkg:npm/baseline-browser-mapping@2.11.23"
  ],
  "symbols": [
    "baseline-browser-mapping.getAllVersions"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
const { getAllVersions } = require('baseline-browser-mapping');

function listAllVersions(options = {}) {
  return getAllVersions({ suppressWarnings: true, ...options });
}

module.exports = {
  getAllVersions,
  listAllVersions,
};
test/contract.js
const assert = require('node:assert/strict');
const { getAllVersions, listAllVersions } = require('../src/index.js');

// 1. Default array format returns core browser versions sorted from pre_baseline with wa_compatible
{
  const versions = listAllVersions();
  assert.ok(Array.isArray(versions), 'default output must be an array');
  assert.ok(versions.length > 0, 'default output must be non-empty');

  const browsers = new Set(versions.map((entry) => entry.browser));
  for (const core of ['chrome', 'edge', 'firefox', 'safari']) {
    assert.ok(browsers.has(core), `core browser ${core} must be present`);
  }
  assert.ok(!browsers.has('opera'), 'downstream browser opera must be excluded by default');
  assert.ok(!browsers.has('kai_os'), 'kai_os must be excluded by default');

  const first = versions[0];
  assert.strictEqual(first.year, 'pre_baseline', 'entries must start with pre_baseline');

  const chrome1 = versions.find((entry) => entry.browser === 'chrome' && entry.version === '1');
  assert.ok(chrome1, 'chrome version 1 entry must exist');
  assert.strictEqual(chrome1.year, 'pre_baseline');
  assert.strictEqual(chrome1.wa_compatible, false);
  assert.strictEqual(typeof chrome1.release_date, 'string');
  assert.strictEqual('supports' in chrome1, false);
}

// 2. outputFormat: "object" returns nested map keyed by browser then version
{
  const mapped = listAllVersions({ outputFormat: 'object' });
  assert.strictEqual(typeof mapped, 'object');
  assert.ok(mapped !== null && !Array.isArray(mapped));
  assert.ok(mapped.chrome && mapped.firefox && mapped.safari && mapped.edge);

  const chrome1 = mapped.chrome['1'];
  assert.ok(chrome1, 'nested chrome["1"] must exist');
  assert.strictEqual(chrome1.year, 'pre_baseline');
  assert.strictEqual(chrome1.wa_compatible, false);
  assert.strictEqual(typeof chrome1.release_date, 'string');
}

// 3. outputFormat: "csv" returns quoted CSV rows with expected headers
{
  const csv = listAllVersions({ outputFormat: 'csv' });
  assert.strictEqual(typeof csv, 'string');
  const lines = csv.trim().split('\n');
  assert.ok(lines.length > 1, 'CSV must have header and data rows');
  assert.strictEqual(
    lines[0],
    '"browser","version","year","wa_compatible","release_date","engine","engine_version"'
  );
  assert.ok(
    lines.slice(1).some((line) => line.startsWith('"chrome","1","pre_baseline","false",')),
    'CSV must contain chrome 1 pre_baseline row'
  );
}

// 4. includeDownstreamBrowsers: true adds downstream browsers while keeping kai_os opt-in via includeKaiOS
{
  const coreOnly = listAllVersions();
  const withDownstream = listAllVersions({ includeDownstreamBrowsers: true });
  assert.ok(withDownstream.length > coreOnly.length, 'downstream option must add entries');

  const downstreamBrowsers = new Set(withDownstream.map((entry) => entry.browser));
  assert.ok(downstreamBrowsers.has('opera'), 'opera must be included when includeDownstreamBrowsers is true');
  assert.ok(
    downstreamBrowsers.has('samsunginternet_android'),
    'samsunginternet_android must be included when includeDownstreamBrowsers is true'
  );
  assert.ok(!downstreamBrowsers.has('kai_os'), 'kai_os must remain excluded unless includeKaiOS is true');

  const operaEntry = withDownstream.find((entry) => entry.browser === 'opera');
  assert.ok(operaEntry && typeof operaEntry.engine === 'string' && typeof operaEntry.engine_version === 'string');

  const withKaiOS = listAllVersions({ includeDownstreamBrowsers: true, includeKaiOS: true });
  const kaiEntry = withKaiOS.find((entry) => entry.browser === 'kai_os');
  assert.ok(kaiEntry, 'kai_os must be included when both includeDownstreamBrowsers and includeKaiOS are true');
  assert.strictEqual(kaiEntry.engine, 'Gecko');
}

// 5. useSupports: true replaces wa_compatible with supports ("widely" / "newly") in array, object, and CSV outputs
{
  const entries = listAllVersions({ useSupports: true });
  assert.ok(entries.every((entry) => !('wa_compatible' in entry)), 'wa_compatible must be omitted when useSupports is true');
  assert.ok(entries.some((entry) => entry.supports === 'widely'), 'widely supported entries must be present');
  assert.ok(entries.some((entry) => entry.supports === 'newly'), 'newly supported entries must be present');

  const chrome1 = entries.find((entry) => entry.browser === 'chrome' && entry.version === '1');
  assert.ok(chrome1 && chrome1.supports === undefined, 'pre_baseline entry must not have supports set');

  const mapped = listAllVersions({ outputFormat: 'object', useSupports: true });
  assert.strictEqual('wa_compatible' in mapped.chrome['1'], false);
  assert.strictEqual('supports' in mapped.chrome['1'], false);

  const csv = listAllVersions({ outputFormat: 'csv', useSupports: true });
  const header = csv.trim().split('\n')[0];
  assert.strictEqual(
    header,
    '"browser","version","year","supports","release_date","engine","engine_version"'
  );
}

// 6. includeKaiOS: true without includeDownstreamBrowsers throws validation error
{
  assert.throws(
    () => {
      getAllVersions({
        includeKaiOS: true,
        includeDownstreamBrowsers: false,
        suppressWarnings: true,
      });
    },
    /KaiOS is a downstream browser and can only be included if you include other downstream browsers/
  );
}

console.log('PASS: baseline-browser-mapping@2.11.23 getAllVersions contract verified.');

Seeder de origen

anónimo