Socket
Book a DemoInstallSign in
Socket

@ceejbot/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

@ceejbot/jumphash

an implementation of the jump consistent hash for node

1.2.4
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

@ceejbot/jumphash

Really remarkably trivial node bindings for Google's jump consistent hash.

Build Status on npm

Tested on nodes 4, 6, and 7. Is probably just fine on node 0.10 too.

npm install --save @ceejbot/jumphash

Usage

This module provides one function: jumphash(key, bucketCount). key must be a non-negative integer or a buffer. bucketCount must be a positive integer (0 is an invalid bucket count).

The return value is a integer in the range [0, bucketCount) that you can use as you wish. The paper linked above describes the intended data storage use.

var jumphash = require('@ceejbot/jumphash')
    assert = require('assert'),
    crypto = require('crypto');

var location = jumphash(23102, 16);
assert(location >= 0);
assert(location < 16);

var buffer = crypto
    .createHash('md5')
    .update('my-string-key-for-some-resource')
    .digest();
var location2 = jumphash(buffer, 16);

Only the first 64 bits of the buffer are considered, with the most significant bit first.

License

ISC

Keywords

consistent hash

FAQs

Package last updated on 16 Nov 2016

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.