fix(core): update
This commit is contained in:
parent
1848006601
commit
4c3565c618
14
ts/index.ts
14
ts/index.ts
@ -84,15 +84,23 @@ export const map = async <T>(inputArg: T[], functionArg: IAsyncFunction<T>) => {
|
||||
return resultArray;
|
||||
};
|
||||
|
||||
export const timeoutWrap = <T = any>(promiseArg: Promise<T>, timeoutInMs: number) => {
|
||||
export const timeoutWrap = async <T = any>(promiseArg: Promise<T>, timeoutInMsArg: number, rejectArg = true) => {
|
||||
return new Promise<T>((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
reject(new Error('timeout'));
|
||||
}, timeoutInMs);
|
||||
if (rejectArg) {
|
||||
reject(new Error('timeout'));
|
||||
} else {
|
||||
resolve(null);
|
||||
}
|
||||
}, timeoutInMsArg);
|
||||
promiseArg.then(resolve, reject);
|
||||
});
|
||||
};
|
||||
|
||||
export const timeoutAndContinue = async <T = any>(promiseArg: Promise<T>, timeoutInMsArg = 60000) => {
|
||||
return timeoutWrap(promiseArg, timeoutInMsArg, false);
|
||||
}
|
||||
|
||||
export const getFirstTrueOrFalse = async (promisesArg: Promise<boolean>[]) => {
|
||||
const done = defer<boolean>();
|
||||
for (const promiseArg of promisesArg) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user