Add is.infinite

This commit is contained in:
Melvin Philips 2017-10-05 00:18:25 -07:00
parent 27d15f40bd
commit e8f0733091
3 changed files with 13 additions and 0 deletions

View file

@ -161,4 +161,6 @@ is.inRange = (x, range) => {
throw new TypeError(`Invalid range: ${util.inspect(range)}`);
};
is.infinite = x => x === Infinity || x === -Infinity;
module.exports = is;

View file

@ -145,6 +145,9 @@ Check if `value` (number) is in the range of `0` to `upperBound`.
is.inRange(3, 10);
```
##### .infinite(value)
Check if `value` is Infinity or -Infinity.
## FAQ

View file

@ -358,3 +358,11 @@ test('is.inRange', t => {
m.inRange(0, [1, 2, 3]);
});
});
test('is.infinite', t => {
t.true(m.infinite(Infinity));
t.true(m.infinite(-Infinity));
t.false(m.infinite(NaN));
t.false(m.infinite(5));
t.false(m.infinite('hello world'));
});