CodeSampleX

Пример

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

Проверенный пример — npm @webassemblyjs/floating-point-hex-parser 1.13.2: default. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден.

sha256:75e8d41252ff70c1150463ab5fefb34e466f4df0776f70c0fe558d5fb648a79e

Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла. Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди. MIT-0

Свидетельства выполнения

Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.

Основа свидетельства
Подписанный контракт пройден
Квитанции проверки
1
Ключи подписи, собравшие его
1
Заявленная среда node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Среды запусков проверки

Окружение Контракт Этапы Запуск
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

Кейс

HOW
Цель
verify pkg:npm/%40webassemblyjs/floating-point-hex-parser@1.13.2
Пакеты
Символы
  • default
Окружение
node 22.23.2
Создан
2026-08-27T23:17:56Z

Контракт

  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

Файлы

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

Скачать артефакт с исходным кодом (tar.gz)

Исходный код

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.");

Исходный сидер

аноним