predictype / predicates/sets/setState / setState
setState<
T
>(source
,oper
):boolean
Defined in: predicates/sets/setState.ts:29
Checks the state of a set using the specified operation.
T
Set
<T
>
The set to check.
The state operation to perform (e.g. ‘is_empty’, ‘has_primitives’).
boolean
True if the state check is valid according to the operator, otherwise false.
If the operation is not recognized.
const a = new Set();
const b = new Set([1]);
const c = new Set([1, 'hello', { id: 1 }]);
setState(a, 'is_empty'); // true
setState(b, 'is_not_empty'); // true
setState(c, 'has_primitives'); // true
setState(c, 'has_objects'); // true
Supported Operators: