apps-script-utils 2.1.1 Help

isNonNegative

function isNonNegative(value: unknown): value is number;

NaN does not qualify: it is a number, but it is neither negative nor non-negative. The infinities behave as their sign suggests, so Infinity qualifies and -Infinity does not.

isX and nonX answer a question and never interrupt control flow; requireX and requireNonX hand the value back or throw. The scheme is explained in Validation conventions.

Parameters

Parameter

Type

Description

value

unknown

The value to check.

Returns

boolean — true when the value is a number that is not negative; otherwise false.

In TypeScript the guard narrows value to number inside the branch.

Examples

What passes and what does not

isNonNegative(0); // => true isNonNegative(-0); // => true isNonNegative(42); // => true isNonNegative(Infinity); // => true isNonNegative(-1); // => false isNonNegative(NaN); // => false isNonNegative("1"); // => false

See also

Source

src/lang/number/isNonNegative.ts

23 September 2026

This documentation was generated with AI (Claude) from the library's source code.