nonNegative
function nonNegative(value: unknown): value is number;
The name breaks the convention the rest of the library follows: everywhere else a nonX prefix means “is not X”, and here it means “is a non-negative number”. isNonNegative says the same thing under the right name and is what new code should call.
Parameters
Parameter | Type | Description |
|---|---|---|
|
| The value to check. |
Returns
boolean — true when the value is a number and is not negative.
In TypeScript the guard narrows value to number inside the branch.
Examples
In use
nonNegative(0); // => true
nonNegative(-1); // => false
See also
Source
23 September 2026
This documentation was generated with AI (Claude) from the library's source code.