0.1.0 • Published 9 months ago
setbigtimeout v0.1.0
setBigTimeout
setTimeout
caps out at ~25 days.
If you need a bigger timeout, use setBigTimeout
.
import { setBigTimeout } from "setbigtimeout";
const FORTY_DAYS_IN_MILLISECONDS = 3.456e9;
// setTimeout doesn't handle big timeouts.
setTimeout(() => {
console.log("Logs immediately! Bad!");
}, FORTY_DAYS_IN_MILLISECONDS);
// setBigTimeout works fine!
setBigTimeout(() => {
console.log("It's been 40 days...no problem!");
}, FORTY_DAYS_IN_MILLISECONDS);
API reference
setBigTimeout(fn: () => unknown, delay: number | bigint): BigTimeout
Very similar to setTimeout
, but allows a delay
of arbitrary duration.
Example:
import { setBigTimeout } from "setbigtimeout";
const EIGHTY_FOUR_YEARS_IN_MILLISECONDS = 2.65e12;
setBigTimeout(() => {
console.log("It's been 84 years...");
}, FORTY_DAYS_IN_MILLISECONDS);
clearBigTimeout(bigTimeout: BigTimeout): void
Very similar to clearTimeout
, but clears big timeouts. Can also clear
"normal" timeouts created by setTimeout
and setInterval
.
Example:
import { clearBigTimeout, setBigTimeout } from "setbigtimeout";
const timeout = setBigTimeout(() => {
console.log("This will never be executed");
}, 123456789);
clearBigTimeout(timeout);
0.1.0
9 months ago