{"id":10598,"library":"buffer-crc32","title":"Buffer CRC32","description":"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.","status":"abandoned","version":"1.0.0","language":"javascript","source_language":"en","source_url":"git://github.com/brianloveswords/buffer-crc32","tags":["javascript","typescript"],"install":[{"cmd":"npm install buffer-crc32","lang":"bash","label":"npm"},{"cmd":"yarn add buffer-crc32","lang":"bash","label":"yarn"},{"cmd":"pnpm add buffer-crc32","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The library is a default export. For CommonJS, use `require('buffer-crc32')`. For TypeScript, types are shipped.","wrong":"import { crc32 } from 'buffer-crc32';","symbol":"crc32 (default export)","correct":"import crc32 from 'buffer-crc32';"},{"note":"This is the primary way the library was designed to be consumed.","symbol":"crc32 (CommonJS)","correct":"const crc32 = require('buffer-crc32');"}],"quickstart":{"code":"import crc32 from 'buffer-crc32';\n\n// Works with Buffers\nconst buf = Buffer.from([0x00, 0x73, 0x75, 0x70, 0x20, 0x62, 0x72, 0x6f, 0x00]);\nconsole.log('Buffer CRC32:', crc32(buf).toString('hex'));\n\n// Convenience methods for signed or unsigned ints\nconsole.log('Signed CRC32:', crc32.signed(buf));\nconsole.log('Unsigned CRC32:', crc32.unsigned(buf));\n\n// Automatically casts strings to buffers, supporting foreign characters\nconsole.log('String CRC32 (自動販売機):', crc32('自動販売機').toString('hex'));\n\n// Append mode for incremental calculation\nlet partialCrc = crc32('hey');\npartialCrc = crc32(' ', partialCrc);\npartialCrc = crc32('sup', partialCrc);\npartialCrc = crc32(' ', partialCrc);\nconst finalCrc = crc32('bros', partialCrc);\nconsole.log('Appended CRC32:', finalCrc.toString('hex'));","lang":"typescript","description":"Demonstrates basic usage with buffers and strings, showing signed/unsigned integer conversion and the append mode for incremental CRC calculations."},"warnings":[{"fix":"Consider testing thoroughly in your target Node.js environment or migrating to a more actively maintained CRC32 library for long-term projects.","message":"The 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.","severity":"breaking","affected_versions":"<=1.0.0"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"Primarily 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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Change `import { crc32 } from 'buffer-crc32';` to `import crc32 from 'buffer-crc32';`.","cause":"Attempting to import a default export as a named export in an ESM context.","error":"TypeError: crc32 is not a function"},{"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`.","cause":"Using `require('buffer-crc32')` in a Node.js project configured with `\"type\": \"module\"` in its `package.json`.","error":"ERR_REQUIRE_ESM (or similar errors related to 'require' in ESM modules)"}],"ecosystem":"npm"}