fix(random): Correct JSDoc (#81)

This commit is contained in:
Dongho Kim 2024-06-21 16:53:59 +09:00 committed by GitHub
parent 92c9db00ba
commit 1b3d9be724
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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) {