if (max < min) {
throw new RangeError('Invalid interval')
}
- if (max - min === Infinity) {
+ if (max - min === Number.POSITIVE_INFINITY) {
throw new RangeError('Invalid interval')
}
return (randomBytes(4).readUInt32LE() / 0xffffffff) * (max - min) + min
* @returns
*/
function loopMax (values) {
- let maximum = -Infinity
+ let maximum = Number.NEGATIVE_INFINITY
for (const value of values) {
if (value > maximum) maximum = value
}
function reduceTernaryMax (values) {
return values.reduce(
(maximum, num) => (maximum > num ? maximum : num),
- -Infinity
+ Number.NEGATIVE_INFINITY
)
}
* @returns
*/
function reduceMathMax (values) {
- return values.reduce((maximum, num) => Math.max(maximum, num), -Infinity)
+ return values.reduce(
+ (maximum, num) => Math.max(maximum, num),
+ Number.NEGATIVE_INFINITY
+ )
}
/**
* @returns
*/
function loopMin (values) {
- let minimum = Infinity
+ let minimum = Number.POSITIVE_INFINITY
for (const value of values) {
if (value < minimum) minimum = value
}
function reduceTernaryMin (values) {
return values.reduce(
(minimum, num) => (minimum < num ? minimum : num),
- Infinity
+ Number.POSITIVE_INFINITY
)
}
* @returns
*/
function reduceMathMin (values) {
- return values.reduce((minimum, num) => Math.min(minimum, num), Infinity)
+ return values.reduce(
+ (minimum, num) => Math.min(minimum, num),
+ Number.POSITIVE_INFINITY
+ )
}
/**
*/
function loopSelect (tasksMap) {
let minKey
- let minValue = Infinity
+ let minValue = Number.POSITIVE_INFINITY
for (const [key, value] of tasksMap) {
if (value === 0) {
return key