mirror of
https://github.com/TheBeastLT/torrentio-scraper.git
synced 2026-08-04 01:56:17 +00:00
Some checks failed
Deploy Addon / build (SSH_HOST_1, SSH_KEY_1) (push) Has been cancelled
Deploy Addon / build (SSH_HOST_2, SSH_KEY_2) (push) Has been cancelled
Deploy Addon / build (SSH_HOST_3, SSH_KEY_3) (push) Has been cancelled
Deploy Addon / build (SSH_HOST_4, SSH_KEY_4) (push) Has been cancelled
Deploy Addon / build (SSH_HOST_5, SSH_KEY_5) (push) Has been cancelled
17 lines
488 B
JavaScript
17 lines
488 B
JavaScript
/**
|
|
* Delay promise
|
|
*/
|
|
export async function delay(duration) {
|
|
return new Promise((resolve) => setTimeout(resolve, duration));
|
|
}
|
|
|
|
/**
|
|
* Timeout promise after a set time in ms
|
|
*/
|
|
export async function timeout(timeoutMs, promise, message = 'Timed out') {
|
|
let timer;
|
|
const timeoutPromise = new Promise((_, reject) => {
|
|
timer = setTimeout(() => reject(new Error(message)), timeoutMs);
|
|
});
|
|
return Promise.race([promise, timeoutPromise]).finally(() => clearTimeout(timer));
|
|
}
|