Repository URL to install this package:
|
Version:
3.12.2 ▾
|
/* Borrowed from https://github.com/ai/nanoid/blob/3.0.2/non-secure/index.js
* & https://github.com/reduxjs/redux-toolkit/blob/master/packages/toolkit/src/nanoid.ts
* This alphabet uses `A-Za-z0-9_-` symbols. A genetic algorithm helped
* optimize the gzip compression for this alphabet.
*/
var urlAlphabet = 'ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW';
var nanoid = function nanoid() {
var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 21;
var id = '';
// A compact alternative for `for (var i = 0; i < step; i++)`.
var i = size;
while (i--) {
// `| 0` is more compact and faster than `Math.floor()`.
id += urlAlphabet[Math.random() * 64 | 0];
}
return id;
};
export default nanoid;