Nitrogen Poisonous Monoxide
Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

standardid

1.0.3 • Public • Published

StandardID Build Status

Generate IDs using the same format

This can be useful if you have user facing IDs that you want to be consitently formatted

Install

$ npm install standardid

Usage

const standardID  = require('standardid') // Require the module
 
// Create a new generator
// This will generator an ID of 3 uppercase alphabets followed by 3 digits
let generator = new standardID("AAA000");
 
// Generate a new ID
let newID = generator.generate();
 
// Set blueprint after generator is created
generator.blueprint = "aaaa";
newID = generator.generate();
 
// Placeing a ! will now select from the given string
generator.specifiers["!"] = ".!><?";
generator.blueprint = "!!!";
newID = generator.generate();
 

By default the specifiers are:

  "A":"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
  "a":"abcdefghijklmnopqrstuvwxyz",
  "0":"0123456789"
 

Install

npm i standardid

DownloadsWeekly Downloads

1

Version

1.0.3

License

ISC

Unpacked Size

43 kB

Total Files

8

Last publish

Collaborators

  • avatar