UNPKG

@toreda/time

Version:

Simple, small footprint library for common time operations and converting between units of time.

38 lines (37 loc) 1.31 kB
import type { Mutable } from '../mutable'; import type { Time } from '../time'; import { TimerCallback } from './callback'; import { TimerCallbackGroup } from './callback/group'; import { TimerCallbackSync } from './callback/sync'; import type { TimerEventId } from './event/id'; import type { TimerOptions } from './options'; /** * Active timer driven by external ticker calls to `onUpdate`. * * @category Timers */ export declare class TimerActive { readonly lastIntervalEnd: Mutable<number>; limitDuration: boolean; readonly listeners: Record<TimerEventId, TimerCallbackGroup>; paused: boolean; running: boolean; readonly timeLimit: Time; readonly timeStart: Time; readonly timeStop: Time; constructor(options?: TimerOptions); getListenerGroup(id: TimerEventId): TimerCallbackGroup | null; on(id: TimerEventId, fn: TimerCallback | TimerCallbackSync): boolean; once(id: TimerEventId, fn: TimerCallback | TimerCallbackSync): boolean; setTimeLimit(value: number | Time): boolean; unpause(): Promise<boolean>; pause(): Promise<boolean>; /** * Start the timer. */ start(): Promise<boolean>; done(): Promise<boolean>; stop(): Promise<boolean>; executeCallbacks(eventId: TimerEventId): Promise<void>; onUpdate(): void; }