predictype

predictype v0.8.1


predictype / predicates/numbers/numberState / numberState

Function: numberState()

numberState(source, oper): boolean

Defined in: predicates/numbers/numberState.ts:28

Checks the state of a number (integer, float, finite, positive, negative, zero) using the specified operation.

Parameters

source

number

The number to check.

oper

NumberStateOper

The state operation to perform (e.g. ‘is_integer’, ‘is_float’).

Returns

boolean

True if the state check is valid according to the operator, otherwise false.

Throws

If the operation is not recognized.

Example

const n = 5;

numberState(n, 'is_integer'); // true
numberState(3.14, 'is_float'); // true
numberState(0, 'is_zero'); // true

Remarks

Supported Operators: