fix(core): update

This commit is contained in:
Philipp Kunz 2022-02-27 21:02:27 +01:00
parent 1848006601
commit 4c3565c618

View File

@ -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) {