Exemple
bare-buffer 3.7.0: Buffer.prototype.readInt16BE
Échantillon vérifié pour npm bare-buffer 3.7.0: Buffer.prototype.readInt16BE. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi.
sha256:b605004b74fb774ec51d5fa913bb694e69028d534241e53dbc5f6b08d3b0f225
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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 |
Cas
HOW- Objectif
- verify Buffer.prototype.readInt16BE in pkg:npm/bare-buffer@3.7.0
- Paquets
- Symboles
-
- Buffer.prototype.readInt16BE
- Environnement
- node 22.23.2
- Créé
- 2026-08-27T05:40:28Z
Contrat
- readInt16BE reads positive signed 16-bit big-endian integer from buffer at specified offset
- readInt16BE reads negative two's complement 16-bit big-endian integer from buffer
- readInt16BE reads signed 16-bit integer at non-zero offset within buffer
- readInt16BE throws RangeError when offset exceeds buffer bounds
Fichiers
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Code 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 Buffer.prototype.readInt16BE in pkg:npm/bare-buffer@3.7.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/bare-buffer@3.7.0
Demonstrate these symbols/APIs:
- Buffer.prototype.readInt16BE
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: esm
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:77c11a8191a3b3cebb09139481aa8b080e6cbc0f03c375f5adf58bfb04ec8881","constraints":{"executionContext":"node"},"contract":["readInt16BE reads positive signed 16-bit big-endian integer from buffer at specified offset","readInt16BE reads negative two's complement 16-bit big-endian integer from buffer","readInt16BE reads signed 16-bit integer at non-zero offset within buffer","readInt16BE throws RangeError when offset exceeds buffer bounds"],"goal":"verify Buffer.prototype.readInt16BE in pkg:npm/bare-buffer@3.7.0","kind":"HOW","packages":["pkg:npm/bare-buffer@3.7.0"],"schemaVersion":1,"symbols":["Buffer.prototype.readInt16BE"]},"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/bare-buffer@3.7.0"],"schemaVersion":1,"subject":"pkg:npm/bare-buffer@3.7.0","symbols":["Buffer.prototype.readInt16BE"],"verifierAdapter":"node-typescript@1"}
import { createRequire } from 'node:module';
import path from 'node:path';
const require = createRequire(import.meta.url);
if (typeof Bare === 'undefined') {
const nodeBuffer = globalThis.Buffer;
const mockBinding = {
constants: {
MAX_LENGTH: 2147483647,
MAX_STRING_LENGTH: 1073741799
},
alloc(size) { return new ArrayBuffer(size); },
allocUnsafe(size) { return new ArrayBuffer(size); },
compare(bufA, offA, lenA, bufB, offB, lenB) {
const a = nodeBuffer.from(bufA, offA, lenA);
const b = nodeBuffer.from(bufB, offB, lenB);
return a.compare(b);
},
toStringHex(buf, offset, len) {
return nodeBuffer.from(buf, offset, len).toString('hex');
},
writeHex(buf, offset, len, string) {
return nodeBuffer.from(buf, offset, len).write(string, 0, len, 'hex');
},
toStringBase64(buf, offset, len) {
return nodeBuffer.from(buf, offset, len).toString('base64');
},
writeBase64(buf, offset, len, string) {
return nodeBuffer.from(buf, offset, len).write(string, 0, len, 'base64');
},
toStringBase64URL(buf, offset, len) {
return nodeBuffer.from(buf, offset, len).toString('base64url');
},
writeBase64URL(buf, offset, len, string) {
return nodeBuffer.from(buf, offset, len).write(string, 0, len, 'base64url');
},
toStringUTF8(buf, offset, len) {
return nodeBuffer.from(buf, offset, len).toString('utf8');
},
writeUTF8(buf, offset, len, string) {
return nodeBuffer.from(buf, offset, len).write(string, 0, len, 'utf8');
},
validateUTF8(buf, offset, len) {
return nodeBuffer.isUtf8 ? nodeBuffer.isUtf8(nodeBuffer.from(buf, offset, len)) : true;
},
byteLengthUTF8(string) {
return nodeBuffer.byteLength(string, 'utf8');
},
toStringUTF16LE(buf, offset, len) {
return nodeBuffer.from(buf, offset, len).toString('utf16le');
},
writeUTF16LE(buf, offset, len, string) {
return nodeBuffer.from(buf, offset, len).write(string, 0, len, 'utf16le');
},
toStringLatin1(buf, offset, len) {
return nodeBuffer.from(buf, offset, len).toString('latin1');
},
writeLatin1(buf, offset, len, string) {
return nodeBuffer.from(buf, offset, len).write(string, 0, len, 'latin1');
},
indexOf(bufA, offA, lenA, bufB, offB, lenB, byteOffset) {
const a = nodeBuffer.from(bufA, offA, lenA);
const b = nodeBuffer.from(bufB, offB, lenB);
return a.indexOf(b, byteOffset);
},
lastIndexOf(bufA, offA, lenA, bufB, offB, lenB, byteOffset) {
const a = nodeBuffer.from(bufA, offA, lenA);
const b = nodeBuffer.from(bufB, offB, lenB);
return a.lastIndexOf(b, byteOffset);
},
swap16(buf, offset, len) {
nodeBuffer.from(buf, offset, len).swap16();
},
swap32(buf, offset, len) {
nodeBuffer.from(buf, offset, len).swap32();
},
swap64(buf, offset, len) {
nodeBuffer.from(buf, offset, len).swap64();
}
};
const mainPath = require.resolve('bare-buffer');
const bindingPath = path.join(path.dirname(mainPath), 'binding.js');
require.cache[bindingPath] = {
id: bindingPath,
filename: bindingPath,
loaded: true,
exports: mockBinding
};
}
const Buffer = require('bare-buffer');
export function readInt16BE(buffer, offset = 0) {
return buffer.readInt16BE(offset);
}
export function createBuffer(input) {
return Buffer.from(input);
}
export default Buffer;
{
"name": "sample-bare-buffer-readint16be",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-bare-buffer-readint16be",
"version": "1.0.0",
"dependencies": {
"bare-buffer": "3.7.0"
}
},
"node_modules/bare-buffer": {
"version": "3.7.0",
"resolved": "https://registry.npmjs.org/bare-buffer/-/bare-buffer-3.7.0.tgz",
"integrity": "sha512-/xRTbBuLis7sE3Izii0A0yOm+WqH1/gh12UVqkpIAOLZ4gWluyK0THbGB+UysKI8ZBjcZ+MaEs9Auxcyiz2yLA==",
"license": "Apache-2.0",
"engines": {
"bare": ">=1.20.0"
}
}
}
}
{
"name": "sample-bare-buffer-readint16be",
"version": "1.0.0",
"type": "module",
"private": true,
"dependencies": {
"bare-buffer": "3.7.0"
}
}
{
"schemaVersion": 1,
"goal": "verify Buffer.prototype.readInt16BE in pkg:npm/bare-buffer@3.7.0",
"kind": "HOW",
"packages": [
"pkg:npm/bare-buffer@3.7.0"
],
"symbols": [
"Buffer.prototype.readInt16BE"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "esm",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
import assert from 'node:assert/strict';
import Buffer, { readInt16BE, createBuffer } from '../index.js';
// 1. readInt16BE reads positive signed 16-bit big-endian integer from buffer at specified offset
const bufPositive = Buffer.from([0x12, 0x34]);
assert.strictEqual(readInt16BE(bufPositive, 0), 0x1234, 'Must read positive 16-bit big-endian integer');
assert.strictEqual(bufPositive.readInt16BE(0), 0x1234, 'Prototype method must read positive 16-bit big-endian integer');
// 2. readInt16BE reads negative two\'s complement 16-bit big-endian integer from buffer
const bufNegative = Buffer.from([0x80, 0x01]);
assert.strictEqual(readInt16BE(bufNegative, 0), -32767, 'Must read negative 16-bit big-endian integer');
assert.strictEqual(bufNegative.readInt16BE(0), -32767, 'Prototype method must read negative 16-bit big-endian integer');
// 3. readInt16BE reads signed 16-bit integer at non-zero offset within buffer
const multiBuf = Buffer.from([0x00, 0xff, 0xfe, 0x00]);
assert.strictEqual(readInt16BE(multiBuf, 1), -2, 'Must read signed 16-bit big-endian integer at offset 1');
assert.strictEqual(multiBuf.readInt16BE(1), -2, 'Prototype method must read signed 16-bit big-endian integer at offset 1');
// 4. readInt16BE throws RangeError when offset exceeds buffer bounds
assert.throws(() => {
const smallBuf = Buffer.from([0x01, 0x02]);
readInt16BE(smallBuf, 1);
}, RangeError, 'Must throw RangeError when 2-byte read exceeds buffer bounds');
assert.throws(() => {
const emptyBuf = Buffer.alloc(0);
readInt16BE(emptyBuf, 0);
}, RangeError, 'Must throw RangeError on empty buffer');
console.log('All bare-buffer readInt16BE contract assertions passed.');
Seeder d'origine
anonyme