generateRandomString

It creates a string with random characteres with the specified length.
Parameter ListReturnsRejection Errors
  • strLen: number
  • tuple: Array (optional)
Promise<string || Array>
Related FunctionsFunction Signature
function generateRandomString(strLen[, tuple]): Promise<string || Array>
1 2 3 4 import {generateRandomString} from 'puddy-m/lib/helpers' generateRandomString(5) .then(randomChars=>console.log(randomChars)) // an example of a possible outcome: 'tg85Y'
1 2 3 4 import {generateRandomString} from 'puddy-m/lib/helpers' generateRandomString(true) .catch(e=>e) // rejects an instance of PositiveIntegersValidationError.
1 2 3 4 5 6 // Using it with tuple parameter import {generateRandomString} from 'puddy-m/lib/helpers' generateRandomString(10, []) .then(tuple=>validateString("World", tuple)) .then(([randomChars, world])=> randomChars + world) // rth34Hgbn8World