murmur-32 provides a JavaScript implementation of the MurmurHash3 algorithm for x86 32-bit systems. It's a non-cryptographic hash function known for its speed and good distribution properties, often used in hash tables, Bloom filters, and other data structures where collision resistance is less critical than performance. The current stable version is 1.0.0, released in July 2021. The package maintains a relatively slow release cadence, primarily focusing on stability and adherence to modern JavaScript standards. A key differentiator is its straightforward API for hashing both `ArrayBuffer` and string inputs, with strings being UTF-8 encoded by default since version 0.2.0, providing predictable cross-platform behavior.
npm install murmur-32Verified import paths — ran on the pinned version, not inferred.
Demonstrates how to compute a 32-bit MurmurHash3 for both string and ArrayBuffer inputs, and how to extract the integer hash value from the returned ArrayBuffer.
Update your import statements from `const murmur32 = require('murmur-32')` to `import murmur32 from 'murmur-32'`. Ensure your Node.js environment is at least 12.20.0, 14.13.1, or 16.0.0+.If you need to maintain the exact hash values produced by older versions for string inputs, use the `array-buffer-from-string` package to explicitly convert your strings to UCS-2 encoded ArrayBuffers before passing them to `murmur32`. Otherwise, update any stored hash values or tests to reflect the new UTF-8 encoding behavior.
Change your import statement to `import murmur32 from 'murmur-32';`.
If you require the previous UCS-2 encoding behavior, pre-process your string inputs using `array-buffer-from-string`: `import arrayBufferFromString from 'array-buffer-from-string'; murmur32(arrayBufferFromString(yourString, 'ucs2'))`. Otherwise, update your application to expect UTF-8 encoded hash outputs.