CodeSampleX

샘플

regenerate 1.4.2: create regular expression character classes from code points and ranges with regenerate

검증된 샘플 — npm regenerate 1.4.2: create regular expression character classes from code points and ranges with regenerate. node 22 · linux alpine/x64 · docker에서…

sha256:e252dc0549d10fccbb994d6131997e90fc4c83c26c7c0f2c21880a6497451ce8

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

케이스

HOW
목표
create regular expression character classes from code points and ranges with regenerate
패키지
심벌
  • regenerate
  • regenerate.prototype.add
  • regenerate.prototype.addRange
  • regenerate.prototype.toRegExp
  • regenerate.prototype.toString
생성일
2026-08-27T20:47:08Z

컨트랙트

  1. regenerate initializes a set and accepts variable arguments of characters or code points
  2. regenerate.prototype.add adds code points, character strings, and numbers to the character set
  3. regenerate.prototype.addRange adds contiguous ranges of unicode code points
  4. regenerate.prototype.toString serializes the character set into an optimized regular expression character class pattern
  5. regenerate.prototype.toRegExp compiles the set into a RegExp instance with optional flags to match target strings

파일

  • PROMPT.md
  • csx.json
  • 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: create regular expression character classes from code points and ranges with regenerate
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/regenerate@1.4.2
Demonstrate these symbols/APIs:
  - regenerate
  - regenerate.prototype.add
  - regenerate.prototype.addRange
  - regenerate.prototype.toRegExp
  - regenerate.prototype.toString

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:1ea1cde88ae058444312dc227b02b90b580d48ee71f00b6887c2df062bb44655","contract":["regenerate initializes a set and accepts variable arguments of characters or code points","regenerate.prototype.add adds code points, character strings, and numbers to the character set","regenerate.prototype.addRange adds contiguous ranges of unicode code points","regenerate.prototype.toString serializes the character set into an optimized regular expression character class pattern","regenerate.prototype.toRegExp compiles the set into a RegExp instance with optional flags to match target strings"],"goal":"create regular expression character classes from code points and ranges with regenerate","kind":"HOW","packages":["pkg:npm/regenerate@1.4.2"],"schemaVersion":1,"symbols":["regenerate","regenerate.prototype.add","regenerate.prototype.addRange","regenerate.prototype.toRegExp","regenerate.prototype.toString"]},"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/regenerate@1.4.2"],"schemaVersion":1,"subject":"pkg:npm/regenerate@1.4.2","symbols":["regenerate","regenerate.prototype.add","regenerate.prototype.addRange","regenerate.prototype.toRegExp","regenerate.prototype.toString"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "regenerate-sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "regenerate-sample",
      "version": "1.0.0",
      "dependencies": {
        "regenerate": "1.4.2"
      }
    },
    "node_modules/regenerate": {
      "version": "1.4.2",
      "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz",
      "integrity": "sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "regenerate-sample",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "description": "Clean-room verification for regenerate",
  "dependencies": {
    "regenerate": "1.4.2"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "create regular expression character classes from code points and ranges with regenerate",
  "kind": "HOW",
  "packages": [
    "pkg:npm/regenerate@1.4.2"
  ],
  "symbols": [
    "regenerate",
    "regenerate.prototype.add",
    "regenerate.prototype.addRange",
    "regenerate.prototype.toRegExp",
    "regenerate.prototype.toString"
  ]
}
test/contract.mjs
import assert from 'node:assert';
import regenerate from 'regenerate';

// 1. regenerate initializes a set and accepts variable arguments of characters or code points
const set1 = regenerate(0x61, 'b');
assert.strictEqual(typeof set1.add, 'function');
assert.strictEqual(typeof set1.addRange, 'function');
assert.strictEqual(typeof set1.toString, 'function');
assert.strictEqual(typeof set1.toRegExp, 'function');
assert.strictEqual(set1.contains(0x61), true);
assert.strictEqual(set1.contains(0x62), true);
assert.strictEqual(set1.contains(0x63), false);

// 2. regenerate.prototype.add adds code points, character strings, and numbers to the character set
const set2 = regenerate().add('x', 0x79, 'z');
assert.strictEqual(set2.contains(0x78), true);
assert.strictEqual(set2.contains(0x79), true);
assert.strictEqual(set2.contains(0x7A), true);
assert.strictEqual(set2.contains(0x61), false);

// 3. regenerate.prototype.addRange adds contiguous ranges of unicode code points
const set3 = regenerate().addRange(0x30, 0x39).addRange(0x41, 0x46);
assert.strictEqual(set3.contains(0x30), true);
assert.strictEqual(set3.contains(0x35), true);
assert.strictEqual(set3.contains(0x39), true);
assert.strictEqual(set3.contains(0x41), true);
assert.strictEqual(set3.contains(0x46), true);
assert.strictEqual(set3.contains(0x47), false);

// 4. regenerate.prototype.toString serializes the character set into an optimized regular expression character class pattern
const set4 = regenerate().addRange(0x30, 0x39).add('a', 'b', 'c');
assert.strictEqual(set4.toString(), '[0-9a-c]');
const set4Solo = regenerate('a');
assert.strictEqual(set4Solo.toString(), 'a');

// 5. regenerate.prototype.toRegExp compiles the set into a RegExp instance with optional flags to match target strings
const set5 = regenerate().addRange(0x30, 0x39).add('a');
const re = set5.toRegExp('i');
assert.ok(re instanceof RegExp);
assert.strictEqual(re.flags, 'i');
assert.strictEqual(re.test('5'), true);
assert.strictEqual(re.test('a'), true);
assert.strictEqual(re.test('A'), true);
assert.strictEqual(re.test('z'), false);

console.log('Contract passed');

오리진 시더

익명