@byted/id-generator
v1.0.0
Published
An uncentralized id generator based on mac address, process id, timestamp and random numbers.
Downloads
5
Readme
ID Generator
An uncentralized id generator based on mac address, process id, timestamp and random numbers.
INSTALLATION
npm install --save @byted/id-generator
USAGE
const IDGenerator = require('@byted/id-generator');
const generator = new IDGenerator(options);
const id = generator.generate();
options
prefix
: prefix of id string, default to''
;radix
: an integer between 2 and 36 that represents the radix (the base in mathematical numeral systems) of id, default to10
;hash
:true
orfalse
, return hased id if true, default tofalse
.
EXAMPLE
const IDGenerator = require('@byted/id-generator');
const generator = new IDGenerator({
prefix: '',
radix: 36,
hash: false
});
const id = generator.generate();