type TimerFunction = (timerId: string, tickId: number) => void; interface Timer { timerFunc: TimerFunction | null; hertz: number; timerId: string; isPaused: boolean; } /** * This class should NEVER be initialized with new Metronome(). Use the * exported variable. To reset the metronome use unregisterAllTimers() * to remove all existing timers followed by init() to initialize the * ticks. */ declare class Metronome { tickId: number; timers: Timer[]; interval: NodeJS.Timeout | null; handleTimerTicks: ((timerIds: string[]) => void) | null; constructor(); init(): void; unregisterAllTimers(): void; step(): void; /** * Multiple timers with varying frequencies can be made at the same * time however each timerId must be unique. If you attempt to create * two timers with the same timerId, the second will silently be ignored. * * @param timerFunc The function to be executed at the given hertz frequency * @param hertz Frequency of the timer given in hertz * @param timerId Id of the timer * @returns Timer or nothing if no timer was created */ register(timerFunc: TimerFunction | null, hertz: number, timerId: string): Timer | undefined; /** * Unregistering a timer completely removes it, if you want to pause a * timer, then use pauseTimer() * * @param timerId Id of the timer */ unregister(timerId: string): void; /** * Checks if a timer is paused * * @param timerId Id of the timer * @returns true if the timer is paused, false if it is running */ isPaused(timerId: string): boolean; /** * Continues running a timer * * @param timerId Id of the timer */ continueTimer(timerId: string): void; /** * Pauses a timer * * @param timerId Id of the timer */ pauseTimer(timerId: string): void; /** * Toggles a timer to be paused or running. Be careful when asking redux * to toggle a timer, it might toggle twice and therefore do nothing * * @param timerId Id of the timer */ toggleTimer(timerId: string): void; /** * Sets the speed of a timer to a new frequency given in hertz * * @param timerId Id of the timer * @param hertz Frequency of the timer given in hertz */ setSpeed(timerId: string, hertz: number): void; } declare const metronome: Metronome; export { metronome };