CodeSampleX

Exemplo

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

Amostra verificada para npm regenerate 1.4.2: create regular expression character classes from code points and ranges with regenerate. O contrato rodou em…

sha256:e252dc0549d10fccbb994d6131997e90fc4c83c26c7c0f2c21880a6497451ce8

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
1
Chaves de assinatura que o compilaram
1
Ambiente declarado linux 24 · ubuntu · glibc 2.39 x64 npm

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
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

Caso

HOW
Objetivo
create regular expression character classes from code points and ranges with regenerate
Pacotes
Símbolos
  • regenerate
  • regenerate.prototype.add
  • regenerate.prototype.addRange
  • regenerate.prototype.toRegExp
  • regenerate.prototype.toString
Criado
2026-08-27T20:47:08Z

Contrato

  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

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

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 de origem

anônimo