Skip to content

dannycoates/jumphash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published