predictype / predicates/maps/mapKey / mapKey
mapKey<
K
,V
>(source
,oper
,key
):boolean
Defined in: predicates/maps/mapKey.ts:26
Checks if a Map contains (or lacks) a specific key using the specified operation.
K
V
Map
<K
, V
>
The Map to check.
The key operation to perform (e.g. ‘has_key’, ‘lacks_key’).
K
The key to check for.
boolean
True if the key check is valid according to the operator, otherwise false.
If the operation is not recognized.
const m = new Map([[1, 'a']]);
const key1 = 1;
const key2 = 2;
mapKey(m, 'has_key', key1); // true
mapKey(m, 'lacks_key', key2); // true
Supported Operators: