source: node_modules/@reduxjs/toolkit/src/nanoid.ts

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 585 bytes
RevLine 
[a762898]1// Borrowed from https://github.com/ai/nanoid/blob/3.0.2/non-secure/index.js
2// This alphabet uses `A-Za-z0-9_-` symbols. A genetic algorithm helped
3// optimize the gzip compression for this alphabet.
4let urlAlphabet =
5 'ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW'
6
7/**
8 *
9 * @public
10 */
11export let nanoid = (size = 21) => {
12 let id = ''
13 // A compact alternative for `for (var i = 0; i < step; i++)`.
14 let i = size
15 while (i--) {
16 // `| 0` is more compact and faster than `Math.floor()`.
17 id += urlAlphabet[(Math.random() * 64) | 0]
18 }
19 return id
20}
Note: See TracBrowser for help on using the repository browser.