샘플
regexpu-core 6.4.0: default
검증된 샘플 — npm regexpu-core 6.4.0: default. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: rewritePattern default export is a function capable of…
sha256:5f8309de9d219889535c87ffa2d17d0d1b2a49a847c358286f4763202e3ed97e
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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 regexpu-core.default in pkg:npm/regexpu-core@6.4.0
- 심벌
-
- regexpu-core.default
- 환경
- node 22.23.2
- 생성일
- 2026-09-05T21:48:26Z
컨트랙트
- rewritePattern default export is a function capable of transpiling regex patterns
- rewritePattern transforms dotAll flag into character class matching any character including newline
- rewritePattern transforms named capture groups and records group names with onNamedGroup callback
- rewritePattern transforms unicode property escapes into character ranges
- rewritePattern transforms unicode code point escapes to UTF-16 surrogate pairs
- rewritePattern transforms unicode sets difference operations under v flag into simplified character class
- rewritePattern transforms inline case-insensitive regex modifiers into case-folded character alternatives
- transpileRegExp compiles rewritten pattern into an executable RegExp instance
파일
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- test/contract.mjs
소스
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 regexpu-core.default in pkg:npm/regexpu-core@6.4.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/regexpu-core@6.4.0
Demonstrate these symbols/APIs:
- regexpu-core.default
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.
{"case":{"caseId":"case:sha256:4ad393e5955a17abdc4079d684013cc42e0f0271607f26ffbb6ac846da5b5d92","contract":["rewritePattern default export is a function capable of transpiling regex patterns","rewritePattern transforms dotAll flag into character class matching any character including newline","rewritePattern transforms named capture groups and records group names with onNamedGroup callback","rewritePattern transforms unicode property escapes into character ranges","rewritePattern transforms unicode code point escapes to UTF-16 surrogate pairs","rewritePattern transforms unicode sets difference operations under v flag into simplified character class","rewritePattern transforms inline case-insensitive regex modifiers into case-folded character alternatives","transpileRegExp compiles rewritten pattern into an executable RegExp instance"],"goal":"verify regexpu-core.default in pkg:npm/regexpu-core@6.4.0","kind":"HOW","packages":["pkg:npm/regexpu-core@6.4.0"],"schemaVersion":1,"symbols":["regexpu-core.default"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/regexpu-core@6.4.0"],"schemaVersion":1,"subject":"pkg:npm/regexpu-core@6.4.0","symbols":["regexpu-core.default"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-regexpu-core-default",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-regexpu-core-default",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"regexpu-core": "6.4.0"
}
},
"node_modules/jsesc": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz",
"integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==",
"license": "MIT",
"bin": {
"jsesc": "bin/jsesc"
},
"engines": {
"node": ">=6"
}
},
"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"
},
"node_modules/regenerate-unicode-properties": {
"version": "10.2.2",
"resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-10.2.2.tgz",
"integrity": "sha512-m03P+zhBeQd1RGnYxrGyDAPpWX/epKirLrp8e3qevZdVkKtnCrjjWczIbYc8+xd6vcTStVlqfycTx1KR4LOr0g==",
"license": "MIT",
"dependencies": {
"regenerate": "^1.4.2"
},
"engines": {
"node": ">=4"
}
},
"node_modules/regexpu-core": {
"version": "6.4.0",
"resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-6.4.0.tgz",
"integrity": "sha512-0ghuzq67LI9bLXpOX/ISfve/Mq33a4aFRzoQYhnnok1JOFpmE/A2TBGkNVenOGEeSBCjIiWcc6MVOG5HEQv0sA==",
"license": "MIT",
"dependencies": {
"regenerate": "^1.4.2",
"regenerate-unicode-properties": "^10.2.2",
"regjsgen": "^0.8.0",
"regjsparser": "^0.13.0",
"unicode-match-property-ecmascript": "^2.0.0",
"unicode-match-property-value-ecmascript": "^2.2.1"
},
"engines": {
"node": ">=4"
}
},
"node_modules/regjsgen": {
"version": "0.8.0",
"resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.8.0.tgz",
"integrity": "sha512-RvwtGe3d7LvWiDQXeQw8p5asZUmfU1G/l6WbUXeHta7Y2PEIvBTwH6E2EfmYUK8pxcxEdEmaomqyp0vZZ7C+3Q==",
"license": "MIT"
},
"node_modules/regjsparser": {
"version": "0.13.2",
"resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.13.2.tgz",
"integrity": "sha512-NgRBy2Nx/bE+9F27nVHnqcN5HjyLmecqsqx2PJHu3/IEtADD4WuxuXIVExD5PoSDFVrl78dOonfcOe5O+5nbzQ==",
"license": "BSD-2-Clause",
"dependencies": {
"jsesc": "~3.1.0"
},
"bin": {
"regjsparser": "bin/parser"
}
},
"node_modules/unicode-canonical-property-names-ecmascript": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.1.tgz",
"integrity": "sha512-dA8WbNeb2a6oQzAQ55YlT5vQAWGV9WXOsi3SskE3bcCdM0P4SDd+24zS/OCacdRq5BkdsRj9q3Pg6YyQoxIGqg==",
"license": "MIT",
"engines": {
"node": ">=4"
}
},
"node_modules/unicode-match-property-ecmascript": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-2.0.0.tgz",
"integrity": "sha512-5kaZCrbp5mmbz5ulBkDkbY0SsPOjKqVS35VpL9ulMPfSl0J0Xsm+9Evphv9CoIZFwre7aJoa94AY6seMKGVN5Q==",
"license": "MIT",
"dependencies": {
"unicode-canonical-property-names-ecmascript": "^2.0.0",
"unicode-property-aliases-ecmascript": "^2.0.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/unicode-match-property-value-ecmascript": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-2.2.1.tgz",
"integrity": "sha512-JQ84qTuMg4nVkx8ga4A16a1epI9H6uTXAknqxkGF/aFfRLw1xC/Bp24HNLaZhHSkWd3+84t8iXnp1J0kYcZHhg==",
"license": "MIT",
"engines": {
"node": ">=4"
}
},
"node_modules/unicode-property-aliases-ecmascript": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-2.2.0.tgz",
"integrity": "sha512-hpbDzxUY9BFwX+UeBnxv3Sh1q7HFxj48DTmXchNgRa46lO8uj3/1iEn3MiNUYTg1g9ctIqXCCERn8gYZhHC5lQ==",
"license": "MIT",
"engines": {
"node": ">=4"
}
}
}
}
{
"name": "sample-regexpu-core-default",
"version": "1.0.0",
"type": "module",
"private": true,
"license": "MIT-0",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"regexpu-core": "6.4.0"
}
}
{
"schemaVersion": 1,
"goal": "verify regexpu-core.default in pkg:npm/regexpu-core@6.4.0",
"kind": "HOW",
"packages": [
"pkg:npm/regexpu-core@6.4.0"
],
"symbols": [
"regexpu-core.default"
]
}
import rewritePattern from 'regexpu-core';
/**
* Transpiles a regular expression pattern and flags using regexpu-core options,
* and compiles it into an executable RegExp instance.
*
* @param {string} pattern - The regular expression pattern.
* @param {string} [flags=''] - Regular expression flags.
* @param {object} [options] - regexpu-core rewriting options.
* @returns {RegExp} A new compiled RegExp instance.
*/
export function transpileRegExp(pattern, flags = '', options = undefined) {
let targetFlags = flags;
const mergedOptions = {
...options,
onNewFlags: (newFlags) => {
targetFlags = newFlags;
if (options && typeof options.onNewFlags === 'function') {
options.onNewFlags(newFlags);
}
},
};
const rewritten = rewritePattern(pattern, flags, mergedOptions);
return new RegExp(rewritten, targetFlags);
}
/**
* Rewrites a pattern with dotAll transformation enabled.
*
* @param {string} pattern - Pattern containing dot syntax.
* @param {string} [flags='s'] - Flags containing 's'.
* @returns {string} Rewritten pattern compatible with environments without dotAll support.
*/
export function transformDotAll(pattern, flags = 's') {
return rewritePattern(pattern, flags, { dotAllFlag: 'transform' });
}
/**
* Rewrites a pattern with named capture groups transformed into regular capture groups,
* returning the transformed pattern and an array of captured group names and indices.
*
* @param {string} pattern - Pattern containing named capture groups.
* @param {string} [flags=''] - Flags.
* @returns {{ pattern: string, groups: Array<{ name: string, index: number }> }}
*/
export function transformNamedGroups(pattern, flags = '') {
const groups = [];
const rewritten = rewritePattern(pattern, flags, {
namedGroups: 'transform',
onNamedGroup: (name, index) => {
groups.push({ name, index });
},
});
return { pattern: rewritten, groups };
}
/**
* Rewrites a pattern containing Unicode property escapes (\p{...} or \P{...}).
*
* @param {string} pattern - Pattern with Unicode property escapes.
* @param {string} [flags='u'] - Flags.
* @returns {string} Rewritten pattern using character classes.
*/
export function transformUnicodeProperties(pattern, flags = 'u') {
return rewritePattern(pattern, flags, { unicodePropertyEscapes: 'transform' });
}
/**
* Rewrites a pattern containing Unicode sets (v flag) operations.
*
* @param {string} pattern - Pattern with Unicode sets.
* @param {string} [flags='v'] - Flags.
* @returns {string} Rewritten pattern.
*/
export function transformUnicodeSets(pattern, flags = 'v') {
return rewritePattern(pattern, flags, { unicodeSetsFlag: 'transform' });
}
export default rewritePattern;
import assert from 'node:assert';
import rewritePattern, {
transpileRegExp,
transformDotAll,
transformNamedGroups,
transformUnicodeProperties,
transformUnicodeSets,
} from '../src/index.mjs';
// 1. rewritePattern default export is a function capable of transpiling regex patterns
assert(typeof rewritePattern === 'function', 'rewritePattern must be a function');
assert.strictEqual(rewritePattern('abc', ''), 'abc', 'literal pattern should remain unchanged');
assert.strictEqual(rewritePattern('a.c', ''), 'a.c', 'standard pattern without options is preserved');
// 2. rewritePattern transforms dotAll flag into character class matching any character including newline
const dotAllResult = transformDotAll('.', 's');
assert.strictEqual(dotAllResult, '[^]', 'dot with dotAll transform must produce [^]');
const dotAllRegex = new RegExp(dotAllResult);
assert.strictEqual(dotAllRegex.test('\n'), true, 'rewritten dot must match newline');
assert.strictEqual(dotAllRegex.test('\r'), true, 'rewritten dot must match carriage return');
assert.strictEqual(dotAllRegex.test('z'), true, 'rewritten dot must match standard characters');
// 3. rewritePattern transforms named capture groups and records group names with onNamedGroup callback
const { pattern: namedPattern, groups: capturedGroups } = transformNamedGroups('(?<year>\\d{4})-(?<month>\\d{2})');
assert.strictEqual(namedPattern, '(\\d{4})-(\\d{2})', 'named capture groups must be transformed to standard capture groups');
assert.deepStrictEqual(capturedGroups, [
{ name: 'year', index: 1 },
{ name: 'month', index: 2 },
], 'captured groups metadata must match defined group names and indices');
// 4. rewritePattern transforms unicode property escapes into character ranges
const asciiTransformed = transformUnicodeProperties('\\p{ASCII}', 'u');
assert(asciiTransformed.startsWith('[') && asciiTransformed.endsWith(']'), 'rewritten ASCII pattern must be a character class');
assert(asciiTransformed.includes('7F'), 'character class should cover ASCII range boundary');
const asciiRegex = new RegExp('^' + asciiTransformed + '+$');
assert.strictEqual(asciiRegex.test('CodeSampleX123'), true, 'ASCII regex must match ASCII strings');
assert.strictEqual(asciiRegex.test('안녕'), false, 'ASCII regex must not match non-ASCII strings');
// 5. rewritePattern transforms unicode code point escapes to UTF-16 surrogate pairs
const unicodeTransformed = rewritePattern('\\u{1F600}', 'u', { unicodeFlag: 'transform' });
assert(unicodeTransformed.startsWith('(?' + ':') && unicodeTransformed.includes('uD83D') && unicodeTransformed.includes('uDE00'), 'Unicode code point must transform to surrogate pair representation');
const unicodeRegex = new RegExp('^' + unicodeTransformed + '$');
assert.strictEqual(unicodeRegex.test('😀'), true, 'surrogate pair regex must match emoji code point');
assert.strictEqual(unicodeRegex.test('a'), false, 'surrogate pair regex must not match unrelated character');
// 6. rewritePattern transforms unicode sets difference operations under v flag into simplified character class
const setDiffTransformed = transformUnicodeSets('[[a-z]--[d-g]]', 'v');
assert.strictEqual(setDiffTransformed, '[a-ch-z]', 'unicode set difference [[a-z]--[d-g]] must transform to [a-ch-z]');
const setDiffRegex = new RegExp('^' + setDiffTransformed + '$');
assert.strictEqual(setDiffRegex.test('c'), true, 'set diff must match allowed character c');
assert.strictEqual(setDiffRegex.test('e'), false, 'set diff must not match excluded character e');
assert.strictEqual(setDiffRegex.test('z'), true, 'set diff must match allowed character z');
// 7. rewritePattern transforms inline case-insensitive regex modifiers into case-folded character alternatives
let newFlagsResult = '';
const modifierTransformed = rewritePattern('(?i:abc)', '', {
modifiers: 'transform',
onNewFlags: (flags) => {
newFlagsResult = flags;
},
});
assert.strictEqual(modifierTransformed, '(?:[Aa][Bb][Cc])', 'inline (?i:abc) must transform to case-folded alternative [Aa][Bb][Cc]');
assert.strictEqual(newFlagsResult, '', 'new flags should be empty when modifiers are transformed into pattern');
const modifierRegex = new RegExp('^' + modifierTransformed + '$');
assert.strictEqual(modifierRegex.test('AbC'), true, 'case-folded pattern must match mixed case string');
assert.strictEqual(modifierRegex.test('abd'), false, 'case-folded pattern must not match different character');
// 8. transpileRegExp compiles rewritten pattern into an executable RegExp instance
const compiled = transpileRegExp('(?<id>[A-Z]+)-(?<num>\\d+)', '', { namedGroups: 'transform' });
assert(compiled instanceof RegExp, 'transpileRegExp must return a RegExp instance');
const match = compiled.exec('ITEM-42');
assert(match !== null, 'compiled regex should match valid input');
assert.strictEqual(match[1], 'ITEM', 'first capture group must match ITEM');
assert.strictEqual(match[2], '42', 'second capture group must match 42');
assert.throws(() => transpileRegExp('(', ''), SyntaxError, 'invalid pattern must throw SyntaxError');
console.log('All contract assertions for regexpu-core.default passed successfully.');
오리진 시더
익명