CodeSampleX

Ejemplo

baseline-browser-mapping 2.11.13: getCompatibleVersions

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

sha256:45393b415731ab19da51cc0e3a6ccdbc6cefff54fccffdb369d65afb93ec1b0d

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-09-17

Caso

HOW
Objetivo
verify baseline-browser-mapping.getCompatibleVersions in pkg:npm/baseline-browser-mapping@2.11.13
Paquetes
Símbolos
  • baseline-browser-mapping.getCompatibleVersions
Entorno
node 22.23.2
Creado
2026-09-17T12:38:47Z

Contrato

  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

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.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.');

Seeder de origen

anónimo