ipull
Version:
The only file downloader you'll ever need. For node.js and the browser, CLI and library for fast and reliable file downloads.
14 lines • 412 B
JavaScript
export function abortableSleep(timeMS, signal) {
return new Promise((resolve) => {
const timeoutId = setTimeout(() => {
resolve();
}, timeMS);
if (signal) {
signal.addEventListener("abort", () => {
clearTimeout(timeoutId);
resolve();
}, { once: true });
}
});
}
//# sourceMappingURL=abortableSleep.js.map