mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-28 12:05:41 +03:00
fix(random): Correct JSDoc (#81)
This commit is contained in:
parent
92c9db00ba
commit
1b3d9be724
@ -1,15 +1,15 @@
|
||||
/**
|
||||
* Generates a random floating-point number between minimum (inclusive) and maximum (exclusive).
|
||||
* If min is greater than maximum, the values are swapped.
|
||||
* Generate a random number within the given range.
|
||||
*
|
||||
* @param {number} minimum - The lower bound (inclusive).
|
||||
* @param {number} maximum - The upper bound (exclusive).
|
||||
* @returns {number} A random integer between minimum (inclusive) and maximum (exclusive).
|
||||
* @returns {number} A random number between minimum (inclusive) and maximum (exclusive). The number can be an integer or a decimal.
|
||||
* @throws {Error} Throws an error if `maximum` is not greater than `minimum`.
|
||||
*
|
||||
* @example
|
||||
* const result = random(0, 5); // result will be a random floating-point number between 0 (inclusive) and 5 (exclusive)
|
||||
* const result2 = random(5, 0); // This will throw an error
|
||||
* const result1 = random(0, 5); // Returns a random number between 0 and 5.
|
||||
* const result2 = random(5, 0); // If the minimum is greater than the maximum, an error is thrown
|
||||
* const result3 = random(5, 5); // If the minimum is equal to the maximum, an error is thrown.
|
||||
*/
|
||||
export function random(minimum: number, maximum: number): number {
|
||||
if (minimum >= maximum) {
|
||||
|
Loading…
Reference in New Issue
Block a user