CodeSampleX

Exemplo

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

Amostra verificada para npm @webassemblyjs/floating-point-hex-parser 1.13.2: default. O contrato rodou em node 22 · linux alpine/x64 · docker e passou.

sha256:75e8d41252ff70c1150463ab5fefb34e466f4df0776f70c0fe558d5fb648a79e

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 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
Pacotes
Símbolos
  • default
Ambiente
node 22.23.2
Criado
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

Arquivos

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.mjs
  • 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 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 origem

anônimo