Interface FinalizationRegistry<T>

    interface FinalizationRegistry<T> {
        [toStringTag]: "FinalizationRegistry";
        register(target: WeakKey, heldValue: T, unregisterToken?: WeakKey): void;
        unregister(unregisterToken: WeakKey): boolean;
    }

    Type Parameters

    • T

    Properties

    [toStringTag]: "FinalizationRegistry"

    Methods

    • Registers a value with the registry. In es2023 the value can be either a symbol or an object, in previous versions only object is permissible.

      Parameters

      • target: WeakKey

        The target value to register.

      • heldValue: T

        The value to pass to the finalizer for this value. This cannot be the target value.

      • OptionalunregisterToken: WeakKey

        The token to pass to the unregister method to unregister the target value. If not provided, the target cannot be unregistered.

      Returns void

    • Unregisters a value from the registry. In es2023 the value can be either a symbol or an object, in previous versions only object is permissible.

      Parameters

      • unregisterToken: WeakKey

        The token that was used as the unregisterToken argument when calling register to register the target value.

      Returns boolean