UNPKG

3.31 kBTypeScriptView Raw
1// Type definitions for es6-collections v0.5.1
2// Project: https://github.com/WebReflection/es6-collections/
3// Definitions by: Ron Buckton <http://github.com/rbuckton>
4// Definitions: https://github.com/borisyankov/DefinitelyTyped
5
6/* *****************************************************************************
7Copyright (c) Microsoft Corporation. All rights reserved.
8Licensed under the Apache License, Version 2.0 (the "License"); you may not use
9this file except in compliance with the License. You may obtain a copy of the
10License at http://www.apache.org/licenses/LICENSE-2.0
11
12THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
14WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
15MERCHANTABLITY OR NON-INFRINGEMENT.
16
17See the Apache Version 2.0 License for specific language governing permissions
18and limitations under the License.
19***************************************************************************** */
20
21interface IteratorResult<T> {
22 done: boolean;
23 value?: T;
24}
25
26interface Iterator<T> {
27 next(value?: any): IteratorResult<T>;
28 return?(value?: any): IteratorResult<T>;
29 throw?(e?: any): IteratorResult<T>;
30}
31
32interface ForEachable<T> {
33 forEach(callbackfn: (value: T) => void): void;
34}
35
36interface Map<K, V> {
37 clear(): void;
38 delete(key: K): boolean;
39 forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
40 get(key: K): V;
41 has(key: K): boolean;
42 set(key: K, value?: V): Map<K, V>;
43 entries(): Iterator<[K, V]>;
44 keys(): Iterator<K>;
45 values(): Iterator<V>;
46 size: number;
47}
48
49interface MapConstructor {
50 new <K, V>(): Map<K, V>;
51 new <K, V>(iterable: ForEachable<[K, V]>): Map<K, V>;
52 prototype: Map<any, any>;
53}
54
55declare var Map: MapConstructor;
56
57interface Set<T> {
58 add(value: T): Set<T>;
59 clear(): void;
60 delete(value: T): boolean;
61 forEach(callbackfn: (value: T, index: T, set: Set<T>) => void, thisArg?: any): void;
62 has(value: T): boolean;
63 entries(): Iterator<[T, T]>;
64 keys(): Iterator<T>;
65 values(): Iterator<T>;
66 size: number;
67}
68
69interface SetConstructor {
70 new <T>(): Set<T>;
71 new <T>(iterable: ForEachable<T>): Set<T>;
72 prototype: Set<any>;
73}
74
75declare var Set: SetConstructor;
76
77interface WeakMap<K, V> {
78 delete(key: K): boolean;
79 clear(): void;
80 get(key: K): V;
81 has(key: K): boolean;
82 set(key: K, value?: V): WeakMap<K, V>;
83}
84
85interface WeakMapConstructor {
86 new <K, V>(): WeakMap<K, V>;
87 new <K, V>(iterable: ForEachable<[K, V]>): WeakMap<K, V>;
88 prototype: WeakMap<any, any>;
89}
90
91declare var WeakMap: WeakMapConstructor;
92
93interface WeakSet<T> {
94 delete(value: T): boolean;
95 clear(): void;
96 add(value: T): WeakSet<T>;
97 has(value: T): boolean;
98}
99
100interface WeakSetConstructor {
101 new <T>(): WeakSet<T>;
102 new <T>(iterable: ForEachable<T>): WeakSet<T>;
103 prototype: WeakSet<any>;
104}
105
106declare var WeakSet: WeakSetConstructor;
107
108declare module "es6-collections" {
109 var Map: MapConstructor;
110 var Set: SetConstructor;
111 var WeakMap: WeakMapConstructor;
112 var WeakSet: WeakSetConstructor;
113}
\No newline at end of file