CodeSampleX

Exemple

baseline-browser-mapping 2.11.15

Échantillon vérifié pour npm baseline-browser-mapping 2.11.15. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi.

sha256:6f286e8f264b387345dfbac2d8558be86d2a416c5754571dab0d88acaaddd274

Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré. Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes. MIT-0

Preuves d'exécution

L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.

Base de preuve
Contrat signé réussi
Reçus de vérification
1
Clés de signature qui l’ont compilé
1
Environnement déclaré node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
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-28

Cas

HOW
Objectif
verify pkg:npm/baseline-browser-mapping@2.11.15
Paquets
Environnement
node 22.23.2
Créé
2026-08-28T06:11:29Z

Contrat

  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

Fichiers

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

Télécharger l’artefact source (tar.gz)

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

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

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:55d80a35c40ace82154f477c68e91cf2d794aea1ff4f78c3d85471656b4d21bf","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"],"goal":"verify pkg:npm/baseline-browser-mapping@2.11.15","kind":"HOW","packages":["pkg:npm/baseline-browser-mapping@2.11.15"],"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.15"],"schemaVersion":1,"subject":"pkg:npm/baseline-browser-mapping@2.11.15","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.15"
      }
    },
    "node_modules/baseline-browser-mapping": {
      "version": "2.11.15",
      "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.15.tgz",
      "integrity": "sha512-FwMjJJ7HnyZpWe+oWxegG0fezZyBZUagI5LZEoO3GCbtbKNwRfMH9Ue5d5v01PNePBy1QSfPSDTTeVL0Hb9EzA==",
      "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.15"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/baseline-browser-mapping@2.11.15",
  "kind": "HOW",
  "packages": [
    "pkg:npm/baseline-browser-mapping@2.11.15"
  ]
}
src/index.js
const {
  getCompatibleVersions,
  getAllVersions,
  getTimeline,
} = require('baseline-browser-mapping');

/**
 * Retrieves browser versions compatible with Baseline as of a target date or year.
 *
 * @param {import('baseline-browser-mapping/dist/types.js').Options} [options]
 * @returns {import('baseline-browser-mapping/dist/types.js').BrowserVersion[]}
 */
function findCompatibleBrowsers(options = {}) {
  return getCompatibleVersions(options);
}

/**
 * Retrieves all browser versions with their Baseline availability status in specified format.
 *
 * @param {import('baseline-browser-mapping/dist/types.js').AllVersionsOptions} [options]
 * @returns {any}
 */
function fetchAllBrowserVersions(options = {}) {
  return getAllVersions(options);
}

/**
 * Retrieves the timeline of Baseline browser support changes.
 *
 * @param {import('baseline-browser-mapping/dist/types.js').TimelineOptions} [options]
 * @returns {any}
 */
function fetchBaselineTimeline(options = {}) {
  return getTimeline(options);
}

module.exports = {
  findCompatibleBrowsers,
  fetchAllBrowserVersions,
  fetchBaselineTimeline,
  getCompatibleVersions,
  getAllVersions,
  getTimeline,
};
test/contract.js
const assert = require('node:assert/strict');
const {
  findCompatibleBrowsers,
  fetchAllBrowserVersions,
  fetchBaselineTimeline,
  getCompatibleVersions,
} = 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');

  // Verify targetYear option
  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
{
  // Array format
  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');

  // Object format
  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');

  // CSV format
  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');

  // useSupports option
  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
{
  // Grouped by date (default)
  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');

  // Grouped by browser
  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'
  );
}

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

Seeder d'origine

anonyme