CodeSampleX

Exemplo

es-module-lexer 2.3.1: initSync

Amostra verificada para npm es-module-lexer 2.3.1: initSync. O contrato rodou em node 22 · linux debian/x64 · docker e passou.

sha256:72ee15e16c1fabaf3e9f9ff60f243f039de0b6ebc82b513a19e49e51fd723f43

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 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Ambientes das execuções de verificação

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

Caso

HOW
Objetivo
verify es-module-lexer.initSync in pkg:npm/es-module-lexer@2.3.1
Pacotes
Símbolos
  • es-module-lexer.initSync
Ambiente
node 22.23.2
Criado
2026-09-06T13:27:25Z

Contrato

  1. initSync is exported as a function from es-module-lexer
  2. initSync() executes synchronously and initializes the WebAssembly lexer
  3. parseModuleSync parses static imports, exports, and syntax metadata synchronously without awaiting init

Arquivos

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • 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: verify es-module-lexer.initSync in pkg:npm/es-module-lexer@2.3.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/es-module-lexer@2.3.1
Demonstrate these symbols/APIs:
  - es-module-lexer.initSync

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:66eb1024a2afc29c3f47e92fa00b4afc0ed156cedeadf7ca0ce25a01382db87a","contract":["initSync is exported as a function from es-module-lexer","initSync() executes synchronously and initializes the WebAssembly lexer","parseModuleSync parses static imports, exports, and syntax metadata synchronously without awaiting init"],"goal":"verify es-module-lexer.initSync in pkg:npm/es-module-lexer@2.3.1","kind":"HOW","packages":["pkg:npm/es-module-lexer@2.3.1"],"schemaVersion":1,"symbols":["es-module-lexer.initSync"]},"contractCommand":["node","test/contract.mjs"],"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/es-module-lexer@2.3.1"],"schemaVersion":1,"subject":"pkg:npm/es-module-lexer@2.3.1","symbols":["es-module-lexer.initSync"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-es-module-lexer-init-sync",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-es-module-lexer-init-sync",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "es-module-lexer": "2.3.1"
      }
    },
    "node_modules/es-module-lexer": {
      "version": "2.3.1",
      "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.3.1.tgz",
      "integrity": "sha512-shc1dbU90Yl/xq1QrC7QRtfcwURZuVRfPhZbDoldJ1cn1gzDvBaBWlv0eFolj5+0znnPJz5TXLxsN77X/12KTA==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-es-module-lexer-init-sync",
  "version": "1.0.0",
  "private": true,
  "description": "verify es-module-lexer.initSync in pkg:npm/es-module-lexer@2.3.1",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "es-module-lexer": "2.3.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify es-module-lexer.initSync in pkg:npm/es-module-lexer@2.3.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/es-module-lexer@2.3.1"
  ],
  "symbols": [
    "es-module-lexer.initSync"
  ]
}
src/index.js
const { initSync, parse } = require('es-module-lexer');

/**
 * Synchronously initializes the es-module-lexer WebAssembly module.
 */
function initializeLexerSync() {
  initSync();
}

/**
 * Synchronously parses ES module source code using initSync.
 * @param {string} source - JavaScript / ES module source code.
 * @returns {[readonly any[], readonly any[], boolean, boolean]} Parse results [imports, exports, facade, hasModuleSyntax].
 */
function parseModuleSync(source) {
  initSync();
  return parse(source);
}

module.exports = {
  initSync,
  initializeLexerSync,
  parseModuleSync
};
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const { initSync, initializeLexerSync, parseModuleSync } = require('../src/index.js');
const esModuleLexer = require('es-module-lexer');

// 1. Verify initSync is exported as a function from es-module-lexer
assert.equal(typeof initSync, 'function', 'initSync must be a function');
assert.strictEqual(initSync, esModuleLexer.initSync, 'initSync must match es-module-lexer.initSync export');

// 2. Verify initSync() executes synchronously and initializes the WebAssembly lexer
assert.doesNotThrow(() => {
  initializeLexerSync();
}, 'initializeLexerSync must execute synchronously without errors');

// 3. Verify parseModuleSync parses static imports, exports, and syntax metadata synchronously without awaiting init
const sampleCode = `
  import { helper } from 'utils';
  export const value = 123;
`;
const [imports, exports, facade, hasModuleSyntax] = parseModuleSync(sampleCode);

assert.strictEqual(imports.length, 1, 'should identify 1 import');
assert.strictEqual(imports[0].n, 'utils', 'import specifier should match');
assert.strictEqual(exports.length, 1, 'should identify 1 export');
assert.strictEqual(exports[0].n, 'value', 'export specifier should match');
assert.strictEqual(facade, false, 'facade should be false');
assert.strictEqual(hasModuleSyntax, true, 'hasModuleSyntax should be true');

console.log('Contract assertions passed.');

Seeder de origem

anônimo