-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Expand file tree
/
Copy pathesnext.collection.d.ts
More file actions
31 lines (29 loc) · 1.77 KB
/
esnext.collection.d.ts
File metadata and controls
31 lines (29 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/// <reference lib="es2025.collection" />
interface Map<K, V> {
/**
* Returns a specified element from the Map object.
* If no element is associated with the specified key, a new element with the value `defaultValue` will be inserted into the Map and returned.
* @returns The element associated with the specified key, which will be `defaultValue` if no element previously existed.
*/
getOrInsert(key: K, defaultValue: V): V;
/**
* Returns a specified element from the Map object.
* If no element is associated with the specified key, the result of passing the specified key to the `callback` function will be inserted into the Map and returned.
* @returns The element associated with the specific key, which will be the newly computed value if no element previously existed.
*/
getOrInsertComputed(key: K, callback: (key: K) => V): V;
}
interface WeakMap<K extends WeakKey, V> {
/**
* Returns a specified element from the WeakMap object.
* If no element is associated with the specified key, a new element with the value `defaultValue` will be inserted into the WeakMap and returned.
* @returns The element associated with the specified key, which will be `defaultValue` if no element previously existed.
*/
getOrInsert(key: K, defaultValue: V): V;
/**
* Returns a specified element from the WeakMap object.
* If no element is associated with the specified key, the result of passing the specified key to the `callback` function will be inserted into the WeakMap and returned.
* @returns The element associated with the specific key, which will be the newly computed value if no element previously existed.
*/
getOrInsertComputed(key: K, callback: (key: K) => V): V;
}