squuid

Semi-sequential universally unique identifiers

Usage no npm install needed!

<script type="module">
  import squuid from 'https://cdn.skypack.dev/squuid';
</script>

README

squuid

Semi-sequential universally unique identifiers

build status

  // generate base64-lex-encoded v1 UUID
  var id = squuid() // 'Wjmi85Wy4UMVUHybSVnKU0--'

  // generate another
  var id2 = squuid() // 'Wjmi8LWy4UMVUHybSVnKU0--'

  // ids will be monotonically increasing per process
  id2 > id // true

  // you can pass 
  squuid({
    msecs: Date.now() + 100 // epoch time, defaults to `Date.now`
    // node: node id as array of 6 bytes (randomly generated if not provided)
    // clockseq: RFC clock sequence, number between 0 and 0x3fff
  })

TODO: node-uuid looks to be encoding the time bit in little-endian, which marginally decreases the monotonicity properties you want for optimal btree inserts.