CodeSampleX

Ejemplo

baseline-browser-mapping 2.11.12

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

sha256:84e322b59d7239c21cee9fae11198dbc0a0b790475f5e376558b3cc9d74e5faa

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 alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5…
2026-08-26

Caso

HOW
Objetivo
verify pkg:npm/baseline-browser-mapping@2.11.12
Paquetes
Entorno
node 22.23.2
Creado
2026-08-26T14:51:28Z

Contrato

  1. getCompatibleVersions returns minimum browser versions supporting Baseline for a given date or year
  2. getAllVersions returns browser versions in array, object, and csv formats with baseline status
  3. getTimeline returns baseline event timelines grouped by date or browser
  4. getCompatibleVersions validates mutually exclusive targetYear and widelyAvailableOnDate options
  5. _resetHasWarned resets internal warning state for stale data checks

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 pkg:npm/baseline-browser-mapping@2.11.12
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/baseline-browser-mapping@2.11.12

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:f43e3421f13870b962ea703aa4f0d3df108995959276811374993b131f69df85","constraints":{"executionContext":"node"},"contract":["getCompatibleVersions returns minimum browser versions supporting Baseline for a given date or year","getAllVersions returns browser versions in array, object, and csv formats with baseline status","getTimeline returns baseline event timelines grouped by date or browser","getCompatibleVersions validates mutually exclusive targetYear and widelyAvailableOnDate options","_resetHasWarned resets internal warning state for stale data checks"],"goal":"verify pkg:npm/baseline-browser-mapping@2.11.12","kind":"HOW","packages":["pkg:npm/baseline-browser-mapping@2.11.12"],"schemaVersion":1},"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.12"],"schemaVersion":1,"subject":"pkg:npm/baseline-browser-mapping@2.11.12","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.12"
      }
    },
    "node_modules/baseline-browser-mapping": {
      "version": "2.11.12",
      "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.12.tgz",
      "integrity": "sha512-r7WnVImvVCeFpf2DOXfy41aPWzeNg3H/A2X4dKmy1QL0MSyyk/e7z8ihJ3N6Nn2PsdhkVlqnEfnUE4a05P2aTA==",
      "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.12"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/baseline-browser-mapping@2.11.12",
  "kind": "HOW",
  "packages": [
    "pkg:npm/baseline-browser-mapping@2.11.12"
  ]
}
src/index.js
const {
  getCompatibleVersions,
  getAllVersions,
  getTimeline,
  _resetHasWarned,
} = require('baseline-browser-mapping');

/**
 * Retrieves browser versions compatible with Baseline as of a target date or year.
 *
 * @param {object} [options]
 * @returns {Array<object>}
 */
function findCompatibleBrowsers(options = {}) {
  return getCompatibleVersions(options);
}

/**
 * Retrieves all browser versions with their Baseline availability status in specified format.
 *
 * @param {object} [options]
 * @returns {any}
 */
function fetchAllBrowserVersions(options = {}) {
  return getAllVersions(options);
}

/**
 * Retrieves the timeline of Baseline browser support changes.
 *
 * @param {object} [options]
 * @returns {any}
 */
function fetchBaselineTimeline(options = {}) {
  return getTimeline(options);
}

module.exports = {
  findCompatibleBrowsers,
  fetchAllBrowserVersions,
  fetchBaselineTimeline,
  getCompatibleVersions,
  getAllVersions,
  getTimeline,
  _resetHasWarned,
};
test/contract.js
const assert = require('node:assert/strict');
const {
  findCompatibleBrowsers,
  fetchAllBrowserVersions,
  fetchBaselineTimeline,
  getCompatibleVersions,
  _resetHasWarned,
} = require('../src/index.js');

// Contract 1: getCompatibleVersions returns minimum browser versions supporting Baseline for a given date or year
{
  const compatDate = findCompatibleBrowsers({
    widelyAvailableOnDate: '2023-01-01',
    suppressWarnings: true,
  });

  assert.ok(Array.isArray(compatDate), 'getCompatibleVersions should return an array');
  assert.ok(compatDate.length >= 4, 'should include core browsers');

  const chrome = compatDate.find((b) => b.browser === 'chrome');
  assert.ok(chrome, 'chrome entry should exist');
  assert.ok(typeof chrome.version === 'string', 'version should be a string');
  assert.ok(typeof chrome.release_date === 'string', 'release_date should be a string');

  const safari = compatDate.find((b) => b.browser === 'safari');
  assert.ok(safari, 'safari entry should exist');
  assert.ok(typeof safari.version === 'string', 'version should be a string');

  const compatYear = findCompatibleBrowsers({
    targetYear: 2022,
    suppressWarnings: true,
  });
  assert.ok(Array.isArray(compatYear), 'targetYear query should return an array');
  assert.ok(compatYear.some((b) => b.browser === 'firefox'), 'firefox entry should exist');
}

// Contract 2: getAllVersions returns browser versions in array, object, and csv formats with baseline status
{
  const list = fetchAllBrowserVersions({
    outputFormat: 'array',
    suppressWarnings: true,
  });
  assert.ok(Array.isArray(list), 'outputFormat array should return an array');
  assert.ok(list.length > 0, 'array should not be empty');
  assert.ok('browser' in list[0], 'items should contain browser');
  assert.ok('version' in list[0], 'items should contain version');
  assert.ok('year' in list[0], 'items should contain year');

  const obj = fetchAllBrowserVersions({
    outputFormat: 'object',
    suppressWarnings: true,
  });
  assert.strictEqual(typeof obj, 'object', 'outputFormat object should return an object');
  assert.ok(obj.chrome, 'nested chrome object should exist');
  assert.ok(typeof obj.chrome === 'object', 'chrome property should be an object');

  const csv = fetchAllBrowserVersions({
    outputFormat: 'csv',
    suppressWarnings: true,
  });
  assert.strictEqual(typeof csv, 'string', 'outputFormat csv should return a string');
  assert.ok(csv.includes('"browser","version"'), 'CSV should contain header');

  const listWithSupports = fetchAllBrowserVersions({
    outputFormat: 'array',
    useSupports: true,
    suppressWarnings: true,
  });
  assert.ok(Array.isArray(listWithSupports));
  const hasSupportsField = listWithSupports.some((item) => item.supports !== undefined);
  assert.ok(hasSupportsField, 'items should include supports property when useSupports is true');
}

// Contract 3: getTimeline returns baseline event timelines grouped by date or browser
{
  const timelineByDate = fetchBaselineTimeline({ groupBy: 'date' });
  assert.ok(Array.isArray(timelineByDate), 'timeline by date should return an array');
  assert.ok(timelineByDate.length > 0, 'timeline should have events');
  assert.ok(typeof timelineByDate[0].date === 'string', 'event should contain date');
  assert.ok(Array.isArray(timelineByDate[0].browsers), 'event should contain browsers array');

  const timelineByBrowser = fetchBaselineTimeline({ groupBy: 'browser' });
  assert.strictEqual(typeof timelineByBrowser, 'object', 'timeline by browser should return an object');
  assert.ok(Array.isArray(timelineByBrowser.chrome), 'chrome timeline should be an array');
  assert.ok(timelineByBrowser.chrome.length > 0, 'chrome timeline should not be empty');
  assert.ok(typeof timelineByBrowser.chrome[0].date === 'string', 'timeline entry should contain date');
  assert.ok(typeof timelineByBrowser.chrome[0].version === 'string', 'timeline entry should contain version');
}

// Contract 4: getCompatibleVersions validates mutually exclusive targetYear and widelyAvailableOnDate options
{
  assert.throws(
    () => {
      getCompatibleVersions({
        widelyAvailableOnDate: '2023-01-01',
        targetYear: 2022,
        suppressWarnings: true,
      });
    },
    /You cannot use targetYear and widelyAvailableOnDate at the same time/,
    'Should throw 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 when includeKaiOS is true without includeDownstreamBrowsers'
  );
}

// Contract 5: _resetHasWarned resets internal warning state for stale data checks
{
  assert.doesNotThrow(() => {
    _resetHasWarned();
  }, 'Should not throw when resetting hasWarned state');
}

console.log('All pkg:npm/baseline-browser-mapping@2.11.12 contracts passed successfully.');

Seeder de origen

anónimo