Skip to main content

isMap

A function that checks whether a given argument is a Map object.

Useful for type checking and narrowing the type of the argument to Map.


Code

🔗 View source code

Interface

typescript
function isMap(value: unknown): value is Map<any, any>

Usage

typescript
import { isMap } from '@modern-kit/utils';

isMap(new Map()) // true
isMap(new Map([['hello', 5],['world', 5]])) // true

isMap([]) // false
isMap({}) // false
isMap(new Set()) // false
isMap(new WeakMap()) // false
isMap(new Date()) // false
isMap(null) // false
isMap(undefined) // false