-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.d.ts
46 lines (40 loc) · 1.64 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
declare interface ES6Promise<T> extends PromiseLike<T> {
_state: PromiseState;
_fulfillReactions: PromiseReaction<T>[];
_rejectReactions: PromiseReaction<T>[];
_result: T
_isHandled: boolean;
then<U, V>(
onFulfilled?: (value: T) => U | ES6Promise<U>,
onRejected?: (reason: T) => V | ES6Promise<V>
): ES6Promise<U | V>;
catch<U>(onRejected?: (reason: T) => U | ES6Promise<U>): ES6Promise<U>;
finally(onFinally?: () => void): ES6Promise<T>;
}
declare const enum PromiseState {
Pending = 'pending',
Fulfilled = 'fulfilled',
Rejected = 'rejected',
}
declare interface PromiseReaction<T, U = unknown> {
Capability: PromiseCapability<U>;
Type: 'Fulfill' | 'Reject';
Handler: (value: T) => U | ES6Promise<U>;
}
declare interface PromiseCapability<T> {
Resolve: PromiseResolveFunction<T>;
Reject: PromiseRejectFunction;
Promise: ES6Promise<T>;
}
declare type PromiseResolveFunction<T> = (value: T | ES6Promise<T>) => void;
declare type PromiseRejectFunction = (value: unknown) => void;
declare type PromiseExecutor<T> = (resolve?: PromiseResolveFunction<T>, reject?: PromiseRejectFunction) => void
declare interface ES6PromiseConstructor {
new <T>(executor: PromiseExecutor<T>): ES6Promise<T>;
resolve<T>(value?: T | ES6Promise<T>): ES6Promise<T>;
reject<T>(reason?: T): ES6Promise<T>;
all<T>(iterable: Iterable<T | ES6Promise<T>>): ES6Promise<T[]>;
race<T>(iterable: Iterable<T | ES6Promise<T>>): ES6Promise<T>;
allSettled<T>(iterable: Iterable<T | ES6Promise<T>>): ES6Promise<PromiseSettledResult<T>[]>;
any<T>(iterable: Iterable<T | ES6Promise<T>>): ES6Promise<T>;
}