CodeSampleX

Beispiel

baseline-browser-mapping 2.11.13: getCompatibleVersions

Verifiziertes Beispiel für npm baseline-browser-mapping 2.11.13: getCompatibleVersions. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand.

sha256:45393b415731ab19da51cc0e3a6ccdbc6cefff54fccffdb369d65afb93ec1b0d

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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-17

Fall

HOW
Ziel
verify baseline-browser-mapping.getCompatibleVersions in pkg:npm/baseline-browser-mapping@2.11.13
Pakete
Symbole
  • baseline-browser-mapping.getCompatibleVersions
Umgebung
node 22.23.2
Erstellt
2026-09-17T12:38:47Z

Contract

  1. getCompatibleVersions returns minimum core browser versions supporting Baseline Widely available by default
  2. getCompatibleVersions returns browser versions meeting Baseline for a specific date or year
  3. getCompatibleVersions returns downstream browser versions when includeDownstreamBrowsers is enabled
  4. getCompatibleVersions returns all compatible versions when listAllCompatibleVersions is enabled
  5. getCompatibleVersions validates mutually exclusive and dependent configuration options

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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.13
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/baseline-browser-mapping@2.11.13
Demonstrate these symbols/APIs:
  - baseline-browser-mapping.getCompatibleVersions

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:4387519bf6f3e285479d878bfba25f6fb9d6d6e61647a6e24a326e8f96181043","contract":["getCompatibleVersions returns minimum core browser versions supporting Baseline Widely available by default","getCompatibleVersions returns browser versions meeting Baseline for a specific date or year","getCompatibleVersions returns downstream browser versions when includeDownstreamBrowsers is enabled","getCompatibleVersions returns all compatible versions when listAllCompatibleVersions is enabled","getCompatibleVersions validates mutually exclusive and dependent configuration options"],"goal":"verify baseline-browser-mapping.getCompatibleVersions in pkg:npm/baseline-browser-mapping@2.11.13","kind":"HOW","packages":["pkg:npm/baseline-browser-mapping@2.11.13"],"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.13"],"schemaVersion":1,"subject":"pkg:npm/baseline-browser-mapping@2.11.13","symbols":["baseline-browser-mapping.getCompatibleVersions"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "baseline-browser-mapping-sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "baseline-browser-mapping-sample",
      "version": "1.0.0",
      "dependencies": {
        "baseline-browser-mapping": "2.11.13"
      }
    },
    "node_modules/baseline-browser-mapping": {
      "version": "2.11.13",
      "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.13.tgz",
      "integrity": "sha512-k9HNuUVMlqVjQ9UHzfPjIqiDbWw7WqT1AoT7GL8VwvF3r0ZfArtgiSPAlmupyNquNgOJHTuH4CKYf8ttMTWBTQ==",
      "license": "Apache-2.0",
      "bin": {
        "baseline-browser-mapping": "dist/cli.cjs"
      },
      "engines": {
        "node": ">=6.0.0"
      }
    }
  }
}
package.json
{
  "name": "baseline-browser-mapping-sample",
  "version": "1.0.0",
  "dependencies": {
    "baseline-browser-mapping": "2.11.13"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify baseline-browser-mapping.getCompatibleVersions in pkg:npm/baseline-browser-mapping@2.11.13",
  "kind": "HOW",
  "packages": [
    "pkg:npm/baseline-browser-mapping@2.11.13"
  ],
  "symbols": [
    "baseline-browser-mapping.getCompatibleVersions"
  ]
}
src/index.js
const { getCompatibleVersions } = require('baseline-browser-mapping');

/**
 * Retrieves browser versions compatible with Baseline according to given options.
 *
 * @param {import('baseline-browser-mapping/dist/types.js').Options} [options]
 * @returns {import('baseline-browser-mapping/dist/types.js').BrowserVersion[]}
 */
function queryCompatibleVersions(options = {}) {
  return getCompatibleVersions(options);
}

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

// Contract 1: getCompatibleVersions returns minimum core browser versions supporting Baseline Widely available by default
{
  const versions = queryCompatibleVersions({ suppressWarnings: true });
  assert.ok(Array.isArray(versions), 'getCompatibleVersions should return an array');
  assert.ok(versions.length >= 4, 'should return at least core browsers');

  const coreBrowsers = ['chrome', 'edge', 'firefox', 'safari'];
  for (const browserName of coreBrowsers) {
    const entry = versions.find((b) => b.browser === browserName);
    assert.ok(entry, `browser ${browserName} should be present in results`);
    assert.strictEqual(typeof entry.version, 'string', `version for ${browserName} should be a string`);
    assert.strictEqual(typeof entry.release_date, 'string', `release_date for ${browserName} should be a string`);
  }

  // By default, should return minimum versions (1 per core browser)
  const browserCounts = {};
  for (const entry of versions) {
    browserCounts[entry.browser] = (browserCounts[entry.browser] || 0) + 1;
  }
  for (const browserName of coreBrowsers) {
    assert.strictEqual(browserCounts[browserName], 1, `browser ${browserName} should only have 1 minimum version`);
  }
}

// Contract 2: getCompatibleVersions returns browser versions meeting Baseline for a specific date or year
{
  // Date query
  const dateVersions = queryCompatibleVersions({
    widelyAvailableOnDate: '2023-01-01',
    suppressWarnings: true,
  });
  assert.ok(Array.isArray(dateVersions), 'date query should return an array');
  assert.ok(dateVersions.length >= 4, 'date query should return core browsers');
  const chromeDate = dateVersions.find((b) => b.browser === 'chrome');
  assert.ok(chromeDate, 'chrome should be present in date query');
  assert.strictEqual(typeof chromeDate.version, 'string');

  // Year query
  const yearVersions = queryCompatibleVersions({
    targetYear: 2022,
    suppressWarnings: true,
  });
  assert.ok(Array.isArray(yearVersions), 'year query should return an array');
  assert.ok(yearVersions.length >= 4, 'year query should return core browsers');
  const firefoxYear = yearVersions.find((b) => b.browser === 'firefox');
  assert.ok(firefoxYear, 'firefox should be present in year query');
  assert.strictEqual(typeof firefoxYear.version, 'string');
}

// Contract 3: getCompatibleVersions returns downstream browser versions when includeDownstreamBrowsers is enabled
{
  const coreVersions = queryCompatibleVersions({ suppressWarnings: true });
  const downstreamVersions = queryCompatibleVersions({
    includeDownstreamBrowsers: true,
    suppressWarnings: true,
  });

  assert.ok(Array.isArray(downstreamVersions), 'downstream query should return an array');
  assert.ok(
    downstreamVersions.length > coreVersions.length,
    'downstream query should return more browsers than core query'
  );

  const downstreamBrowsers = ['webview_android', 'samsunginternet_android', 'opera'];
  const hasAnyDownstream = downstreamVersions.some((b) => downstreamBrowsers.includes(b.browser));
  assert.ok(hasAnyDownstream, 'results should contain at least one downstream browser');
}

// Contract 4: getCompatibleVersions returns all compatible versions when listAllCompatibleVersions is enabled
{
  const minVersions = queryCompatibleVersions({ suppressWarnings: true });
  const allVersions = queryCompatibleVersions({
    listAllCompatibleVersions: true,
    suppressWarnings: true,
  });

  assert.ok(Array.isArray(allVersions), 'listAllCompatibleVersions should return an array');
  assert.ok(
    allVersions.length > minVersions.length * 2,
    'listAllCompatibleVersions should return significantly more versions than minimum set'
  );

  // Should have multiple entries for chrome
  const chromeEntries = allVersions.filter((b) => b.browser === 'chrome');
  assert.ok(chromeEntries.length > 1, 'should have multiple chrome entries when listAllCompatibleVersions is true');
}

// Contract 5: getCompatibleVersions validates mutually exclusive and dependent configuration options
{
  assert.throws(
    () => {
      getCompatibleVersions({
        widelyAvailableOnDate: '2023-01-01',
        targetYear: 2022,
        suppressWarnings: true,
      });
    },
    /You cannot use targetYear and widelyAvailableOnDate at the same time/,
    'Should throw error when both targetYear and widelyAvailableOnDate are specified'
  );

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

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

Ursprungs-Seeder

anonym