mirror of
https://github.com/JasonYANG170/IOTConnect-Web.git
synced 2024-11-27 14:16:34 +00:00
22 lines
489 B
JavaScript
22 lines
489 B
JavaScript
let urlAlphabet =
|
|
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
|
|
let customAlphabet = (alphabet, defaultSize = 21) => {
|
|
return (size = defaultSize) => {
|
|
let id = ''
|
|
let i = size
|
|
while (i--) {
|
|
id += alphabet[(Math.random() * alphabet.length) | 0]
|
|
}
|
|
return id
|
|
}
|
|
}
|
|
let nanoid = (size = 21) => {
|
|
let id = ''
|
|
let i = size
|
|
while (i--) {
|
|
id += urlAlphabet[(Math.random() * 64) | 0]
|
|
}
|
|
return id
|
|
}
|
|
export { nanoid, customAlphabet }
|