|
Last change
on this file since 505f39a was 2058e5c, checked in by istevanoska <ilinastevanoska@…>, 6 months ago |
|
Working / before login
|
-
Property mode
set to
100644
|
|
File size:
497 bytes
|
| Line | |
|---|
| 1 | let urlAlphabet =
|
|---|
| 2 | 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
|
|---|
| 3 | let customAlphabet = (alphabet, defaultSize = 21) => {
|
|---|
| 4 | return (size = defaultSize) => {
|
|---|
| 5 | let id = ''
|
|---|
| 6 | let i = size | 0
|
|---|
| 7 | while (i--) {
|
|---|
| 8 | id += alphabet[(Math.random() * alphabet.length) | 0]
|
|---|
| 9 | }
|
|---|
| 10 | return id
|
|---|
| 11 | }
|
|---|
| 12 | }
|
|---|
| 13 | let nanoid = (size = 21) => {
|
|---|
| 14 | let id = ''
|
|---|
| 15 | let i = size | 0
|
|---|
| 16 | while (i--) {
|
|---|
| 17 | id += urlAlphabet[(Math.random() * 64) | 0]
|
|---|
| 18 | }
|
|---|
| 19 | return id
|
|---|
| 20 | }
|
|---|
| 21 | export { nanoid, customAlphabet }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.