predictype

predictype v0.8.1


predictype / predicates/objects/objectState / objectState

Function: objectState()

objectState(source, oper): boolean

Defined in: predicates/objects/objectState.ts:17

Checks state-related properties of an object (is_empty, is_not_empty, is_plain, is_frozen, is_sealed).

Parameters

source

object

The object to check.

oper

ObjectStateOper

The state operation to perform.

Returns

boolean

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

Throws

If the operation is not recognized.

Example

objectState({}, 'is_empty'); // true
objectState({ a: 1 }, 'is_not_empty'); // true
objectState(Object.freeze({}), 'is_frozen'); // true