source: imaps-frontend/node_modules/nanoid/non-secure/index.cjs@ 0c6b92a

main
Last change on this file since 0c6b92a was 0c6b92a, checked in by stefan toskovski <stefantoska84@…>, 5 weeks ago

Pred finalna verzija

  • Property mode set to 100644
File size: 1.1 KB
Line 
1// This alphabet uses `A-Za-z0-9_-` symbols.
2// The order of characters is optimized for better gzip and brotli compression.
3// References to the same file (works both for gzip and brotli):
4// `'use`, `andom`, and `rict'`
5// References to the brotli default dictionary:
6// `-26T`, `1983`, `40px`, `75px`, `bush`, `jack`, `mind`, `very`, and `wolf`
7let urlAlphabet =
8 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
9
10let customAlphabet = (alphabet, defaultSize = 21) => {
11 return (size = defaultSize) => {
12 let id = ''
13 // A compact alternative for `for (var i = 0; i < step; i++)`.
14 let i = size | 0
15 while (i--) {
16 // `| 0` is more compact and faster than `Math.floor()`.
17 id += alphabet[(Math.random() * alphabet.length) | 0]
18 }
19 return id
20 }
21}
22
23let nanoid = (size = 21) => {
24 let id = ''
25 // A compact alternative for `for (var i = 0; i < step; i++)`.
26 let i = size | 0
27 while (i--) {
28 // `| 0` is more compact and faster than `Math.floor()`.
29 id += urlAlphabet[(Math.random() * 64) | 0]
30 }
31 return id
32}
33
34module.exports = { nanoid, customAlphabet }
Note: See TracBrowser for help on using the repository browser.