@rxap/utilities
Version:
A collection of utility functions, types and interfaces.
22 lines (21 loc) • 833 B
TypeScript
/**
* Generates a random alphanumeric string of a specified length.
*
* @export
* @function GenerateRandomString
* @param {number} [length=32] - The length of the string to be generated. If no value is provided, the default length is 32.
*
* The function works by initializing an empty string and a string of possible characters. It then loops for the specified length,
* each time selecting a random character from the possible characters string and appending it to the result string.
*
* @returns {string} The generated random alphanumeric string.
*
* @example
* // returns a random alphanumeric string of length 32
* GenerateRandomString();
*
* @example
* // returns a random alphanumeric string of length 10
* GenerateRandomString(10);
*/
export declare function GenerateRandomString(length?: number): string;