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