1 | // Type definitions for promise-inflight 1.0
|
2 | // Project: https://github.com/iarna/promise-inflight#readme
|
3 | // Definitions by: Emily Marigold Klassen <https://github.com/forivall>
|
4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
5 |
|
6 | export = inflight;
|
7 |
|
8 | type Resolvable<T> = PromiseLike<T> | T;
|
9 | /**
|
10 | * @param unique A globally-unique key that is used to identify the call to this
|
11 | * function. It determines how to cache the inlfight request. eg. a url or
|
12 | * filename or whatever.
|
13 | * @param doFly The function that actually carries out the request, eg. fetches
|
14 | * the url or whatever.
|
15 | * @returns One promise as long as the `doFly()` promise is pending. Note that
|
16 | * if `bluebird` is installed, this promise will be a Bluebird promise.
|
17 | */
|
18 | declare function inflight<T>(
|
19 | unique: Resolvable<string> | Resolvable<ReadonlyArray<Resolvable<string>>>,
|
20 | doFly: () => Resolvable<T>
|
21 | ): Promise<T>;
|
22 |
|
23 | declare namespace inflight {
|
24 | const active: {
|
25 | [key: string]: Promise<any>
|
26 | };
|
27 | }
|