1 /*! *****************************************************************************
2 Copyright (c) Microsoft Corporation. All rights reserved.
3 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4 this file except in compliance with the License. You may obtain a copy of the
5 License at http://www.apache.org/licenses/LICENSE-2.0
7 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10 MERCHANTABLITY OR NON-INFRINGEMENT.
12 See the Apache Version 2.0 License for specific language governing permissions
13 and limitations under the License.
14 ***************************************************************************** */
18 /// <reference no-default-lib="true"/>
\r
21 interface WeakRef<T extends object> {
\r
22 readonly [Symbol.toStringTag]: "WeakRef";
\r
25 * Returns the WeakRef instance's target object, or undefined if the target object has been
\r
28 deref(): T | undefined;
\r
31 interface WeakRefConstructor {
\r
32 readonly prototype: WeakRef<any>;
\r
35 * Creates a WeakRef instance for the given target object.
\r
36 * @param target The target object for the WeakRef instance.
\r
38 new<T extends object>(target?: T): WeakRef<T>;
\r
41 declare var WeakRef: WeakRefConstructor;
\r
43 interface FinalizationRegistry {
\r
44 readonly [Symbol.toStringTag]: "FinalizationRegistry";
\r
47 * Registers an object with the registry.
\r
48 * @param target The target object to register.
\r
49 * @param heldValue The value to pass to the finalizer for this object. This cannot be the
\r
51 * @param unregisterToken The token to pass to the unregister method to unregister the target
\r
52 * object. If provided (and not undefined), this must be an object. If not provided, the target
\r
53 * cannot be unregistered.
\r
55 register(target: object, heldValue: any, unregisterToken?: object): void;
\r
58 * Unregisters an object from the registry.
\r
59 * @param unregisterToken The token that was used as the unregisterToken argument when calling
\r
60 * register to register the target object.
\r
62 unregister(unregisterToken: object): void;
\r
65 interface FinalizationRegistryConstructor {
\r
66 readonly prototype: FinalizationRegistry;
\r
69 * Creates a finalization registry with an associated cleanup callback
\r
70 * @param cleanupCallback The callback to call after an object in the registry has been reclaimed.
\r
72 new(cleanupCallback: (heldValue: any) => void): FinalizationRegistry;
\r
75 declare var FinalizationRegistry: FinalizationRegistryConstructor;
\r