sliver

128-bit, k-ordered (lexicographically sortable), base 62, coordination free id generation for Node

sliver

I didn't see any existing solutions for Boundary's Flake or Twitter's Snowflake style ids that did everything I'd like at an acceptable speed. This is my shameless attempt at a clone that does the following:

  • 128 bit keys
  • K-ordered
  • Rendered as base 62
  • Lexicographically sortable
  • Coordination free-ish

If no seed is provided during start-up, sliver will attempt to create a seed from the MACAddress. While this is great, it also means that you can't have two processes using sliver independently and still guarantee unique ids (a bad thing).

 
// reading the MAC address is async, hence the ready call. 
var sliver = require( 'sliver' )( ready );
id = sliver.getId(); // ta-da 
 

Anything can seed the node id. sliver uses murmurhash3 to create a unique 32 bit integer for the node id

// no need to provide a call back when specifying a seed 
var sliver = require( 'sliver' )( 'Hey, look, a string based seed.' );
id = sliver.getId(); // ta-da 

Looks like this tops out around 20 / ms which is an improvement over other libraries.