-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
30 lines (27 loc) · 1.05 KB
/
index.d.ts
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
interface DefaultMap<K, V> extends Map<K, V> {
/**
* This attribute is initialized from the first argument to the constructor, if present, or to `undefined`, if absent.
* `.get(key)` will throw an error if `.defaultFactory` is `undefined`.
*/
defaultFactory: (() => V) | undefined;
/**
* Returns the `value` corresponding to `key`, or adds a new default value to the map using the `defaultFactory` function.
*/
get(key: K): V;
}
interface DefaultMapConstructor {
/**
* Creates a new `DefaultMap`. Both arguments are optional.
* @param defaultFactory a function that returns the default value for an entry. It takes no arguments.
* @param entries an array or iterable of key-value pairs to initialize the map with.
*/
new (): DefaultMap<any, any>;
new <V>(defaultFactory?: () => V): DefaultMap<any, V>;
new <K, V>(
defaultFactory?: () => V,
entries?: Iterable<readonly [K, V]> | null
): DefaultMap<K, V>;
readonly prototype: DefaultMap<any, any>;
}
declare const DefaultMap: DefaultMapConstructor;
export { DefaultMap };