1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Add random int utility function

This commit is contained in:
Bill Thornton 2023-03-14 01:32:36 -04:00
parent ff8b7427e3
commit 4937f2d60c
4 changed files with 17 additions and 17 deletions

View file

@ -2,6 +2,16 @@ function toLocaleStringSupportsOptions() {
return !!(typeof Intl === 'object' && Intl && typeof Intl.NumberFormat === 'function');
}
/**
* Generates a random integer in a given range.
* @param {number} min - Minimum of the range.
* @param {number} max - Maximum of the range.
* @returns {number} Randomly generated number.
*/
export function randomInt(min: number, max: number): number {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
/**
* Gets the value of a number formatted as a perentage.
* @param {number} value The value as a number.