CodeSampleX

Beispiel

baseline-browser-mapping 2.11.12

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

sha256:84e322b59d7239c21cee9fae11198dbc0a0b790475f5e376558b3cc9d74e5faa

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

Fall

HOW
Ziel
verify pkg:npm/baseline-browser-mapping@2.11.12
Pakete
Umgebung
node 22.23.2
Erstellt
2026-08-26T14:51:28Z

Contract

  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

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

Ursprungs-Seeder

anonym