dragonroll/backend/node_modules/nanoid/async/generate.js

25 lines
644 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.

var random = require('./random')
var format = require('./format')
/**
* Low-level function to change alphabet and ID size.
*
* Alphabet must contain 256 symbols or less. Otherwise, the generator
* will not be secure.
*
* @param {string} alphabet Symbols to be used in ID.
* @param {number} size The number of symbols in ID.
*
* @return {Promise} Promise with random string.
*
* @example
* const generateAsync = require('nanoid/async/generate')
* generateAsync('0123456789абвгдеё', 5).then(id => {
* model.id = id //=> "8ё56а"
* })
*
* @name generateAsync
* @function
*/
module.exports = format.bind(null, random)