jumphash

0.2.2 • Public • Published

jumphash

Javascript implementation of jump consistent hash

For a faster node module see jumpsuit

Example

var jumphash = require('jumphash')
 
// jumphash(key, numBuckets)
 
// number keys - uses the floor of the absolute value
console.log(jumphash(23102, 16)) // 2
 
// buffer keys - uses the first 8 bytes as the key
console.log(jumphash(Buffer('1234567890ABCDEF', 'hex'), 1024)) // 888
 
// string keys - hashes the string with sha1
console.log(jumphash('live long and prosper', 256)) // 9
 
// optionally, specify a different string hash algorithm
console.log(jumphash('live long and prosper', 256, 'sha256')) // 82
 

Readme

Keywords

Package Sidebar

Install

npm i jumphash

Weekly Downloads

142

Version

0.2.2

License

ISC

Last publish

Collaborators

  • dannycoates