{"library":"murmur-32","title":"MurmurHash3 32-bit","description":"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.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install murmur-32"],"cli":null},"imports":["import murmur32 from 'murmur-32'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import murmur32 from 'murmur-32';\n\n// Example 1: Hashing a string\nconst stringKey = 'hello world';\nconst stringHashBuffer = murmur32(stringKey);\nconst stringHashValue = new DataView(stringHashBuffer).getUint32(0, true); // Get 32-bit integer, little-endian\n\nconsole.log(`Hash for \"${stringKey}\": ${stringHashValue.toString(16).padStart(8, '0')}`);\n\n// Example 2: Hashing an ArrayBuffer\nconst arrayBufferKey = new TextEncoder().encode('another example').buffer;\nconst arrayBufferHashBuffer = murmur32(arrayBufferKey);\nconst arrayBufferHashValue = new DataView(arrayBufferHashBuffer).getUint32(0, true);\n\nconsole.log(`Hash for \"another example\" (ArrayBuffer): ${arrayBufferHashValue.toString(16).padStart(8, '0')}`);\n\n// The function returns an ArrayBuffer of 4 bytes (32-bit hash).\n// You often need to convert it to an integer for practical use.","lang":"javascript","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}