mirror of
https://github.com/xfarrow/blink
synced 2025-06-27 09:03:02 +02:00
Change endpoint from persons to people
This commit is contained in:
40
backend/apis/nodejs/node_modules/knex/lib/util/nanoid.js
generated
vendored
Normal file
40
backend/apis/nodejs/node_modules/knex/lib/util/nanoid.js
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
// This alphabet uses `A-Za-z0-9_-` symbols. The genetic algorithm helped
|
||||
// optimize the gzip compression for this alphabet.
|
||||
const urlAlphabet =
|
||||
'ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW';
|
||||
|
||||
const numberAlphabet = '0123456789';
|
||||
|
||||
/**
|
||||
* Generate URL-friendly unique ID. This method uses the non-secure
|
||||
* predictable random generator with bigger collision probability.
|
||||
* Based on https://github.com/ai/nanoid
|
||||
*
|
||||
* ```js
|
||||
* model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL"
|
||||
* ```
|
||||
*
|
||||
* @param size Size of the ID. The default size is 21.
|
||||
* @returns A random string.
|
||||
*/
|
||||
function nanoid(size = 21) {
|
||||
let id = '';
|
||||
// A compact alternative for `for (var i = 0; i < step; i++)`.
|
||||
let i = size;
|
||||
while (i--) {
|
||||
// `| 0` is more compact and faster than `Math.floor()`.
|
||||
id += urlAlphabet[(Math.random() * 64) | 0];
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
function nanonum(size = 21) {
|
||||
let id = '';
|
||||
let i = size;
|
||||
while (i--) {
|
||||
id += numberAlphabet[(Math.random() * 10) | 0];
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
module.exports = { nanoid, nanonum };
|
Reference in New Issue
Block a user