qiot-id-gen
v0.0.3
Published
Generates random ids with a prefix (a la Stripe)
Downloads
1
Readme
id-generator
Generates random ids with a prefix (a la Stripe)
Installing
npm i auth0-id-generator
Using
Simple case:
var IdGenerator = require('auth0-id-generator');
var generator = new IdGenerator();
var id = generator.new('cus');
console.log(id); // cus_lO1DEQWBbQAACfHO
Predefined set of allowed prefixes (to avoid mistakes):
var IdGenerator = require('auth0-id-generator');
var generator = new IdGenerator(['cus', 'con']);
var id = generator.new('cus');
console.log(id); // cus_lO1DEQWBbQAACfHO
generator.new('cli'); // throws
Author
Completely stolen from Auth0. Wiating on acceptance of a pull request.
License
This project is licensed under the MIT license. See the LICENSE file for more info.