CodeSampleX

Beispiel

balanced-match 1.0.2

Verifiziertes Beispiel für npm balanced-match 1.0.2. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand: balanced matches balanced…

sha256:6bac510a5d55404e7b6c840be79fb2fd1ce04c4f993a7fb4822cbe644fb42530

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-21

Fall

HOW
Ziel
verify pkg:npm/balanced-match@1.0.2
Pakete
Umgebung
node 22.23.2
Erstellt
2026-08-21T16:12:24Z

Contract

  1. balanced matches balanced delimiters and returns pre, body, post, start, and end
  2. balanced correctly parses nested delimiters returning the outermost balanced span
  3. balanced returns undefined when delimiters do not match
  4. balanced.range returns [start, end] indices for balanced matches or undefined if unbalanced

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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: verify pkg:npm/balanced-match@1.0.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/balanced-match@1.0.2
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

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:6bb49f69b03a0f59eb7b857fb9328b808879a6cc58199f5af373275253c6e16e","constraints":{"executionContext":"node"},"contract":["balanced matches balanced delimiters and returns pre, body, post, start, and end","balanced correctly parses nested delimiters returning the outermost balanced span","balanced returns undefined when delimiters do not match","balanced.range returns [start, end] indices for balanced matches or undefined if unbalanced"],"goal":"verify pkg:npm/balanced-match@1.0.2","kind":"HOW","packages":["pkg:npm/balanced-match@1.0.2"],"schemaVersion":1},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/balanced-match@1.0.2"],"schemaVersion":1,"subject":"pkg:npm/balanced-match@1.0.2","verifierAdapter":"node-typescript@1"}
index.js
const balanced = require("balanced-match");

function extractBalanced(opening, closing, text) {
  const match = balanced(opening, closing, text);
  if (!match) {
    return null;
  }
  return {
    start: match.start,
    end: match.end,
    pre: match.pre,
    body: match.body,
    post: match.post
  };
}

function extractRange(opening, closing, text) {
  return balanced.range(opening, closing, text);
}

module.exports = {
  extractBalanced,
  extractRange
};
package-lock.json
{
  "name": "sample-balanced-match",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-balanced-match",
      "version": "1.0.0",
      "dependencies": {
        "balanced-match": "1.0.2"
      }
    },
    "node_modules/balanced-match": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
      "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-balanced-match",
  "version": "1.0.0",
  "private": true,
  "description": "Sample verifying balanced-match delimiters matching and range extraction",
  "main": "index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "balanced-match": "1.0.2"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/balanced-match@1.0.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/balanced-match@1.0.2"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.js
const assert = require("assert");
const { extractBalanced, extractRange } = require("../index.js");
const balanced = require("balanced-match");

// Test 1: Basic balanced delimiter match
const res1 = extractBalanced("{", "}", "prefix{inside}suffix");
assert.deepStrictEqual(res1, {
  start: 6,
  end: 13,
  pre: "prefix",
  body: "inside",
  post: "suffix"
});

// Test 2: Nested delimiter match returns the outermost balanced range
const res2 = extractBalanced("{", "}", "a{b{c}d}e");
assert.deepStrictEqual(res2, {
  start: 1,
  end: 7,
  pre: "a",
  body: "b{c}d",
  post: "e"
});

// Test 3: No match returns null
const res3 = extractBalanced("{", "}", "no delimiters here");
assert.strictEqual(res3, null);

// Test 4: Custom string delimiter match
const res4 = extractBalanced("<b>", "</b>", "hello <b>world</b>!");
assert.deepStrictEqual(res4, {
  start: 6,
  end: 14,
  pre: "hello ",
  body: "world",
  post: "!"
});

// Test 5: Range extraction returns [start, end] indices
const range1 = extractRange("{", "}", "abc{def}ghi");
assert.deepStrictEqual(range1, [3, 7]);

// Test 6: Unbalanced string returns undefined
const rangeUnbalanced = extractRange("{", "}", "unbalanced { open");
assert.strictEqual(rangeUnbalanced, undefined);

// Direct package call verification
const direct = balanced("(", ")", "pre(match)post");
assert.strictEqual(direct.body, "match");

console.log("All contract tests passed successfully.");

Ursprungs-Seeder

anonym