CodeSampleX

Sample

baseline-browser-mapping 2.11.28: getCompatibleVersions

Verified sample for npm baseline-browser-mapping 2.11.28: getCompatibleVersions. The contract ran on node 22 · linux debian/x64 · docker and passed.

sha256:cdff977e12b11e2ecebb04f1d31a7e7f14e1aa535d8d506f86c68e550c81a5c6

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Verification-run environments

Environment Contract Stages Run
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-22

Case

HOW
Goal
verify baseline-browser-mapping.getCompatibleVersions in pkg:npm/baseline-browser-mapping@2.11.28
Packages
Symbols
  • baseline-browser-mapping.getCompatibleVersions
Environment
node 22.23.2
Created
2026-11-22T17:32:29Z

Contract

  1. getCompatibleVersions returns one minimum compatible version per core browser with version and ISO release_date by default
  2. getCompatibleVersions supports deterministic historical queries via targetYear and widelyAvailableOnDate
  3. getCompatibleVersions includes engine-mapped downstream browsers when includeDownstreamBrowsers is true and gates kai_os behind includeKaiOS
  4. getCompatibleVersions returns the minimum and all subsequent compatible versions when listAllCompatibleVersions is true
  5. getCompatibleVersions rejects conflicting targetYear and widelyAvailableOnDate options, includeKaiOS without includeDownstreamBrowsers, and out-of-range years

Files

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

Download the source artifact (tar.gz)

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

Use EXACTLY these public packages and versions:
  - pkg:npm/baseline-browser-mapping@2.11.28
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.
csx.json
{"case":{"caseId":"case:sha256:99edce53d42730c94b059ab4c5f0ba1f90be822fa30cc7fd4c96aabb8e896b0d","constraints":{"executionContext":"node"},"contract":["getCompatibleVersions returns one minimum compatible version per core browser with version and ISO release_date by default","getCompatibleVersions supports deterministic historical queries via targetYear and widelyAvailableOnDate","getCompatibleVersions includes engine-mapped downstream browsers when includeDownstreamBrowsers is true and gates kai_os behind includeKaiOS","getCompatibleVersions returns the minimum and all subsequent compatible versions when listAllCompatibleVersions is true","getCompatibleVersions rejects conflicting targetYear and widelyAvailableOnDate options, includeKaiOS without includeDownstreamBrowsers, and out-of-range years"],"goal":"verify baseline-browser-mapping.getCompatibleVersions in pkg:npm/baseline-browser-mapping@2.11.28","kind":"HOW","packages":["pkg:npm/baseline-browser-mapping@2.11.28"],"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.28"],"schemaVersion":1,"subject":"pkg:npm/baseline-browser-mapping@2.11.28","symbols":["baseline-browser-mapping.getCompatibleVersions"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "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.28"
      }
    },
    "node_modules/baseline-browser-mapping": {
      "version": "2.11.28",
      "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.28.tgz",
      "integrity": "sha512-br0LOmjJqr6Rt4AEkadbcNf67Zpo7EPwKsWbjnRrJIa1QYFHQBqM4C7F2WTbV8ahTEcg1Eo+Y0aWjjORInYFyA==",
      "license": "Apache-2.0",
      "bin": {
        "baseline-browser-mapping": "dist/cli.cjs"
      },
      "engines": {
        "node": ">=6.0.0"
      }
    }
  }
}
package.json
{
  "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.28"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify baseline-browser-mapping.getCompatibleVersions in pkg:npm/baseline-browser-mapping@2.11.28",
  "kind": "HOW",
  "packages": [
    "pkg:npm/baseline-browser-mapping@2.11.28"
  ],
  "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"
  }
}
src/index.js
'use strict';

const { getCompatibleVersions } = require('baseline-browser-mapping');

function getCoreBaselineMinimums(options = {}) {
  return getCompatibleVersions({
    suppressWarnings: true,
    ...options,
  });
}

function getDownstreamBaselineVersions(options = {}) {
  return getCompatibleVersions({
    includeDownstreamBrowsers: true,
    suppressWarnings: true,
    ...options,
  });
}

module.exports = {
  getCompatibleVersions,
  getCoreBaselineMinimums,
  getDownstreamBaselineVersions,
};
test/contract.js
'use strict';

const assert = require('node:assert/strict');
const {
  getCompatibleVersions,
  getCoreBaselineMinimums,
  getDownstreamBaselineVersions,
} = require('../src/index.js');

const CORE_BROWSERS = [
  'chrome',
  'chrome_android',
  'edge',
  'firefox',
  'firefox_android',
  'safari',
  'safari_ios',
];

// 1. Default call returns one minimum compatible version per core browser with version and release_date
{
  const versions = getCoreBaselineMinimums();
  assert.ok(Array.isArray(versions), 'expected an array of browser versions');
  assert.strictEqual(versions.length, CORE_BROWSERS.length, 'expected exactly the 7 core browsers');

  const seen = new Set();
  for (const entry of versions) {
    assert.strictEqual(typeof entry.browser, 'string');
    assert.strictEqual(typeof entry.version, 'string');
    assert.ok(entry.version.length > 0, `expected non-empty version for ${entry.browser}`);
    assert.match(entry.release_date, /^\d{4}-\d{2}-\d{2}$/, `expected ISO date for ${entry.browser}`);
    assert.ok(!seen.has(entry.browser), `duplicate core browser ${entry.browser}`);
    seen.add(entry.browser);
  }
  for (const browser of CORE_BROWSERS) {
    assert.ok(seen.has(browser), `missing core browser ${browser}`);
  }
}

// 2. targetYear and widelyAvailableOnDate return deterministic historical compatibility minimums
{
  const year2020 = getCoreBaselineMinimums({ targetYear: 2020 });
  const byBrowser2020 = Object.fromEntries(year2020.map((entry) => [entry.browser, entry]));
  assert.strictEqual(byBrowser2020.chrome.version, '87');
  assert.strictEqual(byBrowser2020.edge.version, '87');
  assert.strictEqual(byBrowser2020.firefox.version, '83');
  assert.strictEqual(byBrowser2020.safari.version, '14');

  const onDate = getCoreBaselineMinimums({ widelyAvailableOnDate: '2023-06-01' });
  assert.strictEqual(onDate.length, CORE_BROWSERS.length);
  const byBrowserDate = Object.fromEntries(onDate.map((entry) => [entry.browser, entry]));
  assert.strictEqual(byBrowserDate.chrome.version, '87');
  assert.strictEqual(byBrowserDate.firefox.version, '83');
  assert.strictEqual(byBrowserDate.safari.version, '14');

  const laterDate = getCoreBaselineMinimums({ widelyAvailableOnDate: '2025-03-07' });
  const byBrowserLater = Object.fromEntries(laterDate.map((entry) => [entry.browser, entry]));
  assert.ok(
    Number.parseFloat(byBrowserLater.chrome.version) > Number.parseFloat(byBrowserDate.chrome.version),
    'later widelyAvailableOnDate should require a newer Chrome minimum'
  );
}

// 3. includeDownstreamBrowsers adds engine-mapped downstream browsers and respects includeKaiOS
{
  const downstream = getDownstreamBaselineVersions({ targetYear: 2020 });
  assert.ok(downstream.length > CORE_BROWSERS.length, 'expected downstream browsers beyond core set');

  const nonCore = downstream.filter((entry) => !CORE_BROWSERS.includes(entry.browser));
  assert.ok(nonCore.length > 0, 'expected non-core browser entries');
  for (const entry of nonCore) {
    assert.ok(
      entry.engine === 'Blink' || entry.engine === 'Gecko',
      `unexpected downstream engine for ${entry.browser}: ${entry.engine}`
    );
    assert.strictEqual(typeof entry.engine_version, 'string');
    assert.ok(entry.engine_version.length > 0);
  }

  assert.ok(
    !downstream.some((entry) => entry.browser === 'kai_os'),
    'kai_os should be excluded unless includeKaiOS is true'
  );

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

// 4. listAllCompatibleVersions returns minimum and all subsequent compatible versions per browser
{
  const minimums = getCoreBaselineMinimums({ targetYear: 2023 });
  const allCompatible = getCoreBaselineMinimums({
    targetYear: 2023,
    listAllCompatibleVersions: true,
  });

  assert.ok(allCompatible.length > minimums.length * 2, 'expected many versions per browser');
  for (const minEntry of minimums) {
    const matching = allCompatible.filter((entry) => entry.browser === minEntry.browser);
    assert.ok(matching.length > 1, `expected multiple versions for ${minEntry.browser}`);
    assert.ok(
      matching.some((entry) => entry.version === minEntry.version),
      `expected minimum version ${minEntry.version} for ${minEntry.browser} in full list`
    );
  }
}

// 5. Invalid option combinations and out-of-range dates throw errors
{
  assert.throws(
    () =>
      getCompatibleVersions({
        targetYear: 2022,
        widelyAvailableOnDate: '2024-01-01',
        suppressWarnings: true,
      }),
    /You cannot use targetYear and widelyAvailableOnDate at the same time/
  );

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

  assert.throws(
    () =>
      getCompatibleVersions({
        targetYear: 2001,
      }),
    /None of the browsers in the core set were released before 2002/
  );

  assert.throws(
    () =>
      getCompatibleVersions({
        targetYear: new Date().getFullYear() + 5,
      }),
    /There are no browser versions compatible with Baseline in the future/
  );
}

console.log('baseline-browser-mapping.getCompatibleVersions contract passed');

Origin Seeder

anonymous