npm

Need private packages and team management tools?Check out npm Orgs. »

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

6

version

1.0.3

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability