UNPKG

758 BTypeScriptView Raw
1export = inflight;
2
3type Resolvable<T> = PromiseLike<T> | T;
4/**
5 * @param unique A globally-unique key that is used to identify the call to this
6 * function. It determines how to cache the inlfight request. eg. a url or
7 * filename or whatever.
8 * @param doFly The function that actually carries out the request, eg. fetches
9 * the url or whatever.
10 * @returns One promise as long as the `doFly()` promise is pending. Note that
11 * if `bluebird` is installed, this promise will be a Bluebird promise.
12 */
13declare function inflight<T>(
14 unique: Resolvable<string> | Resolvable<ReadonlyArray<Resolvable<string>>>,
15 doFly: () => Resolvable<T>,
16): Promise<T>;
17
18declare namespace inflight {
19 const active: {
20 [key: string]: Promise<any>;
21 };
22}