incremental-id-generator

Generates incremental string IDs.
Installation
npm install incremental-id-generator --save-dev
Usage
const idGenerator = require('incremental-id-generator');
const nextID = idGenerator('ab');
nextID();
nextID();
nextID();
nextID();
nextID();
nextID();
nextID();
nextID();
API
idGenerator(characters, [options]) ⇒ function
Returns a function that will return a new, incrementing ID each time it is called.
characters | string | The characters that will be used to encode the ID. Must not contain duplicate characters. |
[options.prefix] | string | A prefix to prepend to every generated ID. |
Example
const idGenerator = require('incremental-id-generator');
const nextBinID = idGenerator('01');
nextBinID();
nextBinID();
nextBinID();
nextBinID();
const nextPrefixedID = idGenerator('abc', {prefix: '_'});
nextPrefixedID();
nextPrefixedID();
nextPrefixedID();
nextPrefixedID();
nextPrefixedID();
nextPrefixedID();
nextPrefixedID();