• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*! *****************************************************************************
2Copyright (c) Microsoft Corporation. All rights reserved.
3Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4this file except in compliance with the License. You may obtain a copy of the
5License at http://www.apache.org/licenses/LICENSE-2.0
6
7THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10MERCHANTABLITY OR NON-INFRINGEMENT.
11
12See the Apache Version 2.0 License for specific language governing permissions
13and limitations under the License.
14***************************************************************************** */
15
16
17
18/// <reference no-default-lib="true"/>
19
20
21interface Map<K, V> {
22
23    clear(): void;
24    /**
25     * @returns true if an element in the Map existed and has been removed, or false if the element does not exist.
26     */
27    delete(key: K): boolean;
28    /**
29     * Executes a provided function once per each key/value pair in the Map, in insertion order.
30     */
31    forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
32    /**
33     * Returns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.
34     * @returns Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
35     */
36    get(key: K): V | undefined;
37    /**
38     * @returns boolean indicating whether an element with the specified key exists or not.
39     */
40    has(key: K): boolean;
41    /**
42     * Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated.
43     */
44    set(key: K, value: V): this;
45    /**
46     * @returns the number of elements in the Map.
47     */
48    readonly size: number;
49}
50
51interface MapConstructor {
52    new(): Map<any, any>;
53    new <K, V>(entries?: readonly (readonly [K, V])[] | null): Map<K, V>;
54    readonly prototype: Map<any, any>;
55}
56declare var Map: MapConstructor;
57
58interface ReadonlyMap<K, V> {
59    forEach(callbackfn: (value: V, key: K, map: ReadonlyMap<K, V>) => void, thisArg?: any): void;
60    get(key: K): V | undefined;
61    has(key: K): boolean;
62    readonly size: number;
63}
64
65interface WeakMap<K extends object, V> {
66    /**
67     * Removes the specified element from the WeakMap.
68     * @returns true if the element was successfully removed, or false if it was not present.
69     */
70    delete(key: K): boolean;
71    /**
72     * @returns a specified element.
73     */
74    get(key: K): V | undefined;
75    /**
76     * @returns a boolean indicating whether an element with the specified key exists or not.
77     */
78    has(key: K): boolean;
79    /**
80     * Adds a new element with a specified key and value.
81     * @param key Must be an object.
82     */
83    set(key: K, value: V): this;
84}
85
86interface WeakMapConstructor {
87    new <K extends object = object, V = any>(entries?: readonly [K, V][] | null): WeakMap<K, V>;
88    readonly prototype: WeakMap<object, any>;
89}
90declare var WeakMap: WeakMapConstructor;
91
92interface Set<T> {
93    /**
94     * Appends a new element with a specified value to the end of the Set.
95     */
96    add(value: T): this;
97
98    clear(): void;
99    /**
100     * Removes a specified value from the Set.
101     * @returns Returns true if an element in the Set existed and has been removed, or false if the element does not exist.
102     */
103    delete(value: T): boolean;
104    /**
105     * Executes a provided function once per each value in the Set object, in insertion order.
106     */
107    forEach(callbackfn: (value: T, value2: T, set: Set<T>) => void, thisArg?: any): void;
108    /**
109     * @returns a boolean indicating whether an element with the specified value exists in the Set or not.
110     */
111    has(value: T): boolean;
112    /**
113     * @returns the number of (unique) elements in Set.
114     */
115    readonly size: number;
116}
117
118interface SetConstructor {
119    new <T = any>(values?: readonly T[] | null): Set<T>;
120    readonly prototype: Set<any>;
121}
122declare var Set: SetConstructor;
123
124interface ReadonlySet<T> {
125    forEach(callbackfn: (value: T, value2: T, set: ReadonlySet<T>) => void, thisArg?: any): void;
126    has(value: T): boolean;
127    readonly size: number;
128}
129
130interface WeakSet<T extends object> {
131    /**
132     * Appends a new object to the end of the WeakSet.
133     */
134    add(value: T): this;
135    /**
136     * Removes the specified element from the WeakSet.
137     * @returns Returns true if the element existed and has been removed, or false if the element does not exist.
138     */
139    delete(value: T): boolean;
140    /**
141     * @returns a boolean indicating whether an object exists in the WeakSet or not.
142     */
143    has(value: T): boolean;
144}
145
146interface WeakSetConstructor {
147    new <T extends object = object>(values?: readonly T[] | null): WeakSet<T>;
148    readonly prototype: WeakSet<object>;
149}
150declare var WeakSet: WeakSetConstructor;
151