declare const SECOND = 1000; declare const MINUTE = 60000; declare const HOUR = 3600000; declare const DAY = 86400000; type Callback = () => any; declare const sinceLast: (timestamp: number, periodSizeMS: number) => number; declare const untilNext: (timestamp: number, periodSizeMS: number) => number; declare const atLast: (timestamp: number, periodSizeMS: number) => number; declare const atNext: (timestamp: number, periodSizeMS: number) => number; type TimerId = ReturnType; /** Safe timeout which guarantees the timer doesn't undershoot (i.e. doesn't fire a few milliseconds too early) Returns a getter function for the current timeout ID */ declare const safeTimeout: (callback: Callback, delay: number) => (() => TimerId); /** Executes callback which is guaranteed to fire *AFTER* the clock strikes the next whole `periodSizeMs`. Returns an object with a `cancel` function - which optionally executes the callback. Usage: const MINUTE = 60*1000; const HOUR = 60*MINUTE; // Log the current time when the clock strikes next noon or midnight. const at12 = onNext(12*HOUR, () => console.log(Date()) ); // Log the current time 15 minutes after the clock strikes next noon or midnight. const at12_15 = onNext(12*HOUR, 15*MINUTE, () => console.log(Date()) ); // Cancel the 12 o'clock callback: at12.cancel(); // Nevermind the 12:15 schedule. Run the callback right now! at12_15.cancel(true); */ declare const onNext: (periodSizeMS: number, offsetMs: number | Callback, callback?: Callback) => { cancel: (execCallback?: boolean) => void; } | undefined; /** Auto-repeating version of `onNext()` */ declare const onEvery: (periodSizeMS: number, offsetMs: number | Callback, callback?: Callback) => { cancel: (execCallback?: boolean) => void; } | undefined; export { atNext as atEnd, atLast, atNext, atLast as atStart, DAY, HOUR, MINUTE, onEvery, onNext, safeTimeout, SECOND, sinceLast, untilNext, };