2018-07-21 12:37:39 +00:00
|
|
|
import * as plugins from './smartstring.plugins';
|
2017-10-11 12:52:22 +00:00
|
|
|
|
2019-01-12 19:12:58 +00:00
|
|
|
/**
|
|
|
|
* creates a random string
|
2019-04-16 06:55:37 +00:00
|
|
|
*
|
2019-01-12 19:12:58 +00:00
|
|
|
* ```ts
|
|
|
|
* createRandomString('AAAA')
|
2019-04-16 06:55:37 +00:00
|
|
|
* //=> 'AGHR'
|
2019-01-12 19:12:58 +00:00
|
|
|
* ```
|
2019-04-16 06:55:37 +00:00
|
|
|
*
|
2019-01-12 19:12:58 +00:00
|
|
|
* @param patternArg the pattern argument to use, Aa0!* are viable pattern descritors
|
|
|
|
* @param lengthArg the length of the random string
|
|
|
|
* @param optionsArg options
|
|
|
|
*/
|
2017-10-26 13:24:10 +00:00
|
|
|
export const createRandomString = (
|
2017-10-11 12:52:22 +00:00
|
|
|
patternArg: string,
|
2019-01-12 19:12:58 +00:00
|
|
|
lengthArg?: number,
|
|
|
|
optionsArg?: any
|
2017-10-11 12:52:22 +00:00
|
|
|
): string => {
|
2018-07-21 12:37:39 +00:00
|
|
|
return plugins.randomatic(patternArg, lengthArg, optionsArg);
|
|
|
|
};
|
2017-10-11 12:52:22 +00:00
|
|
|
|
2019-01-12 19:12:58 +00:00
|
|
|
/**
|
2020-12-31 04:11:33 +00:00
|
|
|
* creates a cryptic string in the speicifed length
|
2019-01-12 19:12:58 +00:00
|
|
|
* @param lengthArg the length of the crypto string
|
|
|
|
*/
|
|
|
|
export const createCryptoRandomString = (lengthArg: number): string => {
|
2020-12-31 04:11:33 +00:00
|
|
|
return plugins.nanoid(lengthArg);
|
2018-07-21 12:37:39 +00:00
|
|
|
};
|