sequential-guid

Sequential unique identifiers generator

npm install sequential-guid
1 downloads in the last week
6 downloads in the last month

sequential-guid

Node package for generating sequential unique identifiers based on unique guid seed. Generation guids version 1 and 4 cannot be done without node-uuid library, thank you Broofa.

How-to

Start with install a package

  npm install sequential-guid

In your code require library code and create object

  var Uid = require('sequential-guid')
  var uid = new Uid

Creating new instance of guid class cause generation of the seed

  console.log( uid.seed )   // output guid like this: 6e44dc51-804d-47ab-a933-f94641cf86cf

You can deffer generating seed value by seting deferInit property. Now new object has undefined seed until you call next() method on it, we can also specify value for seed

  Uid.prototype.deferInit = true
  var iid = new Uid
  iid.seed = '00000000-0000-4000-a000-000000000000'

lets generate unique identifiers

  console.log( uid.next() )    // '00000000-0000-4000-a000-000000000001'
  console.log( uid.next() )    // '00000000-0000-4000-a000-000000000002'
  console.log( uid.next() )    // '00000000-0000-4000-a000-000000000003'
  console.log( uid.next() )    // '00000000-0000-4000-a000-000000000004'
  console.log( uid.next() )    // '00000000-0000-4000-a000-000000000005'

That's all, thanks for reading :)

npm loves you