CodeSampleX

Exemple

@tootallnate/quickjs-emscripten 0.23.0: getQuickJSSync

Échantillon vérifié pour npm @tootallnate/quickjs-emscripten 0.23.0: getQuickJSSync. Le contrat s'est exécuté sur node 22 · linux debian/x64 · docker et a…

sha256:7221f8d39f00498256b06ade7078d882fa311c48f81d2bf1d6ed0eb876ecfdf6

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

Environnements des exécutions de vérification

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

Cas

HOW
Objectif
verify @tootallnate/quickjs-emscripten.getQuickJSSync in pkg:npm/%40tootallnate/quickjs-emscripten@0.23.0
Paquets
Symboles
  • @tootallnate/quickjs-emscripten.getQuickJSSync
Environnement
node 22.23.2
Créé
2026-09-07T03:25:45Z

Contrat

  1. getQuickJSSync throws an Error when called before getQuickJS has resolved
  2. getQuickJSSync returns the shared QuickJSWASMModule singleton after getQuickJS resolves
  3. getQuickJSSync returns identical instance references across multiple synchronous calls
  4. getQuickJSSync module instance evaluates Javascript expressions directly via evalCode
  5. getQuickJSSync module evalCode propagates unhandled script exceptions as native errors
  6. getQuickJSSync module newContext creates isolated execution environments with independent globals and memory management
  7. getQuickJSSync module newRuntime creates isolated runtime instances with custom memory limits

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: verify @tootallnate/quickjs-emscripten.getQuickJSSync in pkg:npm/%40tootallnate/quickjs-emscripten@0.23.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40tootallnate/quickjs-emscripten@0.23.0
Demonstrate these symbols/APIs:
  - @tootallnate/quickjs-emscripten.getQuickJSSync

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:5ce0cfa1ec86fb906b8347a75f3e1f0f1d72a9bdc941660ebe3a0268cbacd79b","constraints":{"executionContext":"node"},"contract":["getQuickJSSync throws an Error when called before getQuickJS has resolved","getQuickJSSync returns the shared QuickJSWASMModule singleton after getQuickJS resolves","getQuickJSSync returns identical instance references across multiple synchronous calls","getQuickJSSync module instance evaluates Javascript expressions directly via evalCode","getQuickJSSync module evalCode propagates unhandled script exceptions as native errors","getQuickJSSync module newContext creates isolated execution environments with independent globals and memory management","getQuickJSSync module newRuntime creates isolated runtime instances with custom memory limits"],"goal":"verify @tootallnate/quickjs-emscripten.getQuickJSSync in pkg:npm/%40tootallnate/quickjs-emscripten@0.23.0","kind":"HOW","packages":["pkg:npm/%40tootallnate/quickjs-emscripten@0.23.0"],"schemaVersion":1,"symbols":["@tootallnate/quickjs-emscripten.getQuickJSSync"]},"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/%40tootallnate/quickjs-emscripten@0.23.0"],"schemaVersion":1,"subject":"pkg:npm/%40tootallnate/quickjs-emscripten@0.23.0","symbols":["@tootallnate/quickjs-emscripten.getQuickJSSync"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-quickjs-emscripten-getquickjssync",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-quickjs-emscripten-getquickjssync",
      "version": "1.0.0",
      "dependencies": {
        "@tootallnate/quickjs-emscripten": "0.23.0"
      }
    },
    "node_modules/@tootallnate/quickjs-emscripten": {
      "version": "0.23.0",
      "resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz",
      "integrity": "sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-quickjs-emscripten-getquickjssync",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room code sample for @tootallnate/quickjs-emscripten getQuickJSSync",
  "license": "MIT-0",
  "dependencies": {
    "@tootallnate/quickjs-emscripten": "0.23.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify @tootallnate/quickjs-emscripten.getQuickJSSync in pkg:npm/%40tootallnate/quickjs-emscripten@0.23.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40tootallnate/quickjs-emscripten@0.23.0"
  ],
  "symbols": [
    "@tootallnate/quickjs-emscripten.getQuickJSSync"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import { getQuickJS, getQuickJSSync } from '@tootallnate/quickjs-emscripten';

// 1. getQuickJSSync throws an Error when called before getQuickJS has resolved
assert.throws(
  () => getQuickJSSync(),
  {
    name: 'Error',
    message: 'QuickJS not initialized. Await getQuickJS() at least once.'
  }
);

// 2. getQuickJSSync returns the shared QuickJSWASMModule singleton after getQuickJS resolves
const asyncModule = await getQuickJS();
const syncModule = getQuickJSSync();
assert.equal(syncModule, asyncModule);

// 3. getQuickJSSync returns identical instance references across multiple synchronous calls
const secondCall = getQuickJSSync();
assert.equal(secondCall, syncModule);

// 4. getQuickJSSync module instance evaluates Javascript expressions directly via evalCode
const evalResult = syncModule.evalCode('JSON.stringify({ sum: [1, 2, 3, 4].reduce((a, b) => a + b, 0) })');
assert.equal(evalResult, JSON.stringify({ sum: 10 }));

// 5. getQuickJSSync module evalCode propagates unhandled script exceptions as native errors
assert.throws(
  () => {
    syncModule.evalCode('throw new TypeError("invalid type in vm")');
  },
  (err) => err && err.name === 'TypeError' && err.message === 'invalid type in vm'
);

// 6. getQuickJSSync module newContext creates isolated execution environments with independent globals and memory management
const ctx1 = syncModule.newContext();
const ctx2 = syncModule.newContext();
try {
  const h1 = ctx1.evalCode('globalThis.x = 42; globalThis.x');
  const h2 = ctx2.evalCode('typeof globalThis.x');
  assert.equal(ctx1.dump(h1.value), 42);
  assert.equal(ctx2.dump(h2.value), 'undefined');
  h1.value.dispose();
  h2.value.dispose();
} finally {
  ctx1.dispose();
  ctx2.dispose();
}

// 7. getQuickJSSync module newRuntime creates isolated runtime instances with custom memory limits
const rt = syncModule.newRuntime({ memoryLimitBytes: 1024 * 1024 });
const ctx = rt.newContext();
try {
  const result = ctx.evalCode('2 ** 10');
  assert.equal(ctx.dump(result.value), 1024);
  result.value.dispose();
} finally {
  ctx.dispose();
  rt.dispose();
}

Seeder d'origine

anonyme