CodeSampleX

Beispiel

acorn 8.18.0: parseExpressionAt

Verifiziertes Beispiel für npm acorn 8.18.0: parseExpressionAt. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand.

sha256:09d1876f21b3e3e2b52b152f2f9b00ac4e3390c2c79cdbb48e6721c4aad5da1b

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
2
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung linux 24 · ubuntu · glibc 2.39 x64 npm

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@1node:22-alpine@sha256:c610fcdfb1d5…
2026-08-26
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-07

Fall

HOW
Ziel
verify acorn.parseExpressionAt in pkg:npm/acorn@8.18.0
Pakete
Symbole
  • acorn.parseExpressionAt
Erstellt
2026-08-26T11:02:16Z

Contract

  1. acorn.parseExpressionAt(input, offset, options) parses a single JavaScript expression starting at the given offset and returns an AST Node
  2. acorn.parseExpressionAt returns node with correct type, start, end, and expression-specific fields
  3. acorn.parseExpressionAt supports locations and ranges options for source mapping
  4. acorn.parseExpressionAt supports ecmaVersion option for modern ECMAScript syntax features
  5. acorn.parseExpressionAt throws SyntaxError when given invalid JavaScript syntax at the offset

Dateien

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

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 acorn.parseExpressionAt in pkg:npm/acorn@8.18.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/acorn@8.18.0
Demonstrate these symbols/APIs:
  - acorn.parseExpressionAt

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:2454e3b22563855d5dbe8f805a449826580cfcb69ad5d80c0f363f44f5ecdea8","contract":["acorn.parseExpressionAt(input, offset, options) parses a single JavaScript expression starting at the given offset and returns an AST Node","acorn.parseExpressionAt returns node with correct type, start, end, and expression-specific fields","acorn.parseExpressionAt supports locations and ranges options for source mapping","acorn.parseExpressionAt supports ecmaVersion option for modern ECMAScript syntax features","acorn.parseExpressionAt throws SyntaxError when given invalid JavaScript syntax at the offset"],"goal":"verify acorn.parseExpressionAt in pkg:npm/acorn@8.18.0","kind":"HOW","packages":["pkg:npm/acorn@8.18.0"],"schemaVersion":1,"symbols":["acorn.parseExpressionAt"]},"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/acorn@8.18.0"],"schemaVersion":1,"subject":"pkg:npm/acorn@8.18.0","symbols":["acorn.parseExpressionAt"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-acorn-parse-expression-at",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-acorn-parse-expression-at",
      "version": "1.0.0",
      "dependencies": {
        "acorn": "8.18.0"
      }
    },
    "node_modules/acorn": {
      "version": "8.18.0",
      "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.18.0.tgz",
      "integrity": "sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==",
      "license": "MIT",
      "bin": {
        "acorn": "bin/acorn"
      },
      "engines": {
        "node": ">=0.4.0"
      }
    }
  }
}
package.json
{
  "name": "sample-acorn-parse-expression-at",
  "version": "1.0.0",
  "type": "module",
  "dependencies": {
    "acorn": "8.18.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify acorn.parseExpressionAt in pkg:npm/acorn@8.18.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/acorn@8.18.0"
  ],
  "symbols": [
    "acorn.parseExpressionAt"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import * as acorn from 'acorn';

// 1. Basic expression parsing at offset 0
{
  const code = '1 + 2';
  const node = acorn.parseExpressionAt(code, 0, { ecmaVersion: 2020 });
  assert.equal(node.type, 'BinaryExpression');
  assert.equal(node.start, 0);
  assert.equal(node.end, 5);
  assert.equal(node.operator, '+');
  assert.equal(node.left.type, 'Literal');
  assert.equal(node.left.value, 1);
  assert.equal(node.right.type, 'Literal');
  assert.equal(node.right.value, 2);
}

// 2. Parsing expression starting at arbitrary offset
{
  const code = 'const msg = "hello " + name;';
  const offset = 12; // Start of `"hello " + name`
  const node = acorn.parseExpressionAt(code, offset, { ecmaVersion: 2020 });
  assert.equal(node.type, 'BinaryExpression');
  assert.equal(node.start, 12);
  assert.equal(node.end, 27);
  assert.equal(node.left.type, 'Literal');
  assert.equal(node.left.value, 'hello ');
  assert.equal(node.right.type, 'Identifier');
  assert.equal(node.right.name, 'name');
}

// 3. Options: locations and ranges
{
  const code = 'foo.bar(42)';
  const node = acorn.parseExpressionAt(code, 0, {
    ecmaVersion: 2020,
    locations: true,
    ranges: true
  });
  assert.equal(node.type, 'CallExpression');
  assert.deepEqual(node.range, [0, 11]);
  assert.ok(node.loc);
  assert.equal(node.loc.start.line, 1);
  assert.equal(node.loc.start.column, 0);
  assert.equal(node.loc.end.line, 1);
  assert.equal(node.loc.end.column, 11);
}

// 4. Modern syntax with optional chaining and nullish coalescing
{
  const code = 'user?.profile?.name ?? "Anonymous"';
  const node = acorn.parseExpressionAt(code, 0, { ecmaVersion: 2022 });
  assert.equal(node.type, 'LogicalExpression');
  assert.equal(node.operator, '??');
  assert.equal(node.left.type, 'ChainExpression');
  assert.equal(node.right.value, 'Anonymous');
}

// 5. Syntax error handling
{
  assert.throws(
    () => {
      acorn.parseExpressionAt('1 +', 0, { ecmaVersion: 2020 });
    },
    (err) => {
      assert.ok(err instanceof SyntaxError);
      assert.ok(typeof err.pos === 'number');
      return true;
    }
  );
}

console.log('All contract assertions passed successfully.');

Ursprungs-Seeder

anonym