Ejemplo
baseline-browser-mapping 2.11.23: getCompatibleVersions
Muestra verificada para npm baseline-browser-mapping 2.11.23: getCompatibleVersions. El contrato se ejecutó en node 22 · linux debian/x64 · docker y pasó.
sha256:f47053e522f75c2555b21ff10586144655737ba5d26d07b6b13cef28e9ae7e86
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.getCompatibleVersions in pkg:npm/baseline-browser-mapping@2.11.23
- Paquetes
- Símbolos
-
- baseline-browser-mapping.getCompatibleVersions
- Entorno
- node 22.23.2
- Creado
- 2026-11-21T22:29:13Z
Contrato
- getCompatibleVersions returns the 7 core Baseline browsers in sorted order with valid versions and release dates by default
- getCompatibleVersions resolves exact minimum core browser versions for targetYear and matches the 30-month cutoff for widelyAvailableOnDate
- getCompatibleVersions includes downstream browsers with engine and engine_version when includeDownstreamBrowsers is true and adds kai_os only when includeKaiOS is also true
- getCompatibleVersions returns all ascending compatible versions per browser starting at the minimum version when listAllCompatibleVersions is true
- getCompatibleVersions returns sentinel version 0 for pre-Baseline years between 2002 and 2014
- getCompatibleVersions throws on mutually exclusive targetYear and widelyAvailableOnDate, includeKaiOS without includeDownstreamBrowsers, targetYear before 2002, and future targetYear
Archivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.js
Código fuente
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.getCompatibleVersions 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.getCompatibleVersions
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.
{"case":{"caseId":"case:sha256:6147a88f8a7ba92a7e93fdadb2bfb751efcd7a70e92b1e0cc44e398fcadb5139","constraints":{"executionContext":"node"},"contract":["getCompatibleVersions returns the 7 core Baseline browsers in sorted order with valid versions and release dates by default","getCompatibleVersions resolves exact minimum core browser versions for targetYear and matches the 30-month cutoff for widelyAvailableOnDate","getCompatibleVersions includes downstream browsers with engine and engine_version when includeDownstreamBrowsers is true and adds kai_os only when includeKaiOS is also true","getCompatibleVersions returns all ascending compatible versions per browser starting at the minimum version when listAllCompatibleVersions is true","getCompatibleVersions returns sentinel version 0 for pre-Baseline years between 2002 and 2014","getCompatibleVersions throws on mutually exclusive targetYear and widelyAvailableOnDate, includeKaiOS without includeDownstreamBrowsers, targetYear before 2002, and future targetYear"],"goal":"verify baseline-browser-mapping.getCompatibleVersions 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.getCompatibleVersions"]},"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.getCompatibleVersions"],"verifierAdapter":"node-typescript@1"}
{
"name": "baseline-browser-mapping-get-compatible-versions-sample",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "baseline-browser-mapping-get-compatible-versions-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"
}
}
}
}
{
"name": "baseline-browser-mapping-get-compatible-versions-sample",
"version": "1.0.0",
"private": true,
"scripts": {
"test": "node test/contract.js"
},
"dependencies": {
"baseline-browser-mapping": "2.11.23"
}
}
{
"schemaVersion": 1,
"goal": "verify baseline-browser-mapping.getCompatibleVersions in pkg:npm/baseline-browser-mapping@2.11.23",
"kind": "HOW",
"packages": [
"pkg:npm/baseline-browser-mapping@2.11.23"
],
"symbols": [
"baseline-browser-mapping.getCompatibleVersions"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
"use strict";
const { getCompatibleVersions } = require("baseline-browser-mapping");
function queryBaselineVersions(options = {}) {
return getCompatibleVersions(options);
}
function queryVersionsForYear(targetYear, extraOptions = {}) {
return getCompatibleVersions({
...extraOptions,
targetYear,
});
}
function queryVersionsForDate(widelyAvailableOnDate, extraOptions = {}) {
return getCompatibleVersions({
...extraOptions,
widelyAvailableOnDate,
});
}
module.exports = {
getCompatibleVersions,
queryBaselineVersions,
queryVersionsForYear,
queryVersionsForDate,
};
"use strict";
const assert = require("node:assert/strict");
const {
getCompatibleVersions,
queryBaselineVersions,
queryVersionsForYear,
queryVersionsForDate,
} = require("../src/index.js");
const CORE_BROWSERS = [
"chrome",
"chrome_android",
"edge",
"firefox",
"firefox_android",
"safari",
"safari_ios",
];
function parseVersion(version) {
const [major = 0, minor = 0] = version.split(".", 2).map(Number);
return [major, minor];
}
function compareVersion(a, b) {
const [aMaj, aMin] = parseVersion(a);
const [bMaj, bMin] = parseVersion(b);
if (aMaj !== bMaj) return aMaj - bMaj;
return aMin - bMin;
}
function indexByBrowser(entries) {
const map = new Map();
for (const entry of entries) {
map.set(entry.browser, entry);
}
return map;
}
// 1. Default behavior: minimum versions for the 7 core Baseline browsers
{
const defaults = queryBaselineVersions({ suppressWarnings: true });
assert.equal(defaults.length, CORE_BROWSERS.length);
assert.deepEqual(
defaults.map((entry) => entry.browser),
CORE_BROWSERS
);
for (const entry of defaults) {
assert.match(entry.version, /^\d+(?:\.\d+)?$/);
assert.match(entry.release_date, /^\d{4}-\d{2}-\d{2}$/);
assert.equal(entry.engine, undefined);
assert.equal(entry.engine_version, undefined);
}
}
// 2. Deterministic targetYear and widelyAvailableOnDate behavior
{
const baseline2023 = queryVersionsForYear(2023, { suppressWarnings: true });
assert.deepEqual(
baseline2023.map((entry) => [entry.browser, entry.version, entry.release_date]),
[
["chrome", "120", "2023-12-05"],
["chrome_android", "120", "2023-12-05"],
["edge", "120", "2023-12-07"],
["firefox", "121", "2023-12-19"],
["firefox_android", "121", "2023-12-19"],
["safari", "17.2", "2023-12-11"],
["safari_ios", "17.2", "2023-12-11"],
]
);
// Widely available subtracts 30 months from widelyAvailableOnDate:
// 2026-06-30 minus 30 months -> 2023-12-30 (after 2023-12-19, before 2023-12-31)
const widelyMid2026 = queryVersionsForDate("2026-06-30", { suppressWarnings: true });
assert.deepEqual(widelyMid2026, baseline2023);
// Earlier date produces older or equal minimum versions for every core browser
const baseline2020 = queryVersionsForYear(2020, { suppressWarnings: true });
const by2020 = indexByBrowser(baseline2020);
const by2023 = indexByBrowser(baseline2023);
for (const browser of CORE_BROWSERS) {
assert.ok(
compareVersion(by2020.get(browser).version, by2023.get(browser).version) < 0,
`Expected ${browser} 2020 version to be older than 2023 version`
);
}
}
// 3. Downstream browsers and optional KaiOS inclusion
{
const withDownstream = queryVersionsForYear(2023, {
includeDownstreamBrowsers: true,
suppressWarnings: true,
});
const downstreamBrowsers = withDownstream.filter(
(entry) => !CORE_BROWSERS.includes(entry.browser)
);
assert.ok(downstreamBrowsers.length >= 9);
assert.equal(
withDownstream.some((entry) => entry.browser === "kai_os"),
false
);
for (const entry of downstreamBrowsers) {
assert.equal(typeof entry.engine, "string");
assert.ok(entry.engine.length > 0);
assert.equal(typeof entry.engine_version, "string");
assert.ok(entry.engine_version.length > 0);
}
const byDownstream = indexByBrowser(withDownstream);
assert.equal(byDownstream.get("opera").version, "106");
assert.equal(byDownstream.get("opera").engine, "Blink");
assert.equal(byDownstream.get("webview_android").version, "120");
assert.equal(byDownstream.get("instagram_android").release_date, "unknown");
const withKaiOS = queryVersionsForYear(2023, {
includeDownstreamBrowsers: true,
includeKaiOS: true,
suppressWarnings: true,
});
assert.equal(withKaiOS.length, withDownstream.length + 1);
const kaiOS = withKaiOS.find((entry) => entry.browser === "kai_os");
assert.ok(kaiOS);
assert.equal(kaiOS.version, "4.0");
assert.equal(kaiOS.engine, "Gecko");
assert.equal(kaiOS.engine_version, "123");
}
// 4. Listing all compatible versions vs minimum-only mode
{
const minOnly = queryVersionsForYear(2024, { suppressWarnings: true });
const allCompatible = queryVersionsForYear(2024, {
listAllCompatibleVersions: true,
suppressWarnings: true,
});
assert.ok(allCompatible.length > minOnly.length);
for (const minEntry of minOnly) {
const matching = allCompatible.filter(
(entry) => entry.browser === minEntry.browser
);
assert.ok(matching.length > 1, `Expected multiple versions for ${minEntry.browser}`);
assert.equal(matching[0].version, minEntry.version);
for (let i = 1; i < matching.length; i += 1) {
assert.ok(
compareVersion(matching[i - 1].version, matching[i].version) < 0,
`Expected ascending versions for ${minEntry.browser}`
);
}
}
}
// 5. Pre-Baseline year returns sentinel version "0"
{
const preBaseline = queryVersionsForYear(2014, { suppressWarnings: true });
assert.equal(preBaseline.length, CORE_BROWSERS.length);
for (const entry of preBaseline) {
assert.equal(entry.version, "0");
assert.equal(entry.release_date, "");
}
}
// 6. Option validation errors
{
assert.throws(
() =>
getCompatibleVersions({
targetYear: 2023,
widelyAvailableOnDate: "2025-01-01",
}),
/cannot use targetYear and widelyAvailableOnDate at the same time/i
);
assert.throws(
() =>
getCompatibleVersions({
includeDownstreamBrowsers: false,
includeKaiOS: true,
}),
/KaiOS is a downstream browser/i
);
assert.throws(
() =>
getCompatibleVersions({
targetYear: 2001,
}),
/before 2002/i
);
const futureYear = new Date().getFullYear() + 5;
assert.throws(
() =>
getCompatibleVersions({
targetYear: futureYear,
}),
/in the future/i
);
}
console.log("baseline-browser-mapping.getCompatibleVersions contract passed");
Seeder de origen
anónimo