Skip to content

weak ref

Nicholas Berlette edited this page Jun 19, 2025 · 1 revision

@nick/is/weak-ref

isWeakRef

Signature

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.

Parameters
Name Info
obj The value to check.
Returns

true if it is a WeakRef, otherwise false.

Category

Weak Collections

Examples

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

isWeakRef

Signature

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.

Parameters
Name Info
obj The value to check.
Returns

true if it is a WeakRef, otherwise false.

isWeakRef

Signature

function isWeakRef<T extends WeakKey>(obj: unknown): obj is WeakRef<T>;
Clone this wiki locally