UNPKG

@devgrid/common

Version:
46 lines (45 loc) 1.92 kB
export type Deferred = { resolve?: (value: any) => void; reject?: (reason?: any) => void; promise?: Promise<any>; }; export declare const defer: () => Deferred; export declare const delay: <T>(ms: number, value?: T, options?: { unref?: boolean; }) => Promise<T>; interface TimeoutOptions { unref?: boolean; signal?: AbortSignal; } export declare const timeout: <T>(promise: Promise<T>, ms: number, options?: TimeoutOptions) => Promise<T>; export declare const nodeify: <T>(promise: Promise<T>, cb: (err: any, result?: T) => void) => Promise<T>; export declare const callbackify: <T>(fn: (...args: any[]) => Promise<T>) => (...args: any[]) => any; export declare const promisify: (fn: (...args: any[]) => void, options?: { context?: any; multiArgs?: boolean; }) => (...args: any[]) => Promise<any>; export declare const promisifyAll: (source: any, options?: { suffix?: string; filter?: (key: string) => boolean; context?: any; }) => any; declare const _finally: <T>(promise: Promise<T>, onFinally: () => void) => Promise<T>; export { _finally as finally }; export interface RetryOptions { max: number; timeout?: number; match?: Array<string | RegExp | (new (...args: any[]) => any)>; backoffBase?: number; backoffExponent?: number; report?: (message: string, options: any, error?: Error) => void; name?: string; $current?: number; } export declare const retry: <T>(callback: (options: { current: number; }) => Promise<T> | T, options: RetryOptions | number) => Promise<T>; export declare const props: (obj: any) => Promise<any>; declare const try_: (fn: (...args: any[]) => any, ...args: any[]) => Promise<any>; export { try_ as try }; export declare const universalify: (fn: (...args: any[]) => void) => (...args: any[]) => any; export declare const universalifyFromPromise: (fn: (...args: any[]) => Promise<any>) => (...args: any[]) => any;