Fix isInRange silently returning false when range contains NaN

This commit is contained in:
Sindre Sorhus 2026-04-08 14:54:37 +07:00
parent 47415dc46a
commit ac46b5400d
2 changed files with 12 additions and 0 deletions

View file

@ -1274,6 +1274,14 @@ test('is.inRange', () => {
is.inRange(0, [1, 2, 3]);
});
assert.throws(() => {
is.inRange(5, [NaN, 10]);
}, TypeError);
assert.throws(() => {
is.inRange(5, [0, NaN]);
}, TypeError);
assert.doesNotThrow(() => {
isAssert.inRange(x, [0, 5]);
});