@subspace/jump-consistent-hash
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

Jump-consistent hash implementation

Read https://arxiv.org/abs/1406.2294 for details, this package works with 64-bit/8-byte inputs in form of Uint8Arrays.

How to install

npm install @subspace/jump-consistent-hash

NOTE: Requires Node.js v12+ or modern browser with BigInt support

How to use

TypeScript:

import {randomBytes} from 'crypto';
import {jumpConsistentHash} from '@subspace/jump-consistent-hash';

const bucket = jumpConsistentHash(randomBytes(8), 10);

API

jumpConsistentHash.jumpConsistentHash(key: Uint8Array, numBuckets: number): number

Takes a key and number of buckets and returns bucket from range [0, numBuckets).

  • key - 8 bytes key
  • numBuckets - number of buckets to which keys should be distributed

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.1
    17
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.1.1
    17
  • 1.1.0
    0
  • 1.0.0
    0
  • 0.0.1
    0

Package Sidebar

Install

npm i @subspace/jump-consistent-hash

Weekly Downloads

17

Version

1.1.1

License

MIT

Unpacked Size

5.29 kB

Total Files

5

Last publish

Collaborators

  • subserge
  • leo_subspace
  • rg3l3dr
  • nazar-pc