CodeSampleX

Ejemplo

@webassemblyjs/floating-point-hex-parser 1.13.2: default

Muestra verificada para npm @webassemblyjs/floating-point-hex-parser 1.13.2: default. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó.

sha256:75e8d41252ff70c1150463ab5fefb34e466f4df0776f70c0fe558d5fb648a79e

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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
verify pkg:npm/%40webassemblyjs/floating-point-hex-parser@1.13.2
Paquetes
Símbolos
  • default
Entorno
node 22.23.2
Creado
2026-08-27T23:17:56Z

Contrato

  1. parseHexFloat parses floating point hexadecimal string with negative binary exponent to IEEE 754 float
  2. parseHexFloat parses floating point hexadecimal string with fractional mantissa and positive binary exponent
  3. parseHexFloat parses hexadecimal integer string without exponent component
  4. parseHexFloat correctly preserves negative sign for hexadecimal floating point values

Archivos

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

Descargar el artefacto de código fuente (tar.gz)

Código fuente

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/%40webassemblyjs/floating-point-hex-parser@1.13.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40webassemblyjs/floating-point-hex-parser@1.13.2
Demonstrate these symbols/APIs:
  - default

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:c281b20675cc11a4cc84ff45e7172104f1abef110e250c181d1d9c988343b19b","contract":["parseHexFloat parses floating point hexadecimal string with negative binary exponent to IEEE 754 float","parseHexFloat parses floating point hexadecimal string with fractional mantissa and positive binary exponent","parseHexFloat parses hexadecimal integer string without exponent component","parseHexFloat correctly preserves negative sign for hexadecimal floating point values"],"goal":"verify pkg:npm/%40webassemblyjs/floating-point-hex-parser@1.13.2","kind":"HOW","packages":["pkg:npm/%40webassemblyjs/floating-point-hex-parser@1.13.2"],"schemaVersion":1,"symbols":["default"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40webassemblyjs/floating-point-hex-parser@1.13.2"],"schemaVersion":1,"subject":"pkg:npm/%40webassemblyjs/floating-point-hex-parser@1.13.2","symbols":["default"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-floating-point-hex-parser",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-floating-point-hex-parser",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@webassemblyjs/floating-point-hex-parser": "1.13.2"
      }
    },
    "node_modules/@webassemblyjs/floating-point-hex-parser": {
      "version": "1.13.2",
      "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.13.2.tgz",
      "integrity": "sha512-6oXyTOzbKxGH4steLbLNOu71Oj+C8Lg34n6CqRvqfS2O71BxY6ByfMDRhBytzknj9yGUPVJ1qIKhRlAwO1AovA==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-floating-point-hex-parser",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "@webassemblyjs/floating-point-hex-parser": "1.13.2"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40webassemblyjs/floating-point-hex-parser@1.13.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40webassemblyjs/floating-point-hex-parser@1.13.2"
  ],
  "symbols": [
    "default"
  ]
}
src/index.mjs
import parseHexFloatModule from "@webassemblyjs/floating-point-hex-parser";

const rawParse = typeof parseHexFloatModule === "function"
  ? parseHexFloatModule
  : parseHexFloatModule.default;

/**
 * Parses a floating point hexadecimal string into an IEEE 754 number.
 *
 * @param {string} input - Hexadecimal floating point string (e.g., "0x1p-1", "0x1.8p1")
 * @returns {number} The parsed JavaScript number
 */
export function parseHexFloat(input) {
  return rawParse(input);
}

export default parseHexFloat;
test/contract.mjs
import assert from "node:assert/strict";
import parseHexFloatModule from "@webassemblyjs/floating-point-hex-parser";
import { parseHexFloat } from "../src/index.mjs";

const rawParse = typeof parseHexFloatModule === "function"
  ? parseHexFloatModule
  : parseHexFloatModule.default;

// 1. parseHexFloat parses floating point hexadecimal string with negative binary exponent to IEEE 754 float
{
  assert.equal(rawParse("0x1p-1"), 0.5);
  assert.equal(parseHexFloat("0x1p-1"), 0.5);
  assert.equal(parseHexFloat("0x1p-2"), 0.25);
  assert.equal(parseHexFloat("0x1p-3"), 0.125);
}

// 2. parseHexFloat parses floating point hexadecimal string with fractional mantissa and positive binary exponent
{
  assert.equal(rawParse("0x1.8p1"), 3);
  assert.equal(parseHexFloat("0x1.8p1"), 3);
  assert.equal(parseHexFloat("0x1.4p3"), 10);
  assert.equal(parseHexFloat("0x1.921fb54442d18p+2"), 6.283185307179586);
}

// 3. parseHexFloat parses hexadecimal integer string without exponent component
{
  assert.equal(rawParse("0x0"), 0);
  assert.equal(parseHexFloat("0x0"), 0);
  assert.equal(parseHexFloat("0x10"), 16);
  assert.equal(parseHexFloat("0xFF"), 255);
}

// 4. parseHexFloat correctly preserves negative sign for hexadecimal floating point values
{
  assert.equal(rawParse("-0x1p0"), -1);
  assert.equal(parseHexFloat("-0x1p0"), -1);
  assert.equal(parseHexFloat("-0x1p-1"), -0.5);
  assert.equal(parseHexFloat("-0x1.8p1"), -3);
}

console.log("All floating-point-hex-parser contract tests passed successfully.");

Seeder de origen

anónimo