chenyc
2025-12-09 545c24c6a711d71b65f3d4e8122fee3837fb1edc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { createWorker } from 'worker-factory';
import { createClearTimer } from './factories/clear-timer';
import { createSetTimeoutCallback } from './factories/set-timeout-callback';
import { createSetTimer } from './factories/set-timer';
/*
 * @todo Explicitly referencing the barrel file seems to be necessary when enabling the
 * isolatedModules compiler option.
 */
export * from './interfaces/index';
export * from './types/index';
const intervalIdentifiersAndResolvers = new Map();
const clearInterval = createClearTimer(globalThis.clearTimeout, intervalIdentifiersAndResolvers);
const timeoutIdentifiersAndResolvers = new Map();
const clearTimeout = createClearTimer(globalThis.clearTimeout, timeoutIdentifiersAndResolvers);
const setTimeoutCallback = createSetTimeoutCallback(performance, globalThis.setTimeout);
const setInterval = createSetTimer(intervalIdentifiersAndResolvers, performance, globalThis.setTimeout, setTimeoutCallback);
const setTimeout = createSetTimer(timeoutIdentifiersAndResolvers, performance, globalThis.setTimeout, setTimeoutCallback);
createWorker(self, {
    clear: async ({ timerId, timerType }) => {
        return { result: await (timerType === 'interval' ? clearInterval(timerId) : clearTimeout(timerId)) };
    },
    set: async ({ delay, now, timerId, timerType }) => {
        return { result: await (timerType === 'interval' ? setInterval : setTimeout)(delay, now, timerId) };
    }
});
//# sourceMappingURL=module.js.map