CodeSampleX

サンプル

browserslist 4.28.9: browserslist

検証済みサンプル — npm browserslist 4.28.9: browserslist. node 22 · linux debian/x64 · docker で contract を実行し、成功しました: browserslist() with undefined or no argument…

sha256:4b8f9bc8fbbc7444fae88b8044bbd21b4707714af41da9edff5d0fe600e39541

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
1
ビルドした署名鍵
1
宣言された環境 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

検証実行環境

環境 コントラクト ステージ 実行日
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-05

ケース

HOW
ゴール
verify pkg:npm/browserslist@4.28.9
パッケージ
シンボル
  • browserslist
環境
node 22.23.2
作成日
2026-09-05T03:22:22Z

コントラクト

  1. browserslist() with undefined or no argument resolves default queries from browserslist.defaults
  2. browserslist([]) with empty query array returns an empty target list
  3. browserslist('chrome >= 100 and chrome <= 102') resolves ranged versions joined by boolean and
  4. browserslist(['firefox 120', 'safari 17']) resolves an array of specific browser versions
  5. browserslist(['chrome >= 100 and chrome <= 102', 'not chrome 101']) subtracts negated versions from preceding queries
  6. browserslist('node 20.0.0') resolves exact Node.js release targets
  7. browserslist('chrome 999') throws BrowserslistError on unknown browser version
  8. browserslist('chrome 999', { ignoreUnknownVersions: true }) returns an empty array without throwing
  9. browserslist(['not chrome 100']) throws BrowserslistError when query list starts with negation without preceding base
  10. browserslist(123) throws BrowserslistError when argument is neither string nor array

ファイル

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

ソースアーティファクトをダウンロード (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/browserslist@4.28.9
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/browserslist@4.28.9
Demonstrate these symbols/APIs:
  - browserslist

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:0306116c0dce39b386092a352f35deac3f3cc3e3e94635eb063fa4b37b728906","constraints":{"executionContext":"node"},"contract":["browserslist() with undefined or no argument resolves default queries from browserslist.defaults","browserslist([]) with empty query array returns an empty target list","browserslist('chrome \u003e= 100 and chrome \u003c= 102') resolves ranged versions joined by boolean and","browserslist(['firefox 120', 'safari 17']) resolves an array of specific browser versions","browserslist(['chrome \u003e= 100 and chrome \u003c= 102', 'not chrome 101']) subtracts negated versions from preceding queries","browserslist('node 20.0.0') resolves exact Node.js release targets","browserslist('chrome 999') throws BrowserslistError on unknown browser version","browserslist('chrome 999', { ignoreUnknownVersions: true }) returns an empty array without throwing","browserslist(['not chrome 100']) throws BrowserslistError when query list starts with negation without preceding base","browserslist(123) throws BrowserslistError when argument is neither string nor array"],"goal":"verify pkg:npm/browserslist@4.28.9","kind":"HOW","packages":["pkg:npm/browserslist@4.28.9"],"schemaVersion":1,"symbols":["browserslist"]},"contractCommand":["node","test/contract.mjs"],"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/browserslist@4.28.9"],"schemaVersion":1,"subject":"pkg:npm/browserslist@4.28.9","symbols":["browserslist"],"verifierAdapter":"node-typescript@1"}
index.js
const browserslist = require('browserslist');

/**
 * Resolves browser target queries against Can I Use usage and version data.
 *
 * @param {string | string[]} [queries] - Queries or array of queries.
 * @param {object} [opts] - Optional configuration options.
 * @returns {string[]} Resolved target browser versions.
 */
function resolveBrowsers(queries, opts) {
  return browserslist(queries, opts);
}

module.exports = {
  browserslist,
  resolveBrowsers,
};
package-lock.json
{
  "name": "sample-browserslist-query",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-browserslist-query",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "browserslist": "4.28.9"
      }
    },
    "node_modules/baseline-browser-mapping": {
      "version": "2.11.21",
      "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.21.tgz",
      "integrity": "sha512-uh8vpY/1/YyFkunIDFH/12p7/7VdPKA1hejMVEbdkEaWnUz0Hesvx5EbiU6XxjyHZIOju+ZMbQJkRh+es3/spQ==",
      "license": "Apache-2.0",
      "bin": {
        "baseline-browser-mapping": "dist/cli.cjs"
      },
      "engines": {
        "node": ">=6.0.0"
      }
    },
    "node_modules/browserslist": {
      "version": "4.28.9",
      "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.9.tgz",
      "integrity": "sha512-EWazOblFYUvlGZcfGhPUPmYh3nikUxBVb+y9MJun5f3hBi812X+8MSQTujLBtgK3cf51fJWbWfOjyeO954d+Eg==",
      "funding": [
        {
          "type": "opencollective",
          "url": "https://opencollective.com/browserslist"
        },
        {
          "type": "tidelift",
          "url": "https://tidelift.com/funding/github/npm/browserslist"
        },
        {
          "type": "github",
          "url": "https://github.com/sponsors/ai"
        }
      ],
      "license": "MIT",
      "dependencies": {
        "baseline-browser-mapping": "^2.11.20",
        "caniuse-lite": "^1.0.30001810",
        "electron-to-chromium": "^1.5.420",
        "node-releases": "^2.0.54",
        "update-browserslist-db": "^1.3.2"
      },
      "bin": {
        "browserslist": "cli.js"
      },
      "engines": {
        "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"
      }
    },
    "node_modules/caniuse-lite": {
      "version": "1.0.30001810",
      "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001810.tgz",
      "integrity": "sha512-TITQPUkaz+aVk5GL6NhOdwk1aEaNTSDPsGFWrTuhKGtjTF70jL/Oht2W4c6rXUe5fu7Ie19VIahAXHIIiWWNeg==",
      "funding": [
        {
          "type": "opencollective",
          "url": "https://opencollective.com/browserslist"
        },
        {
          "type": "tidelift",
          "url": "https://tidelift.com/funding/github/npm/caniuse-lite"
        },
        {
          "type": "github",
          "url": "https://github.com/sponsors/ai"
        }
      ],
      "license": "CC-BY-4.0"
    },
    "node_modules/electron-to-chromium": {
      "version": "1.5.422",
      "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.422.tgz",
      "integrity": "sha512-UvA/32XqrLDdZSn7Jllo1AYNcWji/G0d5M0GTViE7KoGBiMunw3a34Sb2KO4ZZyrSEhqsxFoVhWWJshdyfKqJA==",
      "license": "ISC"
    },
    "node_modules/escalade": {
      "version": "3.2.0",
      "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
      "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
      "license": "MIT",
      "engines": {
        "node": ">=6"
      }
    },
    "node_modules/node-releases": {
      "version": "2.0.54",
      "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.54.tgz",
      "integrity": "sha512-YHs7BmmcsdAI5Ozuf8JZo6PT0mv2GIWC9vMfvUC3dp65M8hn7Ux8CPL+2oBI7juNuj9d0ndhTcznq2ODBps9cQ==",
      "license": "MIT",
      "engines": {
        "node": ">=18"
      }
    },
    "node_modules/picocolors": {
      "version": "1.1.1",
      "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
      "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
      "license": "ISC"
    },
    "node_modules/update-browserslist-db": {
      "version": "1.3.2",
      "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.2.tgz",
      "integrity": "sha512-UQ+MSxlhRm1bzjhU+DcuXfjFO1FzNtqhK5+9Yvlp90ItDLk5vT932A0rFu619nf7RVS+Y/VeaUW1jaRDqZ8VJw==",
      "funding": [
        {
          "type": "opencollective",
          "url": "https://opencollective.com/browserslist"
        },
        {
          "type": "tidelift",
          "url": "https://tidelift.com/funding/github/npm/browserslist"
        },
        {
          "type": "github",
          "url": "https://github.com/sponsors/ai"
        }
      ],
      "license": "MIT",
      "dependencies": {
        "escalade": "^3.2.0",
        "picocolors": "^1.1.1"
      },
      "bin": {
        "update-browserslist-db": "cli.js"
      },
      "peerDependencies": {
        "browserslist": ">= 4.21.0"
      }
    }
  }
}
package.json
{
  "name": "sample-browserslist-query",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room sample verifying browserslist target resolution queries",
  "main": "index.js",
  "license": "MIT-0",
  "dependencies": {
    "browserslist": "4.28.9"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/browserslist@4.28.9",
  "kind": "HOW",
  "packages": [
    "pkg:npm/browserslist@4.28.9"
  ],
  "symbols": [
    "browserslist"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import browserslist from 'browserslist';
import { resolveBrowsers } from '../index.js';

// 1. browserslist() with undefined or no argument resolves default queries from browserslist.defaults
const defaults = browserslist();
assert.ok(Array.isArray(defaults) && defaults.length > 0);
assert.deepStrictEqual(browserslist(undefined), defaults);
assert.deepStrictEqual(resolveBrowsers(), defaults);

// 2. browserslist([]) with empty query array returns an empty target list
assert.deepStrictEqual(browserslist([]), []);
assert.deepStrictEqual(resolveBrowsers([]), []);

// 3. browserslist('chrome >= 100 and chrome <= 102') resolves ranged versions joined by boolean and
assert.deepStrictEqual(
  browserslist('chrome >= 100 and chrome <= 102'),
  ['chrome 102', 'chrome 101', 'chrome 100']
);
assert.deepStrictEqual(
  resolveBrowsers('chrome >= 100 and chrome <= 102'),
  ['chrome 102', 'chrome 101', 'chrome 100']
);

// 4. browserslist(['firefox 120', 'safari 17']) resolves an array of specific browser versions
assert.deepStrictEqual(
  browserslist(['firefox 120', 'safari 17']),
  ['firefox 120', 'safari 17.0']
);
assert.deepStrictEqual(
  resolveBrowsers(['firefox 120', 'safari 17']),
  ['firefox 120', 'safari 17.0']
);

// 5. browserslist(['chrome >= 100 and chrome <= 102', 'not chrome 101']) subtracts negated versions from preceding queries
assert.deepStrictEqual(
  browserslist(['chrome >= 100 and chrome <= 102', 'not chrome 101']),
  ['chrome 102', 'chrome 100']
);

// 6. browserslist('node 20.0.0') resolves exact Node.js release targets
assert.deepStrictEqual(browserslist('node 20.0.0'), ['node 20.0.0']);

// 7. browserslist('chrome 999') throws BrowserslistError on unknown browser version
assert.throws(
  () => browserslist('chrome 999'),
  (err) => err.name === 'BrowserslistError' && err.message.includes('Unknown version 999 of chrome')
);

// 8. browserslist('chrome 999', { ignoreUnknownVersions: true }) returns an empty array without throwing
assert.deepStrictEqual(
  browserslist('chrome 999', { ignoreUnknownVersions: true }),
  []
);

// 9. browserslist(['not chrome 100']) throws BrowserslistError when query list starts with negation without preceding base
assert.throws(
  () => browserslist(['not chrome 100']),
  (err) => err.name === 'BrowserslistError' && err.message.includes('Write any browsers query')
);

// 10. browserslist(123) throws BrowserslistError when argument is neither string nor array
assert.throws(
  () => browserslist(123),
  (err) => err.name === 'BrowserslistError' && err.message.includes('Browser queries must be an array or string. Got number.')
);

console.log('Contract passed successfully.');

オリジンシーダー

匿名