dragonroll/backend/node_modules/nanoid/url.js

28 lines
814 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// This alphabet uses a-z A-Z 0-9 _- symbols.
// Despite the fact the source code is quite long, its entropy
// is low and there are lots of duplicates - just what compressors
// like GZIP and Brotli likes the best.
/**
* URL safe symbols.
*
* @name url
* @type {string}
*
* @example
* const url = require('nanoid/url')
* generate(url, 10) //=> "Uakgb_J5m9"
*/
// This alphabet uses a-z A-Z 0-9 _- symbols.
// Symbols are generated for smaller size.
// -_zyxwvutsrqponmlkjihgfedcba9876543210ZYXWVUTSRQPONMLKJIHGFEDCBA
module.exports = '-_'
var i = 36
while (i--) {
// 36 is radix. Number.prototype.toString(36) returns number
// in Base36 representation. Base36 is like hex, but it uses 09 and a-z.
module.exports += i.toString(36)
i > 9 && (module.exports += i.toString(36).toUpperCase())
}