CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
lib.es2015.proxy.d.ts127 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 17interface ProxyHandler<T extends object> {18    /**19     * A trap method for a function call.20     * @param target The original callable object which is being proxied.21     */22    apply?(target: T, thisArg: any, argArray: any[]): any;23 24    /**25     * A trap for the `new` operator.26     * @param target The original object which is being proxied.27     * @param newTarget The constructor that was originally called.28     */29    construct?(target: T, argArray: any[], newTarget: Function): object;30 31    /**32     * A trap for `Object.defineProperty()`.33     * @param target The original object which is being proxied.34     * @returns A `Boolean` indicating whether or not the property has been defined.35     */36    defineProperty?(target: T, property: string | symbol, attributes: PropertyDescriptor): boolean;37 38    /**39     * A trap for the `delete` operator.40     * @param target The original object which is being proxied.41     * @param p The name or `Symbol` of the property to delete.42     * @returns A `Boolean` indicating whether or not the property was deleted.43     */44    deleteProperty?(target: T, p: string | symbol): boolean;45 46    /**47     * A trap for getting a property value.48     * @param target The original object which is being proxied.49     * @param p The name or `Symbol` of the property to get.50     * @param receiver The proxy or an object that inherits from the proxy.51     */52    get?(target: T, p: string | symbol, receiver: any): any;53 54    /**55     * A trap for `Object.getOwnPropertyDescriptor()`.56     * @param target The original object which is being proxied.57     * @param p The name of the property whose description should be retrieved.58     */59    getOwnPropertyDescriptor?(target: T, p: string | symbol): PropertyDescriptor | undefined;60 61    /**62     * A trap for the `[[GetPrototypeOf]]` internal method.63     * @param target The original object which is being proxied.64     */65    getPrototypeOf?(target: T): object | null;66 67    /**68     * A trap for the `in` operator.69     * @param target The original object which is being proxied.70     * @param p The name or `Symbol` of the property to check for existence.71     */72    has?(target: T, p: string | symbol): boolean;73 74    /**75     * A trap for `Object.isExtensible()`.76     * @param target The original object which is being proxied.77     */78    isExtensible?(target: T): boolean;79 80    /**81     * A trap for `Reflect.ownKeys()`.82     * @param target The original object which is being proxied.83     */84    ownKeys?(target: T): ArrayLike<string | symbol>;85 86    /**87     * A trap for `Object.preventExtensions()`.88     * @param target The original object which is being proxied.89     */90    preventExtensions?(target: T): boolean;91 92    /**93     * A trap for setting a property value.94     * @param target The original object which is being proxied.95     * @param p The name or `Symbol` of the property to set.96     * @param receiver The object to which the assignment was originally directed.97     * @returns A `Boolean` indicating whether or not the property was set.98     */99    set?(target: T, p: string | symbol, newValue: any, receiver: any): boolean;100 101    /**102     * A trap for `Object.setPrototypeOf()`.103     * @param target The original object which is being proxied.104     * @param newPrototype The object's new prototype or `null`.105     */106    setPrototypeOf?(target: T, v: object | null): boolean;107}108 109interface ProxyConstructor {110    /**111     * Creates a revocable Proxy object.112     * @param target A target object to wrap with Proxy.113     * @param handler An object whose properties define the behavior of Proxy when an operation is attempted on it.114     */115    revocable<T extends object>(target: T, handler: ProxyHandler<T>): { proxy: T; revoke: () => void; };116 117    /**118     * Creates a Proxy object. The Proxy object allows you to create an object that can be used in place of the119     * original object, but which may redefine fundamental Object operations like getting, setting, and defining120     * properties. Proxy objects are commonly used to log property accesses, validate, format, or sanitize inputs.121     * @param target A target object to wrap with Proxy.122     * @param handler An object whose properties define the behavior of Proxy when an operation is attempted on it.123     */124    new <T extends object>(target: T, handler: ProxyHandler<T>): T;125}126declare var Proxy: ProxyConstructor;127