generateRandomString
Description
It creates a string with random characteres with the specified length.
| Parameter List | Returns | Rejection Errors |
|---|---|---|
| Promise<string || Array> | |
| Related Functions | Function Signature | |
function generateRandomString(strLen[, tuple]): Promise<string || Array> | ||
Examples
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