audio-context-timers
Version:
A replacement for setInterval() and setTimeout() which works in unfocused windows.
16 lines (12 loc) • 387 B
text/typescript
import { TFunctionMap, TTimerType } from '../types';
export const createCallFunction = (functions: TFunctionMap, type: TTimerType) => (id: number) => {
if (functions.has(id)) {
const func = functions.get(id);
if (func !== undefined) {
func();
if (type === 'timeout') {
functions.delete(id);
}
}
}
};