README
Create Id
Install
npm install create-id
or
yarn add create-id
Usage
import createId from "create-id";
const createId = require("create-id");
createId can be called with no arguments to make a 20 character id
createId() => "x8HZPoiMRUhQzygXegAK"
Arguments
createId(prefix, suffix, length, chars);
prefix places a string at the front of the id
suffix places a string at the end of the id
Neither are counted against length.
Must be a string, suggested to be something to help find type or location of data.
createId("myPrefix-", "_mySuffix") => "myPrefix-qsZGSjYRAmiJRt1s7v1h_mySuffix"
Encouraged to use a character like - or _ at the end of your prefix and beginning of your suffix
You can split id id.split("-") to get your prefix or suffix
length is how long the random generated portion is
20 is the default and must be a number
createId(null, null, 6) => "ojZESh"
createId(null, null, 16) => "3hgV848o9KBXrpqf"
chars is the characters used for the random generated portion.
Must be a string, not an array
Default characters are upper and lower case alphabet and numbers
- "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
createId(null, null, null, "01") => "11110011000100100011"
createId(null, null, null, "1234567890ABCDEF") => "01B5E21371E9DB262996"
If returned id is an empty string the default method occurs
createId(null, null, 0, "!@#