@pushrocks/smartpromise
Version:
simple promises and Deferred constructs
24 lines (23 loc) • 1.09 kB
TypeScript
export * from './smartpromise.classes.cumulativedeferred.js';
export * from './smartpromise.classes.deferred.js';
/**
* Creates a new resolved promise for the provided value.
*/
export declare const resolvedPromise: <T>(value?: T) => Promise<T>;
/**
* Creates a new rejected promise for the provided reason.
*/
export declare const rejectedPromise: (err: any) => Promise<never>;
interface IAsyncFunction<T> {
(someArg: T): Promise<T>;
}
/**
* accepts an array of inputs and a function that accepts the input.
* runs all items with the function and returns the result array when all items have run
* @param inputArg
* @param functionArg
*/
export declare const map: <T>(inputArg: T[], functionArg: IAsyncFunction<T>) => Promise<any[]>;
export declare const timeoutWrap: <T = any>(promiseArg: Promise<T>, timeoutInMsArg: number, rejectArg?: boolean) => Promise<T>;
export declare const timeoutAndContinue: <T = any>(promiseArg: Promise<T>, timeoutInMsArg?: number) => Promise<T>;
export declare const getFirstTrueOrFalse: (promisesArg: Promise<boolean>[]) => Promise<boolean>;