UNPKG

codetrix

Version:

A lightweight lodash-style utility library

34 lines (33 loc) 1.2 kB
/** * Generates a random floating-point number between the given min (inclusive) and max (exclusive). * * @param min - The minimum value (inclusive). Defaults to 0. * @param max - The maximum value (exclusive). Defaults to 1. * @returns A random float between min (inclusive) and max (exclusive). * * @example * random(1, 5); // Might return 3.1415 */ export declare function random(min?: number, max?: number): number; /** * Generates a random integer between the given min and max (inclusive). * * @param min - The minimum value (inclusive). * @param max - The maximum value (inclusive). * @returns A random integer between min and max. * * @example * randomInt(1, 10); // Might return 4 */ export declare function randomInt(min: number, max: number): number; /** * Generates a random integer with the specified number of digits. * * @param digits - The number of digits for the random number. Must be greater than 0. * @returns A random integer with the specified digit length. * @throws Will throw an error if digits is less than or equal to 0. * * @example * randomByDigits(3); // Might return 527 */ export declare function randomByDigits(digits: number): number;