src/codeGenerator.js
async function codeGenerator(length = 6) {
    const code = new Array(length)
      .fill('0')
      .map(() => CHARS_SET[Math.floor(random() * (charsSetLength - 1))])
      .join('');
    log('debug', `Generated a new code:`, code);
    return code;
  }
async function codeGenerator(length = 6) {
    const code = new Array(length)
      .fill('0')
      .map(() => CHARS_SET[Math.floor(random() * (charsSetLength - 1))])
      .join('');
    log('debug', `Generated a new code:`, code);
    return code;
  }
async function codeGenerator ( length = 6 ) { const code = new Array ( length ) . fill ( '0' ) . map ( ( ) => CHARS_SET [ Math . floor ( random ( ) * ( charsSetLength - 1 ) ) ] ) . join ( '' ) ; log ( 'debug' , ` ` , code ) ; return code ; }
Returns a random code
@param  {Number}   [length]
An optional custon code length (defaults to 6)
@return {Promise<String>}
A promise of the generated code
@example
console.log([
codeGenerator(),
codeGenerator(),
codeGenerator(),
]);
// Prints: ABCDEF,GHJKMN,PRSTUV
Returns a random code