Skip to content

Commit 4902860

Browse files
authored
Fix(49472): Added docs for Set and Map types (#49522)
* wip: started map object * Feat: Added docs on collection objects * Accepted baselines. * Accepted baselines. * fix: removed unecessary comments * Adjusted JSDocs as requested * fix: adjusted more comments * fix: removed params without description
1 parent cd3bd55 commit 4902860

File tree

1 file changed

+62
-1
lines changed

1 file changed

+62
-1
lines changed

src/lib/es2015.collection.d.ts

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,36 @@
11
interface Map<K, V> {
2+
23
clear(): void;
4+
/**
5+
* @returns true if an element in the Map existed and has been removed, or false if the element does not exist.
6+
*/
37
delete(key: K): boolean;
8+
/**
9+
* Executes a provided function once per each key/value pair in the Map, in insertion order.
10+
*/
411
forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
12+
/**
13+
* 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.
14+
* @returns Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
15+
*/
516
get(key: K): V | undefined;
17+
/**
18+
* @returns boolean indicating whether an element with the specified key exists or not.
19+
*/
620
has(key: K): boolean;
21+
/**
22+
* 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.
23+
*/
724
set(key: K, value: V): this;
25+
/**
26+
* @returns the number of elements in the Map.
27+
*/
828
readonly size: number;
929
}
1030

1131
interface MapConstructor {
1232
new(): Map<any, any>;
13-
new<K, V>(entries?: readonly (readonly [K, V])[] | null): Map<K, V>;
33+
new <K, V>(entries?: readonly (readonly [K, V])[] | null): Map<K, V>;
1434
readonly prototype: Map<any, any>;
1535
}
1636
declare var Map: MapConstructor;
@@ -23,9 +43,23 @@ interface ReadonlyMap<K, V> {
2343
}
2444

2545
interface WeakMap<K extends object, V> {
46+
/**
47+
* Removes the specified element from the WeakMap.
48+
* @returns true if the element was successfully removed, or false if it was not present.
49+
*/
2650
delete(key: K): boolean;
51+
/**
52+
* @returns a specified element.
53+
*/
2754
get(key: K): V | undefined;
55+
/**
56+
* @returns a boolean indicating whether an element with the specified key exists or not.
57+
*/
2858
has(key: K): boolean;
59+
/**
60+
* Adds a new element with a specified key and value.
61+
* @param key Must be an object.
62+
*/
2963
set(key: K, value: V): this;
3064
}
3165

@@ -36,11 +70,28 @@ interface WeakMapConstructor {
3670
declare var WeakMap: WeakMapConstructor;
3771

3872
interface Set<T> {
73+
/**
74+
* Appends a new element with a specified value to the end of the Set.
75+
*/
3976
add(value: T): this;
77+
4078
clear(): void;
79+
/**
80+
* Removes a specified value from the Set.
81+
* @returns Returns true if an element in the Set existed and has been removed, or false if the element does not exist.
82+
*/
4183
delete(value: T): boolean;
84+
/**
85+
* Executes a provided function once per each value in the Set object, in insertion order.
86+
*/
4287
forEach(callbackfn: (value: T, value2: T, set: Set<T>) => void, thisArg?: any): void;
88+
/**
89+
* @returns a boolean indicating whether an element with the specified value exists in the Set or not.
90+
*/
4391
has(value: T): boolean;
92+
/**
93+
* @returns the number of (unique) elements in Set.
94+
*/
4495
readonly size: number;
4596
}
4697

@@ -57,8 +108,18 @@ interface ReadonlySet<T> {
57108
}
58109

59110
interface WeakSet<T extends object> {
111+
/**
112+
* Appends a new object to the end of the WeakSet.
113+
*/
60114
add(value: T): this;
115+
/**
116+
* Removes the specified element from the WeakSet.
117+
* @returns Returns true if the element existed and has been removed, or false if the element does not exist.
118+
*/
61119
delete(value: T): boolean;
120+
/**
121+
* @returns a boolean indicating whether an object exists in the WeakSet or not.
122+
*/
62123
has(value: T): boolean;
63124
}
64125

0 commit comments

Comments
 (0)