CodeSampleX

샘플

baseline-browser-mapping 2.11.12

검증된 샘플 — npm baseline-browser-mapping 2.11.12. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: getCompatibleVersions returns minimum browser…

sha256:84e322b59d7239c21cee9fae11198dbc0a0b790475f5e376558b3cc9d74e5faa

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

검증 실행 환경

환경 컨트랙트 단계 실행일
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

케이스

HOW
목표
verify pkg:npm/baseline-browser-mapping@2.11.12
패키지
환경
node 22.23.2
생성일
2026-08-26T14:51:28Z

컨트랙트

  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

파일

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

소스 아티팩트 내려받기 (tar.gz)

소스

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

오리진 시더

익명