mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-24 03:32:58 +03:00
2acc21175d
* feat : add isMap function * feat : add isMap bench * docs : isMap
776 B
776 B
isMap
Checks if the given value is a Map
.
This function tests whether the provided value is an instance of Map
.
It returns true
if the value is a Map
, and false
otherwise.
This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to Map
.
Signature
function isMap(value: unknown): value is Map<any, any>;
Parameters
value
(unknown
): The value to check if it is aMap
.
Returns
(value is Map<any, any>
): true if the value is a Map
, false otherwise.
Examples
const value1 = new Map();
const value2 = new Set();
const value3 = new WeakMap();
console.log(isMap(value1)); // true
console.log(isMap(value2)); // false
console.log(isMap(value3)); // false