forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pinkyswear.d.ts
235 lines (207 loc) · 9.37 KB
/
pinkyswear.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
// Type definitions for PinkySwear v2.2.2
// Project: https://github.com/timjansen/PinkySwear.js
// Definitions by: Chance Snow <https://github.com/chances/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/*
* PinkySwear.js 2.2.2 - Minimalistic implementation of the Promises/A+ spec
*
* Public Domain. Use, modify and distribute it any way you like. No attribution required.
*
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
declare namespace PinkySwear {
interface Promise {
/**
* Get the promise's current state; true if fulfilled, false if rejected, and undefined, otherwise.
*/
(): boolean;
/**
* Fulfill or reject the promise.
*
* @param fulfilled true to fulfill promise, false to reject
* @param values Value(s) with which to fulfill or reject the promise
* @returns PinkySwear.Promise
*/
(fulfilled: boolean, ...values: any[]): Promise;
/**
* Called when or if the promise is either resolved or rejected.
*
* @returns PinkySwear.Promise
*/
then(): Promise;
/**
* Called when or if the promise is either resolved or rejected.
*
* @param onFulfilled Called when or if the promise is resolved.
* @param onRejected Called when or if the promise is rejected.
* @returns PinkySwear.Promise
*/
then(onFulfilled?: () => Promise, onRejected?: () => void): Promise;
/**
* Called when or if the promise is either resolved or rejected.
*
* @param onFulfilled Called when or if the promise is resolved.
* @param onRejected Called when or if the promise is rejected.
* @returns PinkySwear.Promise
*/
then(onFulfilled?: () => void, onRejected?: () => void): Promise;
/**
* Called when or if the promise is either resolved or rejected.
*
* @param onFulfilled Called when or if the promise is resolved.
* @param onRejected Called when or if the promise is rejected.
* @returns PinkySwear.Promise
*/
then(onFulfilled?: () => any, onRejected?: () => void): Promise;
/**
* onFulfilled is called when or if the promise is resolved.
* onRejected is called when or if the promise is rejected.
*
* @param onFulfilled Called when or if the promise is resolved.
* @param onRejected Called when or if the promise is rejected.
* @returns PinkySwear.Promise
*/
then(onFulfilled?: (...values: any[]) => Promise, onRejected?: (...values: any[]) => void): Promise;
/**
* onFulfilled is called when or if the promise is resolved.
* onRejected is called when or if the promise is rejected.
*
* @param onFulfilled Called when or if the promise is resolved.
* @param onRejected Called when or if the promise is rejected.
* @returns PinkySwear.Promise
*/
then(onFulfilled?: (...values: any[]) => void, onRejected?: (...values: any[]) => void): Promise;
/**
* onFulfilled is called when or if the promise is resolved.
* onRejected is called when or if the promise is rejected.
*
* @param onFulfilled Called when or if the promise is resolved.
* @param onRejected Called when or if the promise is rejected.
* @returns PinkySwear.Promise
*/
then(onFulfilled?: (...values: any[]) => any, onRejected?: (...values: any[]) => void): Promise;
/**
* onFulfilled is called when or if the promise is resolved.
* onRejected is called when or if the promise is rejected.
*
* @param onFulfilled Called when or if the promise is resolved.
* @param onRejected Called when or if the promise is rejected.
* @returns PinkySwear.Promise
*/
then(onFulfilled?: (...values: any[]) => Promise, onRejected?: (error?: TypeError) => void): Promise;
/**
* onFulfilled is called when or if the promise is resolved.
* onRejected is called when or if the promise is rejected.
*
* @param onFulfilled Called when or if the promise is resolved.
* @param onRejected Called when or if the promise is rejected.
* @returns PinkySwear.Promise
*/
then(onFulfilled?: (...values: any[]) => void, onRejected?: (error: TypeError) => void): Promise;
/**
* onFulfilled is called when or if the promise is resolved.
* onRejected is called when or if the promise is rejected.
*
* @param onFulfilled Called when or if the promise is resolved.
* @param onRejected Called when or if the promise is rejected.
* @returns PinkySwear.Promise
*/
then(onFulfilled?: (...values: any[]) => any, onRejected?: (error: TypeError) => void): Promise;
}
interface GenericPromise<T> extends Promise {
/**
* Fulfill or reject the promise.
*
* @param fulfilled true to fulfill promise, false to reject
* @param value Value with which to fulfill or reject the promise
*/
(fulfilled: boolean, value: T): boolean;
/**
* onFulfilled is called when or if the promise is resolved.
* onRejected is called when or if the promise is rejected.
*
* @param onFulfilled Called when or if the promise is resolved.
* @param onRejected Called when or if the promise is rejected.
* @returns PinkySwear.GenericPromise
*/
then<G>(onFulfilled?: (value: T) => G, onRejected?: (value: T) => void): GenericPromise<G>;
/**
* onFulfilled is called when or if the promise is resolved.
* onRejected is called when or if the promise is rejected.
*
* @param onFulfilled Called when or if the promise is resolved.
* @param onRejected Called when or if the promise is rejected.
* @returns PinkySwear.GenericPromise
*/
then<G>(onFulfilled?: (value: T) => GenericPromise<G>, onRejected?: (value: T) => void): GenericPromise<G>;
/**
* onFulfilled is called when or if the promise is resolved.
* onRejected is called when or if the promise is rejected.
*
* @param onFulfilled Called when or if the promise is resolved.
* @param onRejected Called when or if the promise is rejected.
* @returns PinkySwear.Promise
*/
then(onFulfilled?: (value: T) => void, onRejected?: (value: T) => void): Promise;
/**
* onFulfilled is called when or if the promise is resolved.
* onRejected is called when or if the promise is rejected.
*
* @param onFulfilled Called when or if the promise is resolved.
* @param onRejected Called when or if the promise is rejected.
* @returns PinkySwear.GenericPromise
*/
then<G>(onFulfilled?: (value: T) => G, onRejected?: (error: TypeError) => void): GenericPromise<G>;
/**
* onFulfilled is called when or if the promise is resolved.
* onRejected is called when or if the promise is rejected.
*
* @param onFulfilled Called when or if the promise is resolved.
* @param onRejected Called when or if the promise is rejected.
* @returns PinkySwear.GenericPromise
*/
then<G>(onFulfilled?: (value: T) => GenericPromise<G>, onRejected?: (error: TypeError) => void): GenericPromise<G>;
/**
* onFulfilled is called when or if the promise is resolved.
* onRejected is called when or if the promise is rejected.
*
* @param onFulfilled Called when or if the promise is resolved.
* @param onRejected Called when or if the promise is rejected.
* @returns PinkySwear.Promise
*/
then(onFulfilled?: (value: T) => void, onRejected?: (error: TypeError) => void): Promise;
}
}
interface PinkySwearStatic {
/**
* Create a new generic promise in pending state that promises a value of a specific type and that also extends
* the returned generic promise object as specified in an extend function.
*
* @param extend Called when the promise is created and is ready to be extended.
* @returns PinkySwear.GenericPromise
*/
<T>(extend: (promise: PinkySwear.GenericPromise<T>) => PinkySwear.GenericPromise<T>): PinkySwear.GenericPromise<T>;
/**
* Create a new generic promise in pending state that promises a value of a specific type.
*
* @see PinkySwear.GenericPromise
* @returns PinkySwear.GenericPromise
*/
<T>(): PinkySwear.GenericPromise<T>;
/**
* Create a new promise in pending state that promises a value of a specific type and that also extends the
* returned promise object as specified in an extend function.
*
* @param extend Called when the promise is created and is ready to be extended.
* @returns PinkySwear.Promise
*/
<T>(extend: (promise: PinkySwear.Promise) => PinkySwear.Promise): PinkySwear.Promise;
/**
* Create a new promise in pending state that promises a value or set of values.
*
* @see PinkySwear.Promise
* @returns PinkySwear.Promise
*/
(): PinkySwear.Promise;
}
declare var pinkySwear: PinkySwearStatic;