Socket
Socket
Sign inDemoInstall

jumphash

Package Overview
Dependencies
1
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jumphash

jump consistent hash


Version published
Maintainers
1
Install size
109 kB
Created

Readme

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

FAQs

Last updated on 29 Mar 2015

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc