blob: d46916ac53211b0d3c8937f7de56cf66997f3fc9 (
plain) (
blame)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
class Timeout {
#id;
#refCount = 1;
#clearFunction;
constructor(id, clearFunction) {
this.#id = id;
this.#refCount = 1;
this.#clearFunction = clearFunction;
}
ref() {
this.#refCount += 1;
}
hasRef() {
return this.#refCount > 0;
}
unref() {
this.#refCount -= 1;
var clearFunction = this.#clearFunction;
if (clearFunction && this.#refCount === 0) {
this.#clearFunction = null;
clearFunction(this.#id);
}
}
}
export const setInterval = globalThis.setInterval;
export const setImmediate = globalThis.queueMicrotask;
export const setTimeout = globalThis.setTimeout;
export const clearInterval = globalThis.clearInterval;
// not implemented
export const clearImmediate = () => {};
export const clearTimeout = globalThis.clearTimeout;
export const queueMicrotask = globalThis.queueMicrotask;
export default {
setInterval,
queueMicrotask,
setImmediate,
setTimeout,
clearInterval,
clearImmediate,
clearTimeout,
};
|