Add finiteNumber, nonNegativeNumber, and positiveInteger predicates

This commit is contained in:
Sindre Sorhus 2026-04-08 16:12:51 +07:00
parent ac46b5400d
commit 63be5c0c19
3 changed files with 150 additions and 0 deletions

View file

@ -463,6 +463,10 @@ function foo() {
foo();
```
##### .finiteNumber(value)
Check if `value` is a number and is finite. Excludes `Infinity` and `-Infinity`.
##### .positiveNumber(value)
Check if `value` is a number and is more than 0.
@ -471,6 +475,14 @@ Check if `value` is a number and is more than 0.
Check if `value` is a number and is less than 0.
##### .nonNegativeNumber(value)
Check if `value` is a number and is 0 or more.
##### .positiveInteger(value)
Check if `value` is an integer and is more than 0.
##### .inRange(value, range)
Check if `value` (number) is in the given `range`. The range is an array of two values, lower bound and upper bound, in no specific order.