@sunney/flareutils
Version:
Small Utilities and little goodies that make developing with Cloudflare easier and faster.
34 lines (33 loc) • 1.12 kB
TypeScript
export declare type RandNum = () => number;
export declare type RandLetter = () => string;
/**
* Generator that generates random phonetic strings. Cryptographic security is dependent on the random number generator that is passed in.
*/
export declare class Phonetic {
/**
* Random number generator used by Phonetic. Must generate numbers from 0 to 1.
*/
private readonly generator;
/**
* Returns a random vowel.
*/
private readonly vowel;
/**
* Returns a random consonant.
*/
private readonly consonant;
/**
* Creates a new Phonetic generator.
* @param {RandNum} rand Random Number Generator. While it is recommended to use a cryptographically secure random number generator(a la. [Isaac](/classes/Isaac)), this is not required.
* @constructor
*/
constructor(rand: RandNum);
/**
* Generates a random phonetic string.
* @param {number} length Length of the string to generate.
* @returns {string} Random phonetic string.
* @example
* const phonetic = phonetic.rand(10);
*/
rand(len?: number): string;
}