Пример
lodash.escaperegexp 4.1.2: escapeRegExp
Проверенный пример — npm lodash.escaperegexp 4.1.2: escapeRegExp. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден.
sha256:8e56c58d990bebfbf887cb7666d7e0bb8722f650ce8101a26490df3fe32f3394
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
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-28 |
Кейс
HOW- Цель
- verify pkg:npm/lodash.escaperegexp@4.1.2
- Пакеты
- Символы
-
- escapeRegExp
- lodash.escaperegexp
- Окружение
- node 22.23.2
- Создан
- 2026-08-28T04:59:33Z
Контракт
- escapeRegExp exports a function that escapes RegExp special characters
- escapeRegExp escapes all 14 standard RegExp syntax characters \ ^ $ . * + ? ( ) [ ] { } |
- escapeRegExp preserves regular strings and characters that do not require escaping
- escapeRegExp converts null and undefined to empty strings
- escapeRegExp converts numbers and other non-string primitives to strings
- createExactMatcher creates regular expressions matching exact literal text with special characters
Файлы
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- 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 pkg:npm/lodash.escaperegexp@4.1.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/lodash.escaperegexp@4.1.2
Demonstrate these symbols/APIs:
- escapeRegExp
- lodash.escaperegexp
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:29ad9274f6925f71663673fa3c619b9376a3a2e082f37cfbb6a8cafddc942ea1","contract":["escapeRegExp exports a function that escapes RegExp special characters","escapeRegExp escapes all 14 standard RegExp syntax characters \\ ^ $ . * + ? ( ) [ ] { } |","escapeRegExp preserves regular strings and characters that do not require escaping","escapeRegExp converts null and undefined to empty strings","escapeRegExp converts numbers and other non-string primitives to strings","createExactMatcher creates regular expressions matching exact literal text with special characters"],"goal":"verify pkg:npm/lodash.escaperegexp@4.1.2","kind":"HOW","packages":["pkg:npm/lodash.escaperegexp@4.1.2"],"schemaVersion":1,"symbols":["escapeRegExp","lodash.escaperegexp"]},"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/lodash.escaperegexp@4.1.2"],"schemaVersion":1,"subject":"pkg:npm/lodash.escaperegexp@4.1.2","symbols":["escapeRegExp","lodash.escaperegexp"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-lodash-escaperegexp",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-lodash-escaperegexp",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"lodash.escaperegexp": "4.1.2"
}
},
"node_modules/lodash.escaperegexp": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/lodash.escaperegexp/-/lodash.escaperegexp-4.1.2.tgz",
"integrity": "sha512-TM9YBvyC84ZxE3rgfefxUWiQKLilstD6k7PTGt6wfbtXF8ixIJLOL3VYyV/z+ZiPLsVxAsKAFVwWlWeb2Y8Yyw==",
"license": "MIT"
}
}
}
{
"name": "sample-lodash-escaperegexp",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of lodash.escaperegexp special character escaping",
"type": "module",
"main": "src/index.js",
"license": "MIT-0",
"dependencies": {
"lodash.escaperegexp": "4.1.2"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/lodash.escaperegexp@4.1.2",
"kind": "HOW",
"packages": [
"pkg:npm/lodash.escaperegexp@4.1.2"
],
"symbols": [
"escapeRegExp",
"lodash.escaperegexp"
]
}
import escapeRegExp from 'lodash.escaperegexp';
/**
* Escapes RegExp special characters in a string so it can be safely used in a RegExp constructor.
*
* @param {string} string - The string to escape.
* @returns {string} The escaped string.
*/
export function escapePattern(string) {
return escapeRegExp(string);
}
/**
* Creates a regular expression that matches the exact literal string.
*
* @param {string} literal - The exact literal string to match.
* @param {string} [flags=''] - Optional RegExp flags.
* @returns {RegExp} RegExp matching the exact string.
*/
export function createExactMatcher(literal, flags = '') {
return new RegExp(escapeRegExp(literal), flags);
}
export { escapeRegExp };
export default escapeRegExp;
import assert from 'node:assert/strict';
import { escapeRegExp, escapePattern, createExactMatcher } from '../src/index.js';
// 1. escapeRegExp exports a function that escapes RegExp special characters
assert.equal(typeof escapeRegExp, 'function', 'escapeRegExp should be a function');
assert.equal(typeof escapePattern, 'function', 'escapePattern helper should be a function');
assert.equal(typeof createExactMatcher, 'function', 'createExactMatcher helper should be a function');
// 2. escapeRegExp escapes all 14 standard RegExp syntax characters \ ^ $ . * + ? ( ) [ ] { } |
const specialChars = '\\^$.*+?()[]{}|';
const expectedEscaped = '\\\\\\^\\$\\.\\*\\+\\?\\(\\)\\[\\]\\{\\}\\|';
assert.equal(escapeRegExp(specialChars), expectedEscaped, 'all special characters must be preceded by a backslash');
assert.equal(escapePattern('[lodash](https://example.com/)'), '\\[lodash\\]\\(https://example\\.com/\\)');
// 3. escapeRegExp preserves regular strings and characters that do not require escaping
assert.equal(escapeRegExp('hello world 123'), 'hello world 123', 'alphanumeric text without special characters should remain unchanged');
assert.equal(escapeRegExp(''), '', 'empty string should return empty string');
assert.equal(escapeRegExp('abc_def-ghi'), 'abc_def-ghi', 'regular punctuation like underscore and hyphen should not be escaped');
// 4. escapeRegExp converts null and undefined to empty strings
assert.equal(escapeRegExp(null), '', 'null input should return empty string');
assert.equal(escapeRegExp(undefined), '', 'undefined input should return empty string');
// 5. escapeRegExp converts numbers and other non-string primitives to strings
assert.equal(escapeRegExp(42), '42', 'number should be converted to string');
assert.equal(escapeRegExp(0), '0', 'zero should be converted to string');
assert.equal(escapeRegExp(-0), '-0', 'negative zero should preserve sign');
assert.equal(escapeRegExp(true), 'true', 'boolean should be converted to string');
// 6. createExactMatcher creates regular expressions matching exact literal text with special characters
const literalText = 'Item: [Special $10.00] (Discount: 20% + 5% bonus?)';
const matcher = createExactMatcher(literalText);
assert.ok(matcher instanceof RegExp, 'matcher should be an instance of RegExp');
assert.equal(matcher.test(literalText), true, 'matcher should match the exact literal string');
assert.equal(matcher.test('Item: Special $10.00'), false, 'matcher should not match text missing escaped brackets');
const textWithTarget = 'Start of text. ' + literalText + ' End of text.';
const matches = textWithTarget.match(createExactMatcher(literalText, 'g'));
assert.equal(matches?.length, 1, 'should find exactly one match in larger string');
assert.equal(matches?.[0], literalText, 'matched text should equal the literal text');
console.log('All lodash.escaperegexp contract tests passed successfully.');
Исходный сидер
аноним