UNPKG

xflight

Version:

Handle inflight promise to avoid async duplication

21 lines (20 loc) 798 B
declare class Inflight<T = any> { private _count; private _inflights; Promise: PromiseConstructor; constructor(xPromise?: PromiseConstructor); promise(key: string, func: () => Promise<T>): Promise<T>; add(key: string, value: Promise<T>, now?: number): Promise<T>; get(key: string): T | undefined; remove(key: string): void; get isEmpty(): boolean; get count(): number; getStartTime(key: string): number | undefined; time(key: string, now?: number): number; elapseTime(key: string, now?: number): number; getCheckTime(key: string): number | undefined; lastCheckTime(key: string, now?: number): number; elapseCheckTime(key: string, now?: number): number; resetCheckTime(key?: string, now?: number): this; } export default Inflight;