CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
lib.es2021.weakref.d.ts77 linesDownload Raw Back to lib
1/*! *****************************************************************************2Copyright (c) Microsoft Corporation. All rights reserved.3Licensed under the Apache License, Version 2.0 (the "License"); you may not use4this file except in compliance with the License. You may obtain a copy of the5License at http://www.apache.org/licenses/LICENSE-2.06 7THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY8KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED9WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,10MERCHANTABILITY OR NON-INFRINGEMENT.11 12See the Apache Version 2.0 License for specific language governing permissions13and limitations under the License.14***************************************************************************** */15 16 17/// <reference lib="es2015.symbol.wellknown" />18 19interface WeakRef<T extends WeakKey> {20    readonly [Symbol.toStringTag]: "WeakRef";21 22    /**23     * Returns the WeakRef instance's target value, or undefined if the target value has been24     * reclaimed.25     * In es2023 the value can be either a symbol or an object, in previous versions only object is permissible.26     */27    deref(): T | undefined;28}29 30interface WeakRefConstructor {31    readonly prototype: WeakRef<any>;32 33    /**34     * Creates a WeakRef instance for the given target value.35     * In es2023 the value can be either a symbol or an object, in previous versions only object is permissible.36     * @param target The target value for the WeakRef instance.37     */38    new <T extends WeakKey>(target: T): WeakRef<T>;39}40 41declare var WeakRef: WeakRefConstructor;42 43interface FinalizationRegistry<T> {44    readonly [Symbol.toStringTag]: "FinalizationRegistry";45 46    /**47     * Registers a value with the registry.48     * In es2023 the value can be either a symbol or an object, in previous versions only object is permissible.49     * @param target The target value to register.50     * @param heldValue The value to pass to the finalizer for this value. This cannot be the51     * target value.52     * @param unregisterToken The token to pass to the unregister method to unregister the target53     * value. If not provided, the target cannot be unregistered.54     */55    register(target: WeakKey, heldValue: T, unregisterToken?: WeakKey): void;56 57    /**58     * Unregisters a value from the registry.59     * In es2023 the value can be either a symbol or an object, in previous versions only object is permissible.60     * @param unregisterToken The token that was used as the unregisterToken argument when calling61     * register to register the target value.62     */63    unregister(unregisterToken: WeakKey): boolean;64}65 66interface FinalizationRegistryConstructor {67    readonly prototype: FinalizationRegistry<any>;68 69    /**70     * Creates a finalization registry with an associated cleanup callback71     * @param cleanupCallback The callback to call after a value in the registry has been reclaimed.72     */73    new <T>(cleanupCallback: (heldValue: T) => void): FinalizationRegistry<T>;74}75 76declare var FinalizationRegistry: FinalizationRegistryConstructor;77