/** @public */ export declare type RandomFunc = () => number; /** * Basic(bool int float regexp) Generater * basic generator for bool int float regexp * @public */ export declare class BasicRandom { /** * extends class's prototype * @param options - methods * * @example * ```javascript * BasiceRandom.mixin({ * percent() { * return `${this.float({ min: 0, max: 100, fixed: 2 })}%`; * }, * }); * * const R = new Random(); * R.percent(); // '10.12%' * R.n(R.percent, 2) // ['12.10%', '25.22%'] * ``` */ static mixin(options: MixinOptions): void; /** * generate 0 to 1, similar to Math.random */ random: RandomFunc; /** * MersenneTwister's seed */ private readonly seed?; /** * MersenneTwister */ private mt?; constructor(seed?: number); constructor(seed?: RandomFunc); /** * Return a random boolean value (true or false). * @param options - options */ boolean(options?: BooleanOptions): boolean; /** * Reture a random integer * @param options - options */ integer(options?: Interval): number; /** * Genarate a float / double number * * @param options - */ float(options?: FloatOptions): number; /** * generate an integer number * @param options - */ natural(options?: Interval): number; /** * Given an array, pick a random element and return it * @param array - The array to process * */ pickone(array: T[]): T; /** * Given an array, pick some random elements and return them in a new array * @param array - the array to process * @param count - the counts to pick */ pickset(array: T[], count?: number): T[]; /** * Given an array, scramble the order and return it. * @param array - the array to process * @public */ shuffle(array: T[]): T[]; /** * Provide any function that generates random stuff (usually another generate function) * and a number and n() will generate an array of items with a length matching the length you specified. * @param generator - the generator * @param length - the length * @param params - the generator's params * * @example * ```javascript * const R = new Random(); * R.n(R.natural, 10, { min: 0, max: 100 }); // ten numbers which arn between 0 and 100 * ``` */ n(generator: T, length?: number, ...params: Parameters): ReturnType[]; /** * Generate a string which match regexp * * @example * ```javascript * new Random().randexp('\\d{4}-\\d{8}'); * ``` * * @param source - regexp or source of regexp * @param flag - flag(only support `i`) */ randexp(source: string | RegExp, flag?: string): string; } /** * @public */ export declare type AnyFunc = (...args: any[]) => any; /** * the params to generate boolean * @public */ export interface BooleanOptions { /** likelihood 0-100 */ likelihood?: number; } /** * @public */ export interface MixinOptions { [name: string]: AnyFunc; } /** * @public */ export interface Interval { /** * min */ min?: number; /** * max */ max?: number; } /** * The params to generate a float * @public */ export interface FloatOptions extends Interval { /** * precision */ fixed?: number; }