CodeSampleX

샘플

chromium-pickle-js 0.2.0: createEmpty, createFromBuffer

검증된 샘플 — npm chromium-pickle-js 0.2.0: createEmpty, createFromBuffer. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다.

sha256:258c307b68344ed1f201fa4a1d3acd6c6b0dd7ddfdfbafca4e3bbfb2ca0e8951

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
2
빌드한 서명 키
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-26
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-08

케이스

HOW
목표
verify pkg:npm/chromium-pickle-js@0.2.0
패키지
심벌
  • createEmpty
  • createFromBuffer
환경
node 22.23.2
생성일
2026-08-26T09:11:46Z

컨트랙트

  1. createEmpty returns a new Pickle instance that can write bool, int, uint32, float, double, and string primitives
  2. Pickle.toBuffer returns a Buffer containing the 4-byte payload size header followed by 4-byte aligned payload data
  3. createFromBuffer initializes a Pickle instance from an existing Buffer for reading with PickleIterator
  4. PickleIterator sequentially reads bool, int, uint32, float, double, and string values in matching write order
  5. Pickle.writeInt64 and Pickle.writeUInt64 throw TypeError in Node.js because 64-bit buffer write methods are undefined on Buffer.prototype
  6. PickleIterator throws an Error when attempting to read past the payload buffer end

파일

  • 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/chromium-pickle-js@0.2.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/chromium-pickle-js@0.2.0
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - 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.
csx.json
{"case":{"caseId":"case:sha256:2a8593e5836b43efa8f92fa1b859ef2940f790b35ad5147c877cd3218bee6c31","constraints":{"executionContext":"node"},"contract":["createEmpty returns a new Pickle instance that can write bool, int, uint32, float, double, and string primitives","Pickle.toBuffer returns a Buffer containing the 4-byte payload size header followed by 4-byte aligned payload data","createFromBuffer initializes a Pickle instance from an existing Buffer for reading with PickleIterator","PickleIterator sequentially reads bool, int, uint32, float, double, and string values in matching write order","Pickle.writeInt64 and Pickle.writeUInt64 throw TypeError in Node.js because 64-bit buffer write methods are undefined on Buffer.prototype","PickleIterator throws an Error when attempting to read past the payload buffer end"],"goal":"verify pkg:npm/chromium-pickle-js@0.2.0","kind":"HOW","packages":["pkg:npm/chromium-pickle-js@0.2.0"],"schemaVersion":1,"symbols":["createEmpty","createFromBuffer"]},"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/chromium-pickle-js@0.2.0"],"schemaVersion":1,"subject":"pkg:npm/chromium-pickle-js@0.2.0","symbols":["createEmpty","createFromBuffer"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-chromium-pickle-js",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-chromium-pickle-js",
      "version": "1.0.0",
      "dependencies": {
        "chromium-pickle-js": "0.2.0"
      }
    },
    "node_modules/chromium-pickle-js": {
      "version": "0.2.0",
      "resolved": "https://registry.npmjs.org/chromium-pickle-js/-/chromium-pickle-js-0.2.0.tgz",
      "integrity": "sha512-1R5Fho+jBq0DDydt+/vHWj5KJNJCKdARKOCwZUen84I5BreWoLqRLANH1U87eJy1tiASPtMnGqJJq0ZsLoRPOw==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-chromium-pickle-js",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "chromium-pickle-js": "0.2.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/chromium-pickle-js@0.2.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/chromium-pickle-js@0.2.0"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.mjs
import pickle from 'chromium-pickle-js';

const { createEmpty, createFromBuffer } = pickle;

/**
 * Creates an empty Pickle instance for writing binary data.
 * @returns {object}
 */
export function createEmptyPickle() {
  return createEmpty();
}

/**
 * Creates a Pickle instance from an existing Buffer for reading.
 * @param {Buffer} buffer
 * @returns {object}
 */
export function createPickleFromBuffer(buffer) {
  return createFromBuffer(buffer);
}

export { createEmpty, createFromBuffer };
test/contract.mjs
import assert from 'node:assert/strict';
import {
  createEmpty,
  createFromBuffer,
  createEmptyPickle,
  createPickleFromBuffer,
} from '../src/index.mjs';

// 1. createEmpty returns a new Pickle instance that can write bool, int, uint32, float, double, and string primitives
{
  const p = createEmptyPickle();
  assert.equal(p.writeBool(true), true);
  assert.equal(p.writeBool(false), true);
  assert.equal(p.writeInt(-12345), true);
  assert.equal(p.writeUInt32(54321), true);
  assert.equal(p.writeFloat(1.5), true);
  assert.equal(p.writeDouble(3.141592653589793), true);
  assert.equal(p.writeString('chromium-pickle-sample'), true);
}

// 2. Pickle.toBuffer returns a Buffer containing the 4-byte payload size header followed by 4-byte aligned payload data
{
  const p = createEmpty();
  assert.equal(p.writeInt(42), true);
  const buf = p.toBuffer();
  assert.ok(Buffer.isBuffer(buf));
  const payloadSize = buf.readUInt32LE(0);
  assert.equal(payloadSize, 4);
  assert.equal(buf.length, 8);
  assert.equal(buf.readInt32LE(4), 42);
}

// 3. createFromBuffer initializes a Pickle instance from an existing Buffer for reading with PickleIterator
{
  const pWrite = createEmpty();
  assert.equal(pWrite.writeString('read-test'), true);
  const buf = pWrite.toBuffer();

  const pRead = createPickleFromBuffer(buf);
  const it = pRead.createIterator();
  assert.equal(it.readString(), 'read-test');
}

// 4. PickleIterator sequentially reads bool, int, uint32, float, double, and string values in matching write order
{
  const p = createEmpty();
  assert.equal(p.writeBool(true), true);
  assert.equal(p.writeBool(false), true);
  assert.equal(p.writeInt(-9876), true);
  assert.equal(p.writeUInt32(65432), true);
  assert.equal(p.writeFloat(2.5), true);
  assert.equal(p.writeDouble(2.718281828459045), true);
  assert.equal(p.writeString('sequential-test'), true);

  const buf = p.toBuffer();
  const pRead = createFromBuffer(buf);
  const it = pRead.createIterator();

  assert.equal(it.readBool(), true);
  assert.equal(it.readBool(), false);
  assert.equal(it.readInt(), -9876);
  assert.equal(it.readUInt32(), 65432);
  assert.equal(it.readFloat(), 2.5);
  assert.equal(it.readDouble(), 2.718281828459045);
  assert.equal(it.readString(), 'sequential-test');
}

// 5. Pickle.writeInt64 and Pickle.writeUInt64 throw TypeError in Node.js because 64-bit buffer write methods are undefined on Buffer.prototype
{
  const p = createEmpty();
  assert.throws(
    () => {
      p.writeInt64(100);
    },
    {
      name: 'TypeError',
    }
  );
  assert.throws(
    () => {
      p.writeUInt64(100);
    },
    {
      name: 'TypeError',
    }
  );
}

// 6. PickleIterator throws an Error when attempting to read past the payload buffer end
{
  const p = createEmpty();
  assert.equal(p.writeInt(100), true);
  const buf = p.toBuffer();

  const pRead = createFromBuffer(buf);
  const it = pRead.createIterator();
  assert.equal(it.readInt(), 100);

  assert.throws(
    () => {
      it.readInt();
    },
    {
      name: 'Error',
      message: /Failed to read data with length of/,
    }
  );
}

console.log('Contract assertions passed.');

오리진 시더

익명