CodeSampleX

Exemple

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

Échantillon vérifié pour npm regenerate 1.4.2: create regular expression character classes from code points and ranges with regenerate. Le contrat s'est…

sha256:e252dc0549d10fccbb994d6131997e90fc4c83c26c7c0f2c21880a6497451ce8

Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré. Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes. MIT-0

Preuves d'exécution

L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.

Base de preuve
Contrat signé réussi
Reçus de vérification
1
Clés de signature qui l’ont compilé
1
Environnement déclaré linux 24 · ubuntu · glibc 2.39 x64 npm

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
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

Cas

HOW
Objectif
create regular expression character classes from code points and ranges with regenerate
Paquets
Symboles
  • regenerate
  • regenerate.prototype.add
  • regenerate.prototype.addRange
  • regenerate.prototype.toRegExp
  • regenerate.prototype.toString
Créé
2026-08-27T20:47:08Z

Contrat

  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

Fichiers

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

Télécharger l’artefact source (tar.gz)

Code source

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');

Seeder d'origine

anonyme