0.0.4 • Published 2 years ago
@webextensions/simpleid v0.0.4
simpleid
Generate simple unique ID strings (simpleid)
Rules
- A simpleidis an alphanumeric code (-can be used as a separator)
- A simpleidcontains 12 key characters (by default)
- Same character won't repeat consecutively
- A character will not be followed by the keys to its left or right on a QWERTY keyboard
- The first character will be an alphabet
- The following characters are not allowed due to potential of typo: 0,o,1,iandl
Notes
Currently, there are no specific restrictions for:
- String length (default length is 12 characters)
- Case-sensitivity (the implementation should handle different cases as same or different)
- Handling mixed casing (The library generates only lowercase or uppercase strings)
- Versioning for the definition of a valid simpleid
Usage - via Command line
Without installing
$ npx @webextensions/simpleidInstall and run
$ npm install --global @webextensions/simpleid$ simpleid
qn3k-vqtw-rp72$ simpleid --case upper
P6HK-8NRM-RM6G$ simpleid --multiple 5
f3hw-cmwb-7m6g
q49j-2tc7-wx8s
kgvj-n4cj-5xs5
wjzb-w6jz-fjv8
qsk4-x59m-pvp4$ simpleid --help
# Shows the helpUsage - via Code
General
const { simpleid } = require('@webextensions/simpleid');
const id = simpleid();
console.log(id); // swsk-3c3r-czwtAdvanced
const {
    simpleid,
    simpleidLowerCase,
    simpleidUpperCase,
    hyphenateId,
    unhyphenateId
} = require('@webextensions/simpleid');
const
    id1 = simpleid(),                        // vm6f-85s7-k96p
    id2 = simpleidLowerCase(),               // qxwz-9r7z-rvtp
    id3 = simpleidUpperCase(),               // F4QM-2SMW-2J2C
    withoutHyphen = unhyphenateId(id3),      // F4QM2SMW2J2C
    withHyphen = hyphenateId(withoutHyphen); // F4QM-2SMW-2J2C