Sample
ieee754 1.2.1: write
Verified sample for npm ieee754 1.2.1: write. The contract ran on node 22 · linux debian/x64 · docker and passed: write encodes 32-bit floating point numbers…
sha256:b4cb1c5bf65e4101595678372b594a70d4f4d8b5a6dee6494bf72f40c94815f4
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| 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-06 |
Case
HOW- Goal
- verify ieee754.write in pkg:npm/ieee754@1.2.1
- Packages
- Symbols
-
- ieee754.write
- Environment
- node 22.23.2
- Created
- 2026-09-06T12:19:59Z
Contract
- write encodes 32-bit floating point numbers in little-endian and big-endian byte order
- write encodes 64-bit double-precision floating point numbers matching IEEE 754 representations
- write encodes special values including positive zero, negative zero, infinity, and NaN
- write writes values into target buffers at arbitrary valid offsets without disturbing adjacent bytes
- write operates directly on standard Uint8Array and Node.js Buffer instances
Files
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.js
Source
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 ieee754.write in pkg:npm/ieee754@1.2.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/ieee754@1.2.1
Demonstrate these symbols/APIs:
- ieee754.write
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:98e1513d4ac0764f782b7011021f853fe3d86e9d682da70b8c7fbf0b4bb3dfdb","contract":["write encodes 32-bit floating point numbers in little-endian and big-endian byte order","write encodes 64-bit double-precision floating point numbers matching IEEE 754 representations","write encodes special values including positive zero, negative zero, infinity, and NaN","write writes values into target buffers at arbitrary valid offsets without disturbing adjacent bytes","write operates directly on standard Uint8Array and Node.js Buffer instances"],"goal":"verify ieee754.write in pkg:npm/ieee754@1.2.1","kind":"HOW","packages":["pkg:npm/ieee754@1.2.1"],"schemaVersion":1,"symbols":["ieee754.write"]},"contractCommand":["node","test/contract.js"],"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/ieee754@1.2.1"],"schemaVersion":1,"subject":"pkg:npm/ieee754@1.2.1","symbols":["ieee754.write"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-ieee754-write",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-ieee754-write",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"ieee754": "1.2.1"
}
},
"node_modules/ieee754": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
"integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "BSD-3-Clause"
}
}
}
{
"name": "sample-ieee754-write",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification for ieee754.write",
"main": "src/index.js",
"scripts": {
"test": "node test/contract.js"
},
"dependencies": {
"ieee754": "1.2.1"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify ieee754.write in pkg:npm/ieee754@1.2.1",
"kind": "HOW",
"packages": [
"pkg:npm/ieee754@1.2.1"
],
"symbols": [
"ieee754.write"
]
}
const ieee754 = require('ieee754');
/**
* Writes a 32-bit single-precision floating point number into a buffer.
* @param {Uint8Array|Buffer} buffer Target buffer
* @param {number} value Value to write
* @param {number} [offset=0] Byte offset
* @param {boolean} [isLE=true] True for little-endian, false for big-endian
*/
function writeFloat32(buffer, value, offset = 0, isLE = true) {
ieee754.write(buffer, value, offset, isLE, 23, 4);
}
/**
* Writes a 64-bit double-precision floating point number into a buffer.
* @param {Uint8Array|Buffer} buffer Target buffer
* @param {number} value Value to write
* @param {number} [offset=0] Byte offset
* @param {boolean} [isLE=true] True for little-endian, false for big-endian
*/
function writeFloat64(buffer, value, offset = 0, isLE = true) {
ieee754.write(buffer, value, offset, isLE, 52, 8);
}
/**
* Allocates a new buffer and encodes a floating point number into it.
* @param {number} value Floating point number
* @param {'single'|'double'} [precision='double'] Precision mode
* @param {boolean} [isLE=true] Endianness
* @returns {Buffer} Encoded buffer
*/
function encodeFloatingPoint(value, precision = 'double', isLE = true) {
const isSingle = precision === 'single';
const size = isSingle ? 4 : 8;
const mLen = isSingle ? 23 : 52;
const buffer = Buffer.alloc(size);
ieee754.write(buffer, value, 0, isLE, mLen, size);
return buffer;
}
module.exports = {
ieee754,
write: ieee754.write,
read: ieee754.read,
writeFloat32,
writeFloat64,
encodeFloatingPoint,
};
const assert = require('node:assert');
const {
ieee754,
write,
read,
writeFloat32,
writeFloat64,
encodeFloatingPoint,
} = require('../src/index.js');
// 1. write encodes 32-bit floating point numbers in little-endian and big-endian byte order
{
const bufLE = Buffer.alloc(4);
const bufBE = Buffer.alloc(4);
write(bufLE, 42.5, 0, true, 23, 4);
write(bufBE, 42.5, 0, false, 23, 4);
const expectedBE = Buffer.from([0x42, 0x2a, 0x00, 0x00]);
const expectedLE = Buffer.from([0x00, 0x00, 0x2a, 0x42]);
assert(bufLE.equals(expectedLE), '32-bit LE mismatch');
assert(bufBE.equals(expectedBE), '32-bit BE mismatch');
const refLE = Buffer.alloc(4);
refLE.writeFloatLE(42.5, 0);
assert(bufLE.equals(refLE), '32-bit LE ref mismatch');
const helperBuf = Buffer.alloc(4);
writeFloat32(helperBuf, 42.5, 0, true);
assert(helperBuf.equals(expectedLE), 'writeFloat32 LE mismatch');
}
// 2. write encodes 64-bit double-precision floating point numbers matching IEEE 754 representations
{
const testValues = [1.0, -0.5, Math.PI, 12345.6789];
for (const v of testValues) {
const bufLE = Buffer.alloc(8);
const bufBE = Buffer.alloc(8);
write(bufLE, v, 0, true, 52, 8);
write(bufBE, v, 0, false, 52, 8);
const refLE = Buffer.alloc(8);
const refBE = Buffer.alloc(8);
refLE.writeDoubleLE(v, 0);
refBE.writeDoubleBE(v, 0);
assert(bufLE.equals(refLE), `64-bit LE ref mismatch for ${v}`);
assert(bufBE.equals(refBE), `64-bit BE ref mismatch for ${v}`);
const encoded = encodeFloatingPoint(v, 'double', true);
assert(encoded.equals(refLE), `encodeFloatingPoint mismatch for ${v}`);
}
}
// 3. write encodes special values including positive zero, negative zero, infinity, and NaN
{
const posZero = Buffer.alloc(8);
const negZero = Buffer.alloc(8);
write(posZero, 0, 0, false, 52, 8);
write(negZero, -0, 0, false, 52, 8);
assert.strictEqual(posZero[0] & 0x80, 0x00, '+0 must not have sign bit set');
assert.strictEqual(negZero[0] & 0x80, 0x80, '-0 must have sign bit set');
const infBuf = Buffer.alloc(8);
const negInfBuf = Buffer.alloc(8);
write(infBuf, Infinity, 0, false, 52, 8);
write(negInfBuf, -Infinity, 0, false, 52, 8);
assert.strictEqual(read(infBuf, 0, false, 52, 8), Infinity);
assert.strictEqual(read(negInfBuf, 0, false, 52, 8), -Infinity);
const nanBuf = Buffer.alloc(8);
write(nanBuf, NaN, 0, true, 52, 8);
assert(Number.isNaN(read(nanBuf, 0, true, 52, 8)), 'NaN must decode to NaN');
}
// 4. write writes values into target buffers at arbitrary valid offsets without disturbing adjacent bytes
{
const sentinel = 0xee;
const buf = Buffer.alloc(16, sentinel);
write(buf, 42.5, 2, true, 23, 4);
assert.strictEqual(buf[0], sentinel);
assert.strictEqual(buf[1], sentinel);
assert.strictEqual(buf[6], sentinel);
assert.strictEqual(buf[15], sentinel);
const decoded = read(buf, 2, true, 23, 4);
assert.strictEqual(decoded, 42.5);
}
// 5. write operates directly on standard Uint8Array and Node.js Buffer instances
{
const uint8 = new Uint8Array(8);
write(uint8, 987.654, 0, true, 52, 8);
const view = new DataView(uint8.buffer, uint8.byteOffset, uint8.byteLength);
assert.strictEqual(view.getFloat64(0, true), 987.654);
}
console.log('All contract assertions passed successfully.');
Origin Seeder
anonymous