Comparing version 1.2.1 to 2.0.0
34
index.js
@@ -1,18 +0,15 @@ | ||
/*jslint node: true */ | ||
'use strict'; | ||
var farmhash = require('./build/Release/farmhash'); | ||
var farmhashLegacy = require('./build/Release/farmhash-legacy'); | ||
const farmhash = require('./build/Release/farmhash'); | ||
// Input validation | ||
var verifyInteger = function(input) { | ||
function verifyInteger (input) { | ||
if (typeof input !== 'number' || (input % 1) !== 0) { | ||
throw new Error('Expected an integer for seed'); | ||
} | ||
}; | ||
} | ||
module.exports = { | ||
// Hash methods - platform dependent | ||
hash32: function(input) { | ||
hash32: function (input) { | ||
if (typeof input === 'string') { | ||
@@ -26,3 +23,3 @@ return farmhash.Hash32String(input); | ||
}, | ||
hash32WithSeed: function(input, seed) { | ||
hash32WithSeed: function (input, seed) { | ||
verifyInteger(seed); | ||
@@ -37,3 +34,3 @@ if (typeof input === 'string') { | ||
}, | ||
hash64: function(input) { | ||
hash64: function (input) { | ||
if (typeof input === 'string') { | ||
@@ -47,3 +44,3 @@ return farmhash.Hash64String(input); | ||
}, | ||
hash64WithSeed: function(input, seed) { | ||
hash64WithSeed: function (input, seed) { | ||
verifyInteger(seed); | ||
@@ -58,3 +55,3 @@ if (typeof input === 'string') { | ||
}, | ||
hash64WithSeeds: function(input, seed1, seed2) { | ||
hash64WithSeeds: function (input, seed1, seed2) { | ||
verifyInteger(seed1); | ||
@@ -70,15 +67,4 @@ verifyInteger(seed2); | ||
}, | ||
// v1 (legacy) implementation of platform dependent hash32 | ||
hash32v1: function(input) { | ||
if (typeof input === 'string') { | ||
return farmhashLegacy.Hash32String(input); | ||
} | ||
if (Buffer.isBuffer(input)) { | ||
return farmhashLegacy.Hash32Buffer(input); | ||
} | ||
throw new Error('Expected a String or Buffer for input'); | ||
}, | ||
// Fingerprint methods - platform independent | ||
fingerprint32: function(input) { | ||
fingerprint32: function (input) { | ||
if (typeof input === 'string') { | ||
@@ -92,3 +78,3 @@ return farmhash.Fingerprint32String(input); | ||
}, | ||
fingerprint64: function(input) { | ||
fingerprint64: function (input) { | ||
if (typeof input === 'string') { | ||
@@ -95,0 +81,0 @@ return farmhash.Fingerprint64String(input); |
{ | ||
"name": "farmhash", | ||
"version": "1.2.1", | ||
"version": "2.0.0", | ||
"author": "Lovell Fuller <npm@lovell.info>", | ||
@@ -11,3 +11,4 @@ "contributors": [ | ||
"scripts": { | ||
"test": "node test/unit" | ||
"install": "prebuild-install || node-gyp rebuild", | ||
"test": "semistandard && cc && node test/unit && prebuild-ci" | ||
}, | ||
@@ -27,8 +28,22 @@ "main": "index.js", | ||
"dependencies": { | ||
"nan": "^2.4.0" | ||
"nan": "^2.6.2", | ||
"prebuild-install": "^2.1.2" | ||
}, | ||
"devDependencies": { | ||
"cc": "^1.0.1", | ||
"prebuild": "^6.2.0", | ||
"prebuild-ci": "^2.2.2", | ||
"semistandard": "^11.0.0" | ||
}, | ||
"license": "Apache-2.0", | ||
"engines": { | ||
"node": ">=0.10" | ||
"node": ">=4.5.0" | ||
}, | ||
"cc": { | ||
"linelength": "120", | ||
"ignore": [ | ||
"node_modules", | ||
"src/upstream" | ||
] | ||
} | ||
} |
@@ -17,5 +17,7 @@ # farmhash | ||
This module uses FarmHash v1.1.0 (2015-03-01). | ||
It has been tested with Node.js v0.10, v0.12, v4, v6 | ||
It has been tested with Node.js v4, v6, v8 | ||
on Linux, OS X and Windows. | ||
Pre-compiled binaries are provided for the most common platforms. | ||
## Installation | ||
@@ -30,7 +32,7 @@ | ||
```javascript | ||
var farmhash = require('farmhash'); | ||
const farmhash = require('farmhash'); | ||
``` | ||
```javascript | ||
var hash = farmhash.hash32('test'); | ||
const hash = farmhash.hash32('test'); | ||
console.log(typeof hash); // 'number' | ||
@@ -40,3 +42,3 @@ ``` | ||
```javascript | ||
var hash = farmhash.hash64(new Buffer('test')); | ||
const hash = farmhash.hash64(new Buffer('test')); | ||
console.log(typeof hash); // 'string' | ||
@@ -46,3 +48,3 @@ ``` | ||
```javascript | ||
var hash = farmhash.hash64WithSeed('test', 123); | ||
const hash = farmhash.hash64WithSeed('test', 123); | ||
console.log(typeof hash); // 'string' | ||
@@ -52,3 +54,3 @@ ``` | ||
```javascript | ||
var hash = farmhash.fingerprint32(new Buffer('test')); | ||
const hash = farmhash.fingerprint32(new Buffer('test')); | ||
console.log(typeof hash); // 'number' | ||
@@ -58,3 +60,3 @@ ``` | ||
```javascript | ||
var hash = farmhash.fingerprint64('test'); | ||
const hash = farmhash.fingerprint64('test'); | ||
console.log(typeof hash); // 'string' | ||
@@ -104,10 +106,2 @@ ``` | ||
#### hash32v1(input) | ||
Legacy function to access v1 of the FarmHash implementation. | ||
* `input` is the Buffer or String to hash. | ||
Returns a Number containing the 32-bit unsigned integer v1 hash value of `input`. | ||
### Fingerprint | ||
@@ -141,3 +135,3 @@ | ||
Copyright 2014, 2015, 2016 Lovell Fuller and contributors. | ||
Copyright 2014, 2015, 2016, 2017 Lovell Fuller and contributors. | ||
@@ -156,3 +150,3 @@ Licensed under the Apache License, Version 2.0 (the "License"); | ||
Copyright 2014, 2015 Google, Inc. | ||
Copyright 2014, 2015, 2016, 2017 Google, Inc. | ||
@@ -159,0 +153,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 6 instances in 1 package
1
322901
2
4
9
79
161
+ Addedprebuild-install@^2.1.2
+ Addedansi-regex@2.1.1(transitive)
+ Addedaproba@1.2.0(transitive)
+ Addedare-we-there-yet@1.1.7(transitive)
+ Addedbl@1.2.3(transitive)
+ Addedbuffer-alloc@1.2.0(transitive)
+ Addedbuffer-alloc-unsafe@1.1.0(transitive)
+ Addedbuffer-fill@1.0.0(transitive)
+ Addedchownr@1.1.4(transitive)
+ Addedcode-point-at@1.1.0(transitive)
+ Addedconsole-control-strings@1.1.0(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddecompress-response@3.3.0(transitive)
+ Addeddeep-extend@0.6.0(transitive)
+ Addeddelegates@1.0.0(transitive)
+ Addeddetect-libc@1.0.3(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedexpand-template@1.1.1(transitive)
+ Addedfs-constants@1.0.0(transitive)
+ Addedgauge@2.7.4(transitive)
+ Addedgithub-from-package@0.0.0(transitive)
+ Addedhas-unicode@2.0.1(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedini@1.3.8(transitive)
+ Addedis-fullwidth-code-point@1.0.0(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedmimic-response@1.0.1(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addednode-abi@2.30.1(transitive)
+ Addednoop-logger@0.1.1(transitive)
+ Addednpmlog@4.1.2(transitive)
+ Addednumber-is-nan@1.0.1(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedos-homedir@1.0.2(transitive)
+ Addedprebuild-install@2.5.3(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedpump@1.0.32.0.1(transitive)
+ Addedrc@1.2.8(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedsemver@5.7.2(transitive)
+ Addedset-blocking@2.0.0(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedsimple-concat@1.0.1(transitive)
+ Addedsimple-get@2.8.2(transitive)
+ Addedstring-width@1.0.2(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedstrip-json-comments@2.0.1(transitive)
+ Addedtar-fs@1.16.3(transitive)
+ Addedtar-stream@1.6.2(transitive)
+ Addedto-buffer@1.1.1(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedwhich-pm-runs@1.1.0(transitive)
+ Addedwide-align@1.1.5(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedxtend@4.0.2(transitive)
Updatednan@^2.6.2