CodeSampleX

示例

@isaacs/brace-expansion 5.0.1: braceExpansion

已验证示例 — npm @isaacs/brace-expansion 5.0.1: braceExpansion. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: braceExpansion exports expand function and…

sha256:c7f3de081e8509871a5884bad904ad31d5323fbb5b1d63f6a93170b9e1ec970b

本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。 提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。 MIT-0

执行证据

声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。

证据依据
签名契约通过
验证回执
1
构建过它的签名密钥
1
声明的环境 linux 24 · ubuntu · glibc 2.39 x64 npm

验证运行环境

环境 契约 阶段 运行日期
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-30

案例

HOW
目标
verify braceExpansion in pkg:npm/%40isaacs/brace-expansion@5.0.1
符号
  • braceExpansion
创建时间
2026-08-30T22:28:05Z

契约

  1. braceExpansion exports expand function and EXPANSION_MAX limit constant
  2. braceExpansion expands comma-separated alternatives and adjacent Cartesian product sets
  3. braceExpansion expands ascending, descending, stepped and zero-padded numeric ranges
  4. braceExpansion expands alphabetical sequences and resolves nested brace expressions
  5. braceExpansion preserves escaped braces and enforces custom max expansion limits

文件

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • 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 braceExpansion in pkg:npm/%40isaacs/brace-expansion@5.0.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40isaacs/brace-expansion@5.0.1
Demonstrate these symbols/APIs:
  - braceExpansion

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:a291d8883481c8a4760dc21773f6b79cb15283adfafed1d96497bc7802245610","contract":["braceExpansion exports expand function and EXPANSION_MAX limit constant","braceExpansion expands comma-separated alternatives and adjacent Cartesian product sets","braceExpansion expands ascending, descending, stepped and zero-padded numeric ranges","braceExpansion expands alphabetical sequences and resolves nested brace expressions","braceExpansion preserves escaped braces and enforces custom max expansion limits"],"goal":"verify braceExpansion in pkg:npm/%40isaacs/brace-expansion@5.0.1","kind":"HOW","packages":["pkg:npm/%40isaacs/brace-expansion@5.0.1"],"schemaVersion":1,"symbols":["braceExpansion"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40isaacs/brace-expansion@5.0.1"],"schemaVersion":1,"subject":"pkg:npm/%40isaacs/brace-expansion@5.0.1","symbols":["braceExpansion"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-brace-expansion-verify",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-brace-expansion-verify",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@isaacs/brace-expansion": "5.0.1"
      }
    },
    "node_modules/@isaacs/balanced-match": {
      "version": "4.0.1",
      "resolved": "https://registry.npmjs.org/@isaacs/balanced-match/-/balanced-match-4.0.1.tgz",
      "integrity": "sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==",
      "license": "MIT",
      "engines": {
        "node": "20 || >=22"
      }
    },
    "node_modules/@isaacs/brace-expansion": {
      "version": "5.0.1",
      "resolved": "https://registry.npmjs.org/@isaacs/brace-expansion/-/brace-expansion-5.0.1.tgz",
      "integrity": "sha512-WMz71T1JS624nWj2n2fnYAuPovhv7EUhk69R6i9dsVyzxt5eM3bjwvgk9L+APE1TRscGysAVMANkB0jh0LQZrQ==",
      "license": "MIT",
      "dependencies": {
        "@isaacs/balanced-match": "^4.0.1"
      },
      "engines": {
        "node": "20 || >=22"
      }
    }
  }
}
package.json
{
  "name": "sample-brace-expansion-verify",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of braceExpansion in @isaacs/brace-expansion@5.0.1",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "@isaacs/brace-expansion": "5.0.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify braceExpansion in pkg:npm/%40isaacs/brace-expansion@5.0.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40isaacs/brace-expansion@5.0.1"
  ],
  "symbols": [
    "braceExpansion"
  ]
}
src/index.js
const braceExpansion = require('@isaacs/brace-expansion');

/**
 * Expand a brace pattern string using @isaacs/brace-expansion.
 *
 * @param {string} pattern - Brace pattern to expand
 * @param {object} [options] - Expansion options (e.g. { max: number })
 * @returns {string[]} Array of expanded strings
 */
function expandBracePattern(pattern, options) {
  return braceExpansion.expand(pattern, options);
}

/**
 * Get the maximum expansion limit from the module.
 *
 * @returns {number} Default expansion maximum (100000)
 */
function getMaxExpansions() {
  return braceExpansion.EXPANSION_MAX;
}

module.exports = {
  braceExpansion,
  expand: braceExpansion.expand,
  EXPANSION_MAX: braceExpansion.EXPANSION_MAX,
  expandBracePattern,
  getMaxExpansions,
};
test/contract.mjs
import assert from 'node:assert';
import { createRequire } from 'node:module';
import * as braceExpansionModule from '@isaacs/brace-expansion';

const require = createRequire(import.meta.url);
const {
  braceExpansion,
  expand,
  EXPANSION_MAX,
  expandBracePattern,
  getMaxExpansions
} = require('../src/index.js');

// 1. Module namespace and exports
assert.strictEqual(typeof braceExpansion, 'object', 'braceExpansion module namespace is an object in CommonJS');
assert.strictEqual(typeof braceExpansion.expand, 'function', 'braceExpansion.expand is a function');
assert.strictEqual(typeof braceExpansion.EXPANSION_MAX, 'number', 'braceExpansion.EXPANSION_MAX is a number');
assert.strictEqual(braceExpansion.EXPANSION_MAX, 100000, 'braceExpansion.EXPANSION_MAX equals 100000');
assert.strictEqual(typeof braceExpansionModule.expand, 'function', 'ESM export expand is a function');
assert.strictEqual(braceExpansionModule.EXPANSION_MAX, 100000, 'ESM export EXPANSION_MAX equals 100000');
assert.strictEqual(getMaxExpansions(), 100000, 'getMaxExpansions returns default EXPANSION_MAX limit');

// 2. Empty string returns empty array
assert.deepStrictEqual(braceExpansion.expand(''), [], 'expand returns empty array for empty string input');
assert.deepStrictEqual(expandBracePattern(''), [], 'expandBracePattern returns empty array for empty string input');

// 3. Comma-separated alternatives expansion
const commaResult = braceExpansion.expand('file.{jpg,png,gif}');
assert.deepStrictEqual(
  commaResult,
  ['file.jpg', 'file.png', 'file.gif'],
  'braceExpansion expands comma-separated alternatives within curly braces'
);

const helperComma = expandBracePattern('pref_{x,y}_suff');
assert.deepStrictEqual(
  helperComma,
  ['pref_x_suff', 'pref_y_suff'],
  'expandBracePattern expands comma alternatives'
);

// 4. Numeric and alphabetical ranges (including step, reverse, and padding)
const numForward = braceExpansion.expand('{1..4}');
assert.deepStrictEqual(numForward, ['1', '2', '3', '4'], 'expands ascending numeric range');

const numReverse = braceExpansion.expand('{3..1}');
assert.deepStrictEqual(numReverse, ['3', '2', '1'], 'expands descending numeric range');

const numStep = braceExpansion.expand('{0..6..2}');
assert.deepStrictEqual(numStep, ['0', '2', '4', '6'], 'expands stepped numeric range');

const numPadded = braceExpansion.expand('{01..03}');
assert.deepStrictEqual(numPadded, ['01', '02', '03'], 'preserves zero-padded numeric range');

const alphaForward = braceExpansion.expand('{a..c}');
assert.deepStrictEqual(alphaForward, ['a', 'b', 'c'], 'expands ascending alphabetical range');

const alphaReverse = braceExpansion.expand('{c..a}');
assert.deepStrictEqual(alphaReverse, ['c', 'b', 'a'], 'expands descending alphabetical range');

// 5. Nested braces and Cartesian products
const nestedResult = braceExpansion.expand('a{b,c{1,2}}d');
assert.deepStrictEqual(nestedResult, ['abd', 'ac1d', 'ac2d'], 'expands nested brace patterns');

const cartesianResult = braceExpansion.expand('{a,b}{1,2}');
assert.deepStrictEqual(cartesianResult, ['a1', 'a2', 'b1', 'b2'], 'computes Cartesian product of adjacent brace sets');

// 6. Escaped braces and literal strings
const escapedResult = braceExpansion.expand('prefix\\{a,b\\}suffix');
assert.deepStrictEqual(escapedResult, ['prefix{a,b}suffix'], 'preserves escaped braces as literals');

const literalResult = braceExpansion.expand('literal-string');
assert.deepStrictEqual(literalResult, ['literal-string'], 'returns non-brace strings unmodified in array');

// 7. Max expansion limit option
const maxLimited = braceExpansion.expand('{1..100}', { max: 3 });
assert.deepStrictEqual(maxLimited, ['1', '2', '3'], 'respects max option to limit number of expanded items');

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

原始种子者

匿名