1.0.0 • Published 7 years ago

@byted/id-generator v1.0.0

Weekly downloads
1
License
ISC
Repository
-
Last release
7 years ago

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 to 10;
  • hash: true or false, return hased id if true, default to false.

EXAMPLE

const IDGenerator = require('@byted/id-generator');

const generator = new IDGenerator({
    prefix: '',
    radix: 36,
    hash: false
});
const id = generator.generate();