Registry / serialization / buffer-crc32

buffer-crc32

JSON →
library1.0.0jsnpmunverified

buffer-crc32 provides a pure JavaScript implementation of the CRC32 algorithm, designed to work seamlessly with binary data and various character encodings by internally casting strings to Buffers. It offers methods to compute the CRC32 checksum and retrieve results as raw Buffer objects, signed integers, or unsigned integers. The library also supports an "append mode," allowing for incremental CRC calculations across multiple data chunks. Currently at version 1.0.0, this package has not seen updates in approximately seven years, suggesting it is stable but effectively abandoned. It requires Node.js version 8.0.0 or higher, potentially posing compatibility challenges for very modern environments that are primarily ESM-based or require newer Node.js features. Its key differentiator is its self-contained, pure JavaScript nature, avoiding native module dependencies.

npm install buffer-crc32
INSTALL
IMPORT
SIG · BUFFER-CRC32
B
buffer-crc32
serializationjavascriptv1.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

crc32 (default export)
import crc32 from 'buffer-crc32';
import { crc32 } from 'buffer-crc32';
The library is a default export. For CommonJS, use `require('buffer-crc32')`. For TypeScript, types are shipped.
crc32 (CommonJS)
const crc32 = require('buffer-crc32');
This is the primary way the library was designed to be consumed.

Demonstrates basic usage with buffers and strings, showing signed/unsigned integer conversion and the append mode for incremental CRC calculations.

import crc32 from 'buffer-crc32'; // Works with Buffers const buf = Buffer.from([0x00, 0x73, 0x75, 0x70, 0x20, 0x62, 0x72, 0x6f, 0x00]); console.log('Buffer CRC32:', crc32(buf).toString('hex')); // Convenience methods for signed or unsigned ints console.log('Signed CRC32:', crc32.signed(buf)); console.log('Unsigned CRC32:', crc32.unsigned(buf)); // Automatically casts strings to buffers, supporting foreign characters console.log('String CRC32 (自動販売機):', crc32('自動販売機').toString('hex')); // Append mode for incremental calculation let partialCrc = crc32('hey'); partialCrc = crc32(' ', partialCrc); partialCrc = crc32('sup', partialCrc); partialCrc = crc32(' ', partialCrc); const finalCrc = crc32('bros', partialCrc); console.log('Appended CRC32:', finalCrc.toString('hex'));
Debug
Known issues
breakingThe package requires Node.js >= 8.0.0. While it might still run on much newer Node.js versions, it has not been tested or updated for modern environments, including potential breaking changes in Node.js APIs or internal Buffer handling since its last release.
fix
Consider testing thoroughly in your target Node.js environment or migrating to a more actively maintained CRC32 library for long-term projects.
affects: <=1.0.0
gotchaThe package is effectively abandoned, with its last update approximately seven years ago. This means no new features, bug fixes, or security patches will be provided. Relying on it in new projects carries a maintenance risk.
fix
Evaluate if an unmaintained library meets your project's security and stability requirements. Consider alternative, actively maintained CRC32 libraries if continuous support is critical.
affects: >=1.0.0
gotchaPrimarily designed for CommonJS environments. While it ships TypeScript types, direct ESM usage (e.g., in a 'type: module' project) might require specific import syntax or bundler configuration to resolve the default export correctly.
fix
In ESM, use `import crc32 from 'buffer-crc32';`. If encountering issues, ensure your bundler (Webpack, Rollup, esbuild) or Node.js version handles CommonJS interoperability correctly. For strict TypeScript CommonJS integration, `import crc32 = require('buffer-crc32');` might be an option.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: crc32 is not a function
Attempting to import a default export as a named export in an ESM context.
fix
Change `import { crc32 } from 'buffer-crc32';` to `import crc32 from 'buffer-crc32';`.
ERR_REQUIRE_ESM (or similar errors related to 'require' in ESM modules)
Using `require('buffer-crc32')` in a Node.js project configured with `"type": "module"` in its `package.json`.
fix
Refactor to use ESM import syntax: `import crc32 from 'buffer-crc32';`. If that causes issues with bundlers or runtime, ensure your build configuration supports CommonJS interoperability or use a dynamic import `import('buffer-crc32').then(m => m.default)`. Alternatively, if possible, set `"type": "commonjs"` in your `package.json`.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
14
OpenAI (training)
1
Resources
buffer-crc32 — npm install buffer-crc32 · libregistry