predictype

predictype v0.8.1


predictype / predicates/arrays/arrayState / arrayState

Function: arrayState()

arrayState(source, oper): boolean

Defined in: predicates/arrays/arrayState.ts:24

Checks if an array is empty or not, using the specified operation.

Parameters

source

any[]

The source array.

oper

ArrayStateOper

The state operation to perform (e.g. ‘is_empty’, ‘is_not_empty’).

Returns

boolean

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

Throws

If the operation is not recognized.

Example

const arr1 = [];
const arr2 = [1, 2, 3];

arrayState(arr1, 'is_empty'); // true
arrayState(arr2, 'is_not_empty'); // true

Remarks

Supported Operators: