Skip to content

Commit 6cd53d3

Browse files
committedJun 16, 2017
Add flow support
1 parent e9e8574 commit 6cd53d3

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
 

‎index.js.flow

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// @flow
2+
3+
declare class ThenPromise<+R> extends Promise<R> {
4+
constructor(callback: (
5+
resolve: (result: Promise<R> | R) => void,
6+
reject: (error: any) => void
7+
) => mixed): void;
8+
9+
then<U>(
10+
onFulfill?: (value: R) => Promise<U> | U,
11+
onReject?: (error: any) => Promise<U> | U
12+
): ThenPromise<U>;
13+
14+
catch<U>(
15+
onReject?: (error: any) => Promise<U> | U
16+
): ThenPromise<R | U>;
17+
18+
// Extensions specific to then/promise
19+
20+
/**
21+
* Attaches callbacks for the resolution and/or rejection of the ThenPromise, without returning a new promise.
22+
* @param onfulfilled The callback to execute when the ThenPromise is resolved.
23+
* @param onrejected The callback to execute when the ThenPromise is rejected.
24+
*/
25+
done(onfulfilled?: (value: R) => any, onrejected?: (reason: any) => any): void;
26+
27+
28+
/**
29+
* Calls a node.js style callback. If none is provided, the promise is returned.
30+
*/
31+
nodeify(callback: void | null): ThenPromise<R>;
32+
nodeify(callback: (err: Error, value: R) => void): void;
33+
34+
static resolve<T>(object: Promise<T> | T): ThenPromise<T>;
35+
static reject<T>(error?: any): ThenPromise<T>;
36+
static all<Elem, T:Iterable<Elem>>(promises: T): ThenPromise<$TupleMap<T, typeof $await>>;
37+
static race<T, Elem: Promise<T> | T>(promises: Array<Elem>): ThenPromise<T>;
38+
39+
// Extensions specific to then/promise
40+
41+
static denodeify(fn: Function): (...args: any[]) => ThenPromise<any>;
42+
static nodeify(fn: Function): Function;
43+
}
44+
module.exports = ThenPromise;

0 commit comments

Comments
 (0)
Please sign in to comment.