incremental-id-generator
Generates incremental string IDs.
Installation
npm install incremental-id-generator --save-dev
Usage
const idGenerator = ;const nextID = ; ; // -> a; // -> b; // -> aa; // -> ab; // -> ba; // -> bb; // -> aaa; // -> aab
API
function
idGenerator(characters, [options]) ⇒ Returns a function that will return a new, incrementing ID each time it is called.
Param | Type | Description |
---|---|---|
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 = ; const nextBinID = ;; // -> 0; // -> 1; // -> 00; // -> 01 const nextPrefixedID = ;; // -> _a; // -> _b; // -> _c; // -> _aa; // -> _ab; // -> _ac; // -> _ba