| # These are supported funding model platforms | ||
| github: perezd | ||
| patreon: # Replace with a single Patreon username | ||
| open_collective: # Replace with a single Open Collective username | ||
| ko_fi: # Replace with a single Ko-fi username | ||
| tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | ||
| community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | ||
| liberapay: # Replace with a single Liberapay username | ||
| issuehunt: # Replace with a single IssueHunt username | ||
| otechie: # Replace with a single Otechie username | ||
| custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] |
| export = murmurhash; | ||
| /** | ||
| * JS Implementation of MurmurHash3 (r136) (as of May 20, 2011) | ||
| * | ||
| * @param key - ASCII only | ||
| * @param seed - (optional) positive integer | ||
| * @returns 32-bit positive integer hash | ||
| */ | ||
| declare function murmurhash( | ||
| key: string | Uint8Array, | ||
| seed?: number | ||
| ): number; | ||
| declare namespace murmurhash { | ||
| /** | ||
| * JS Implementation of MurmurHash3 (r136) (as of May 20, 2011) | ||
| * | ||
| * @param key - ASCII only | ||
| * @param seed - (optional) positive integer | ||
| * @returns 32-bit positive integer hash | ||
| */ | ||
| function v3(key: string | Uint8Array, seed?: number): number; | ||
| /** | ||
| * JS Implementation of MurmurHash2 | ||
| * | ||
| * @param str - ASCII only | ||
| * @param seed - (optional) positive integer | ||
| * @returns 32-bit positive integer hash | ||
| */ | ||
| function v2(str: string | Uint8Array, seed?: number): number; | ||
| } |
+13
| const { v3 } = require("./murmurhash"); | ||
| const fromStr = v3("abc"); | ||
| const fromBuffer = v3(Buffer.from("abc")); | ||
| const fromUnit8Array = v3(new Uint8Array([97, 98, 99])); | ||
| if ( | ||
| fromStr !== fromBuffer || | ||
| fromBuffer !== fromUnit8Array || | ||
| fromStr !== 3017643002 | ||
| ) { | ||
| throw new Error(`Wrong output`); | ||
| } |
+5
-9
| (function(){ | ||
| var _global = this; | ||
| const createBuffer = | ||
| Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow | ||
| ? Buffer.from | ||
| : // support for Node < 5.10 | ||
| val => new Buffer(val); | ||
| const createBuffer = (val) => new TextEncoder().encode(val) | ||
@@ -18,3 +14,3 @@ /** | ||
| * | ||
| * @param {Buffer} str ASCII only | ||
| * @param {Uint8Array | string} str ASCII only | ||
| * @param {number} seed Positive integer only | ||
@@ -24,3 +20,3 @@ * @return {number} 32-bit positive integer hash | ||
| function MurmurHashV2(str, seed) { | ||
| if (!Buffer.isBuffer(str)) str = createBuffer(str); | ||
| if (typeof str === 'string') str = createBuffer(str); | ||
| var | ||
@@ -71,3 +67,3 @@ l = str.length, | ||
| * | ||
| * @param {Buffer} key ASCII only | ||
| * @param {Uint8Array | string} key ASCII only | ||
| * @param {number} seed Positive integer only | ||
@@ -77,3 +73,3 @@ * @return {number} 32-bit positive integer hash | ||
| function MurmurHashV3(key, seed) { | ||
| if (!Buffer.isBuffer(key)) key = createBuffer(key); | ||
| if (typeof key === 'string') key = createBuffer(key); | ||
@@ -80,0 +76,0 @@ var remainder, bytes, h1, h1b, c1, c1b, c2, c2b, k1, i; |
+1
-1
| { | ||
| "name" : "murmurhash", | ||
| "version" : "1.0.0", | ||
| "version" : "2.0.0", | ||
| "description" : "A Node.js module for the optimized JavaScript implementation of the MurmurHash algorithms.", | ||
@@ -5,0 +5,0 @@ "author": { |
+2
-0
@@ -22,2 +22,4 @@ # node-murmurhash | ||
| To support older browsers you need to use TextEncoder [polyfill](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder#Polyfill) | ||
| or in node.js | ||
@@ -24,0 +26,0 @@ |
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
8948
30.23%6
100%155
31.36%53
3.92%