샘플
@webassemblyjs/ieee754 1.13.2: encode and decode 32-bit and 64-bit floating point numbers using IEEE 754
검증된 샘플 — npm @webassemblyjs/ieee754 1.13.2: encode and decode 32-bit and 64-bit floating point numbers using IEEE 754. node 22 · linux alpine/x64 · docker에서…
sha256:b2e073cfd4e7e84514f60efb8b26d85178ca1b775de59f90359b6411384d7438
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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- 목표
- encode and decode 32-bit and 64-bit floating point numbers using IEEE 754
- 심벌
-
- decodeF32
- decodeF64
- encodeF32
- encodeF64
- 환경
- node 22.23.2
- 생성일
- 2026-08-27T23:25:51Z
컨트랙트
- assert encodeF32 returns a 4-byte little-endian array and decodeF32 round-trips single-precision floats
- assert encodeF32 and decodeF32 handle special float values including Infinity, -Infinity, and NaN
- assert encodeF64 returns an 8-byte little-endian array and decodeF64 round-trips double-precision floats
- assert encodeF64 and decodeF64 handle special double values including Infinity, -Infinity, and NaN
- assert decodeF32 and decodeF64 accept Uint8Array byte buffers as input
파일
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
소스
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: encode and decode 32-bit and 64-bit floating point numbers using IEEE 754
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40webassemblyjs/ieee754@1.13.2
Demonstrate these symbols/APIs:
- decodeF32
- decodeF64
- encodeF32
- encodeF64
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.
{"case":{"caseId":"case:sha256:d2447a0864404d1084510a613aff8e1b390eabc487921053a62b4a6c8d925d5a","contract":["assert encodeF32 returns a 4-byte little-endian array and decodeF32 round-trips single-precision floats","assert encodeF32 and decodeF32 handle special float values including Infinity, -Infinity, and NaN","assert encodeF64 returns an 8-byte little-endian array and decodeF64 round-trips double-precision floats","assert encodeF64 and decodeF64 handle special double values including Infinity, -Infinity, and NaN","assert decodeF32 and decodeF64 accept Uint8Array byte buffers as input"],"goal":"encode and decode 32-bit and 64-bit floating point numbers using IEEE 754","kind":"HOW","packages":["pkg:npm/%40webassemblyjs/ieee754@1.13.2"],"schemaVersion":1,"symbols":["decodeF32","decodeF64","encodeF32","encodeF64"]},"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/%40webassemblyjs/ieee754@1.13.2"],"schemaVersion":1,"subject":"pkg:npm/%40webassemblyjs/ieee754@1.13.2","symbols":["decodeF32","decodeF64","encodeF32","encodeF64"],"verifierAdapter":"node-typescript@1"}
const {
encodeF32,
decodeF32,
encodeF64,
decodeF64,
NUMBER_OF_BYTE_F32,
NUMBER_OF_BYTE_F64,
SINGLE_PRECISION_MANTISSA,
DOUBLE_PRECISION_MANTISSA,
} = require('@webassemblyjs/ieee754');
/**
* Encodes a 32-bit single-precision float into an array of 4 little-endian bytes.
* @param {number} value
* @returns {number[]}
*/
function encodeFloat32(value) {
return encodeF32(value);
}
/**
* Decodes an array or Uint8Array of 4 little-endian bytes into a 32-bit float.
* @param {number[] | Uint8Array} bytes
* @returns {number}
*/
function decodeFloat32(bytes) {
return decodeF32(bytes);
}
/**
* Encodes a 64-bit double-precision float into an array of 8 little-endian bytes.
* @param {number} value
* @returns {number[]}
*/
function encodeFloat64(value) {
return encodeF64(value);
}
/**
* Decodes an array or Uint8Array of 8 little-endian bytes into a 64-bit float.
* @param {number[] | Uint8Array} bytes
* @returns {number}
*/
function decodeFloat64(bytes) {
return decodeF64(bytes);
}
module.exports = {
encodeFloat32,
decodeFloat32,
encodeFloat64,
decodeFloat64,
encodeF32,
decodeF32,
encodeF64,
decodeF64,
NUMBER_OF_BYTE_F32,
NUMBER_OF_BYTE_F64,
SINGLE_PRECISION_MANTISSA,
DOUBLE_PRECISION_MANTISSA,
};
{
"name": "sample-webassemblyjs-ieee754",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-webassemblyjs-ieee754",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@webassemblyjs/ieee754": "1.13.2"
}
},
"node_modules/@webassemblyjs/ieee754": {
"version": "1.13.2",
"resolved": "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.13.2.tgz",
"integrity": "sha512-4LtOzh58S/5lX4ITKxnAK2USuNEvpdVV9AlgGQb8rJDHaLeHciwG4zlGr0j/SNWlr7x3vO1lDEsuePvtcDNCkw==",
"license": "MIT",
"dependencies": {
"@xtuc/ieee754": "^1.2.0"
}
},
"node_modules/@xtuc/ieee754": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz",
"integrity": "sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==",
"license": "BSD-3-Clause"
}
}
}
{
"name": "sample-webassemblyjs-ieee754",
"version": "1.0.0",
"description": "Clean-room sample verifying @webassemblyjs/ieee754 float encoding and decoding",
"main": "index.js",
"license": "MIT-0",
"dependencies": {
"@webassemblyjs/ieee754": "1.13.2"
}
}
{
"schemaVersion": 1,
"goal": "encode and decode 32-bit and 64-bit floating point numbers using IEEE 754",
"kind": "HOW",
"packages": [
"pkg:npm/%40webassemblyjs/ieee754@1.13.2"
],
"symbols": [
"decodeF32",
"decodeF64",
"encodeF32",
"encodeF64"
]
}
import assert from 'node:assert';
import {
encodeF32,
decodeF32,
encodeF64,
decodeF64,
} from '@webassemblyjs/ieee754';
import {
encodeFloat32,
decodeFloat32,
encodeFloat64,
decodeFloat64,
} from '../index.js';
// 1. encodeF32 and decodeF32: standard values
const f32OneBytes = encodeF32(1.0);
assert(Array.isArray(f32OneBytes), 'encodeF32 must return an Array');
assert.strictEqual(f32OneBytes.length, 4, 'encodeF32 must return 4 bytes for single-precision float');
assert.deepStrictEqual(f32OneBytes, [0, 0, 128, 63], 'encodeF32(1.0) must produce [0x00, 0x00, 0x80, 0x3F]');
assert.strictEqual(decodeF32(f32OneBytes), 1.0, 'decodeF32 must round-trip 1.0 correctly');
const f32NegBytes = encodeFloat32(-1.0);
assert.deepStrictEqual(f32NegBytes, [0, 0, 128, 191], 'encodeF32(-1.0) must produce [0x00, 0x00, 0x80, 0xBF]');
assert.strictEqual(decodeFloat32(f32NegBytes), -1.0, 'decodeF32 must decode -1.0 correctly');
const f32ZeroBytes = encodeF32(0.0);
assert.deepStrictEqual(f32ZeroBytes, [0, 0, 0, 0], 'encodeF32(0.0) must produce [0, 0, 0, 0]');
assert.strictEqual(decodeF32(f32ZeroBytes), 0.0, 'decodeF32 must decode 0.0 correctly');
// 2. encodeF32 and decodeF32: special values (Infinity, -Infinity, NaN)
const f32InfBytes = encodeF32(Infinity);
assert.deepStrictEqual(f32InfBytes, [0, 0, 128, 127], 'encodeF32(Infinity) must produce [0, 0, 128, 127]');
assert.strictEqual(decodeF32(f32InfBytes), Infinity, 'decodeF32 must decode Infinity correctly');
const f32NegInfBytes = encodeF32(-Infinity);
assert.deepStrictEqual(f32NegInfBytes, [0, 0, 128, 255], 'encodeF32(-Infinity) must produce [0, 0, 128, 255]');
assert.strictEqual(decodeF32(f32NegInfBytes), -Infinity, 'decodeF32 must decode -Infinity correctly');
const f32NaNBytes = encodeF32(NaN);
assert(Number.isNaN(decodeF32(f32NaNBytes)), 'decodeF32(encodeF32(NaN)) must return NaN');
// 3. encodeF64 and decodeF64: standard values
const f64OneBytes = encodeF64(1.0);
assert(Array.isArray(f64OneBytes), 'encodeF64 must return an Array');
assert.strictEqual(f64OneBytes.length, 8, 'encodeF64 must return 8 bytes for double-precision float');
assert.deepStrictEqual(f64OneBytes, [0, 0, 0, 0, 0, 0, 240, 63], 'encodeF64(1.0) must produce 8-byte little-endian IEEE 754 representation');
assert.strictEqual(decodeF64(f64OneBytes), 1.0, 'decodeF64 must round-trip 1.0 correctly');
const f64NegBytes = encodeFloat64(-1.0);
assert.deepStrictEqual(f64NegBytes, [0, 0, 0, 0, 0, 0, 240, 191], 'encodeF64(-1.0) must produce [0, 0, 0, 0, 0, 0, 240, 191]');
assert.strictEqual(decodeFloat64(f64NegBytes), -1.0, 'decodeFloat64 must decode -1.0 correctly');
const f64PiBytes = encodeF64(Math.PI);
assert.strictEqual(decodeF64(f64PiBytes), Math.PI, 'decodeF64 must round-trip Math.PI double-precision float accurately');
// 4. encodeF64 and decodeF64: special values (Infinity, -Infinity, NaN)
const f64InfBytes = encodeF64(Infinity);
assert.deepStrictEqual(f64InfBytes, [0, 0, 0, 0, 0, 0, 240, 127], 'encodeF64(Infinity) must produce [0, 0, 0, 0, 0, 0, 240, 127]');
assert.strictEqual(decodeF64(f64InfBytes), Infinity, 'decodeF64 must decode Infinity correctly');
const f64NegInfBytes = encodeF64(-Infinity);
assert.deepStrictEqual(f64NegInfBytes, [0, 0, 0, 0, 0, 0, 240, 255], 'encodeF64(-Infinity) must produce [0, 0, 0, 0, 0, 0, 240, 255]');
assert.strictEqual(decodeF64(f64NegInfBytes), -Infinity, 'decodeF64 must decode -Infinity correctly');
const f64NaNBytes = encodeF64(NaN);
assert(Number.isNaN(decodeF64(f64NaNBytes)), 'decodeF64(encodeF64(NaN)) must return NaN');
// 5. decodeF32 and decodeF64 accept Uint8Array byte buffers as input
const uint8F32 = new Uint8Array([0, 0, 128, 63]);
assert.strictEqual(decodeF32(uint8F32), 1.0, 'decodeF32 must accept Uint8Array input');
const uint8F64 = new Uint8Array([0, 0, 0, 0, 0, 0, 240, 63]);
assert.strictEqual(decodeF64(uint8F64), 1.0, 'decodeF64 must accept Uint8Array input');
console.log('All contract assertions passed.');
오리진 시더
익명