You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

jumphash

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jumphash

jump consistent hash

0.2.2
latest
Source
npmnpm
Version published
Weekly downloads
23
109.09%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

jump

FAQs

Package last updated on 29 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts