CodeSampleX

Sample

crc32-stream 4.0.3: DeflateCRC32Stream

Verified sample for npm crc32-stream 4.0.3: DeflateCRC32Stream. The contract ran on node 22 · linux debian/x64 · docker and passed.

sha256:200b6201595170658ef0435b5f41a4cb6bb9248f9c04f4c21f6045879a4ff7e7

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 linux 24 · ubuntu · glibc 2.39 x64 npm

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 crc32-stream.DeflateCRC32Stream in pkg:npm/crc32-stream@4.0.3
Packages
Symbols
  • crc32-stream.DeflateCRC32Stream
Created
2026-09-06T14:50:25Z

Contract

  1. assert DeflateCRC32Stream compresses stream data reconstructible via raw inflate
  2. assert DeflateCRC32Stream calculates expected 32-bit CRC checksum across multiple stream chunks
  3. assert DeflateCRC32Stream size returns raw uncompressed byte length by default
  4. assert DeflateCRC32Stream size returns compressed byte length when compressed is true
  5. assert DeflateCRC32Stream hex returns uppercase 8-character hex string of CRC32 checksum
  6. assert DeflateCRC32Stream digest returns 4-byte Buffer or hex string matching calculated checksum
  7. assert DeflateCRC32Stream handles empty input stream producing zero checksum and zero size

Files

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

Download the source artifact (tar.gz)

Source

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 crc32-stream.DeflateCRC32Stream in pkg:npm/crc32-stream@4.0.3
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/crc32-stream@4.0.3
Demonstrate these symbols/APIs:
  - crc32-stream.DeflateCRC32Stream

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:e3d08d2d73133fea34fb8558c7d2c426ab8b60e933e2c7f864d397848ea714ec","contract":["assert DeflateCRC32Stream compresses stream data reconstructible via raw inflate","assert DeflateCRC32Stream calculates expected 32-bit CRC checksum across multiple stream chunks","assert DeflateCRC32Stream size returns raw uncompressed byte length by default","assert DeflateCRC32Stream size returns compressed byte length when compressed is true","assert DeflateCRC32Stream hex returns uppercase 8-character hex string of CRC32 checksum","assert DeflateCRC32Stream digest returns 4-byte Buffer or hex string matching calculated checksum","assert DeflateCRC32Stream handles empty input stream producing zero checksum and zero size"],"goal":"verify crc32-stream.DeflateCRC32Stream in pkg:npm/crc32-stream@4.0.3","kind":"HOW","packages":["pkg:npm/crc32-stream@4.0.3"],"schemaVersion":1,"symbols":["crc32-stream.DeflateCRC32Stream"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/crc32-stream@4.0.3"],"schemaVersion":1,"subject":"pkg:npm/crc32-stream@4.0.3","symbols":["crc32-stream.DeflateCRC32Stream"],"verifierAdapter":"node-typescript@1"}
index.mjs
import crc32Pkg from 'crc32-stream';

const { CRC32Stream, DeflateCRC32Stream } = crc32Pkg;

/**
 * Creates a new DeflateCRC32Stream instance.
 * @param {object} [options]
 * @returns {DeflateCRC32Stream}
 */
export function createDeflateCRC32Stream(options) {
  return new DeflateCRC32Stream(options);
}

export { CRC32Stream, DeflateCRC32Stream };
export default DeflateCRC32Stream;
package-lock.json
{
  "name": "sample-deflate-crc32-stream-verify",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-deflate-crc32-stream-verify",
      "version": "1.0.0",
      "dependencies": {
        "crc32-stream": "4.0.3"
      }
    },
    "node_modules/crc-32": {
      "version": "1.2.2",
      "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz",
      "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==",
      "license": "Apache-2.0",
      "bin": {
        "crc32": "bin/crc32.njs"
      },
      "engines": {
        "node": ">=0.8"
      }
    },
    "node_modules/crc32-stream": {
      "version": "4.0.3",
      "resolved": "https://registry.npmjs.org/crc32-stream/-/crc32-stream-4.0.3.tgz",
      "integrity": "sha512-NT7w2JVU7DFroFdYkeq8cywxrgjPHWkdX1wjpRQXPX5Asews3tA+Ght6lddQO5Mkumffp3X7GEqku3epj2toIw==",
      "license": "MIT",
      "dependencies": {
        "crc-32": "^1.2.0",
        "readable-stream": "^3.4.0"
      },
      "engines": {
        "node": ">= 10"
      }
    },
    "node_modules/inherits": {
      "version": "2.0.4",
      "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
      "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
      "license": "ISC"
    },
    "node_modules/readable-stream": {
      "version": "3.6.2",
      "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
      "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==",
      "license": "MIT",
      "dependencies": {
        "inherits": "^2.0.3",
        "string_decoder": "^1.1.1",
        "util-deprecate": "^1.0.1"
      },
      "engines": {
        "node": ">= 6"
      }
    },
    "node_modules/safe-buffer": {
      "version": "5.2.1",
      "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
      "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
      "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": "MIT"
    },
    "node_modules/string_decoder": {
      "version": "1.3.0",
      "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
      "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
      "license": "MIT",
      "dependencies": {
        "safe-buffer": "~5.2.0"
      }
    },
    "node_modules/util-deprecate": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
      "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-deflate-crc32-stream-verify",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "dependencies": {
    "crc32-stream": "4.0.3"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify crc32-stream.DeflateCRC32Stream in pkg:npm/crc32-stream@4.0.3",
  "kind": "HOW",
  "packages": [
    "pkg:npm/crc32-stream@4.0.3"
  ],
  "symbols": [
    "crc32-stream.DeflateCRC32Stream"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import { Readable } from 'node:stream';
import zlib from 'node:zlib';
import DeflateCRC32Stream, { createDeflateCRC32Stream } from '../index.mjs';

// 1. assert DeflateCRC32Stream compresses stream data reconstructible via raw inflate
{
  const inputBuffer = Buffer.from('The quick brown fox jumps over the lazy dog repeatedly to ensure compression happens');
  const stream = Readable.from([inputBuffer]);
  const deflateStream = createDeflateCRC32Stream();

  const compressedChunks = [];
  deflateStream.on('data', chunk => compressedChunks.push(chunk));

  await new Promise((resolve, reject) => {
    deflateStream.on('end', resolve);
    deflateStream.on('error', reject);
    stream.pipe(deflateStream);
  });

  const compressed = Buffer.concat(compressedChunks);
  const decompressed = zlib.inflateRawSync(compressed);
  assert.strictEqual(decompressed.toString('utf8'), inputBuffer.toString('utf8'));
}

// 2. assert DeflateCRC32Stream calculates expected 32-bit CRC checksum across multiple stream chunks
{
  const chunks = ['123', '456', '789'];
  const stream = Readable.from(chunks);
  const deflateStream = new DeflateCRC32Stream();

  deflateStream.resume();

  await new Promise((resolve, reject) => {
    deflateStream.on('end', resolve);
    deflateStream.on('error', reject);
    stream.pipe(deflateStream);
  });

  assert.strictEqual(deflateStream.hex(), 'CBF43926');
  assert.strictEqual(deflateStream.digest('hex'), 'cbf43926');
}

// 3. assert DeflateCRC32Stream size returns raw uncompressed byte length by default
{
  const part1 = Buffer.from('hello ');
  const part2 = Buffer.from('world!');
  const stream = Readable.from([part1, part2]);
  const deflateStream = new DeflateCRC32Stream();

  deflateStream.resume();

  await new Promise((resolve, reject) => {
    deflateStream.on('end', resolve);
    deflateStream.on('error', reject);
    stream.pipe(deflateStream);
  });

  assert.strictEqual(deflateStream.size(), 12);
  assert.strictEqual(deflateStream.size(false), 12);
  assert.strictEqual(deflateStream.rawSize, 12);
}

// 4. assert DeflateCRC32Stream size returns compressed byte length when compressed is true
{
  const input = Buffer.from('hello world repeated repeated repeated repeated repeated repeated');
  const stream = Readable.from([input]);
  const deflateStream = new DeflateCRC32Stream();

  deflateStream.resume();

  await new Promise((resolve, reject) => {
    deflateStream.on('end', resolve);
    deflateStream.on('error', reject);
    stream.pipe(deflateStream);
  });

  assert.strictEqual(deflateStream.size(true), deflateStream.compressedSize);
  assert.ok(deflateStream.compressedSize > 0);
  assert.ok(deflateStream.compressedSize < deflateStream.rawSize);
}

// 5. assert DeflateCRC32Stream hex returns uppercase 8-character hex string of CRC32 checksum
{
  const input = Buffer.from('hello world');
  const stream = Readable.from([input]);
  const deflateStream = new DeflateCRC32Stream();

  deflateStream.resume();

  await new Promise((resolve, reject) => {
    deflateStream.on('end', resolve);
    deflateStream.on('error', reject);
    stream.pipe(deflateStream);
  });

  const hexValue = deflateStream.hex();
  assert.strictEqual(typeof hexValue, 'string');
  assert.strictEqual(hexValue.length, 8);
  assert.strictEqual(hexValue, '0D4A1185');
}

// 6. assert DeflateCRC32Stream digest returns 4-byte Buffer or hex string matching calculated checksum
{
  const input = Buffer.from('node-deflate-crc32-stream verification');
  const stream = Readable.from([input]);
  const deflateStream = new DeflateCRC32Stream();

  deflateStream.resume();

  await new Promise((resolve, reject) => {
    deflateStream.on('end', resolve);
    deflateStream.on('error', reject);
    stream.pipe(deflateStream);
  });

  const bufferDigest = deflateStream.digest();
  assert.ok(Buffer.isBuffer(bufferDigest));
  assert.strictEqual(bufferDigest.length, 4);

  const hexDigest = deflateStream.digest('hex');
  assert.strictEqual(hexDigest, bufferDigest.toString('hex'));
}

// 7. assert DeflateCRC32Stream handles empty input stream producing zero checksum and zero size
{
  const stream = Readable.from([]);
  const deflateStream = new DeflateCRC32Stream();

  deflateStream.resume();

  await new Promise((resolve, reject) => {
    deflateStream.on('end', resolve);
    deflateStream.on('error', reject);
    stream.pipe(deflateStream);
  });

  assert.strictEqual(deflateStream.size(), 0);
  assert.strictEqual(deflateStream.size(false), 0);
  assert.strictEqual(deflateStream.rawSize, 0);
  assert.strictEqual(deflateStream.hex(), '00000000');
  assert.strictEqual(deflateStream.digest('hex'), '00000000');
}

console.log('All DeflateCRC32Stream contract assertions passed.');

Origin Seeder

anonymous