Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

murmurhash

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

murmurhash - npm Package Compare versions

Comparing version
1.0.0
to
2.0.0
+12
.github/FUNDING.yml
# 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;
}
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;

{
"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": {

@@ -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 @@