-
-
Notifications
You must be signed in to change notification settings - Fork 0
weak map
Nicholas Berlette edited this page Jun 19, 2025
·
1 revision
function isWeakMap<K extends WeakKey, V = any>(
it: WeakMap<K, V> | null | undefined,
): it is WeakMap<K, V>;Checks if it is a WeakMap object. For more
information on this language feature, refer to the
MDN Documentation.
| Name | Info |
|---|---|
it |
The value to check. |
true if it is a WeakMap, otherwise false.
Weak Collections
WeakMap
import { isWeakMap } from "jsr:@nick/is/weak-map";
const strong = new Map([[{ a: 1 }, 1], [{ b: 2 }, 2]]);
const weak1 = new WeakMap([[{ a: 1 }, 1], [{ b: 2 }, 2]]);
const weak2 = new WeakSet([{ a: 1 }, { b: 2 }]);
isWeakMap(strong); // false
isWeakMap(weak1); // true
isWeakMap(weak2); // falsefunction isWeakMap<K extends WeakKey, V = any>(
it: unknown,
): it is WeakMap<K, V>;Checks if obj is a WeakMap object. For more
information on this language feature, see the
MDN Reference.
| Name | Info |
|---|---|
obj |
The value to check. |
true if it is a WeakMap, otherwise false.
Weak Collections
WeakMap
function isWeakMap<K extends WeakKey, V = any>(
obj: unknown,
): obj is WeakMap<K, V>;