@xylabs/timer 2.13.24 → 2.13.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.cjs +8 -2
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.d.cts +2 -1
- package/dist/browser/index.d.cts.map +1 -1
- package/dist/browser/index.d.mts +2 -1
- package/dist/browser/index.d.mts.map +1 -1
- package/dist/browser/index.d.ts +2 -1
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +8 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +9 -2
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +2 -1
- package/dist/node/index.d.cts.map +1 -1
- package/dist/node/index.d.mts +2 -1
- package/dist/node/index.d.mts.map +1 -1
- package/dist/node/index.d.ts +2 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +8 -2
- package/dist/node/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +9 -2
package/dist/browser/index.cjs
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
|
+
clearTimeoutEx: () => clearTimeoutEx,
|
|
23
24
|
setTimeoutEx: () => setTimeoutEx
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -33,12 +34,17 @@ var timerFunc = () => {
|
|
|
33
34
|
timeout.func();
|
|
34
35
|
}
|
|
35
36
|
const notFiring = timeouts.filter((timeout) => timeout.delay > 100);
|
|
36
|
-
timeouts = notFiring.map((timeout) => ({ delay: timeout.delay - 100, func: timeout.func }));
|
|
37
|
+
timeouts = notFiring.map((timeout) => ({ delay: timeout.delay - 100, func: timeout.func, id: timeout.id }));
|
|
37
38
|
};
|
|
38
39
|
var setTimeoutEx = (func, delay) => {
|
|
39
40
|
if (timeouts.length === 0) {
|
|
40
41
|
setTimeout(timerFunc, 100);
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
+
const id = `${Date.now()}|${Math.random() * 9999999999}`;
|
|
44
|
+
timeouts.push({ delay, func, id });
|
|
45
|
+
return id;
|
|
46
|
+
};
|
|
47
|
+
var clearTimeoutEx = (id) => {
|
|
48
|
+
timeouts = timeouts.filter((timeout) => timeout.id !== id);
|
|
43
49
|
};
|
|
44
50
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["interface TimeoutInfo {\n delay: number\n func: () => void\n}\n\nlet timeouts: TimeoutInfo[] = []\n\nconst timerFunc = () => {\n if (timeouts.length > 0) {\n setTimeout(timerFunc, 100)\n }\n const firing = timeouts.filter((timeout) => timeout.delay <= 100)\n for (const timeout of firing) {\n timeout.func()\n }\n const notFiring = timeouts.filter((timeout) => timeout.delay > 100)\n timeouts = notFiring.map((timeout) => ({ delay: timeout.delay - 100, func: timeout.func }))\n}\n\nexport const setTimeoutEx = (func: () => void, delay: number) => {\n if (timeouts.length === 0) {\n setTimeout(timerFunc, 100)\n }\n timeouts.push({ delay, func })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["interface TimeoutInfo {\n delay: number\n func: () => void\n id: string\n}\n\nlet timeouts: TimeoutInfo[] = []\n\nconst timerFunc = () => {\n if (timeouts.length > 0) {\n setTimeout(timerFunc, 100)\n }\n const firing = timeouts.filter((timeout) => timeout.delay <= 100)\n for (const timeout of firing) {\n timeout.func()\n }\n const notFiring = timeouts.filter((timeout) => timeout.delay > 100)\n timeouts = notFiring.map((timeout) => ({ delay: timeout.delay - 100, func: timeout.func, id: timeout.id }))\n}\n\nexport const setTimeoutEx = (func: () => void, delay: number) => {\n if (timeouts.length === 0) {\n setTimeout(timerFunc, 100)\n }\n const id = `${Date.now()}|${Math.random() * 9_999_999_999}`\n timeouts.push({ delay, func, id })\n return id\n}\n\nexport const clearTimeoutEx = (id: string) => {\n timeouts = timeouts.filter((timeout) => timeout.id !== id)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,IAAI,WAA0B,CAAC;AAE/B,IAAM,YAAY,MAAM;AACtB,MAAI,SAAS,SAAS,GAAG;AACvB,eAAW,WAAW,GAAG;AAAA,EAC3B;AACA,QAAM,SAAS,SAAS,OAAO,CAAC,YAAY,QAAQ,SAAS,GAAG;AAChE,aAAW,WAAW,QAAQ;AAC5B,YAAQ,KAAK;AAAA,EACf;AACA,QAAM,YAAY,SAAS,OAAO,CAAC,YAAY,QAAQ,QAAQ,GAAG;AAClE,aAAW,UAAU,IAAI,CAAC,aAAa,EAAE,OAAO,QAAQ,QAAQ,KAAK,MAAM,QAAQ,MAAM,IAAI,QAAQ,GAAG,EAAE;AAC5G;AAEO,IAAM,eAAe,CAAC,MAAkB,UAAkB;AAC/D,MAAI,SAAS,WAAW,GAAG;AACzB,eAAW,WAAW,GAAG;AAAA,EAC3B;AACA,QAAM,KAAK,GAAG,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,UAAa;AACzD,WAAS,KAAK,EAAE,OAAO,MAAM,GAAG,CAAC;AACjC,SAAO;AACT;AAEO,IAAM,iBAAiB,CAAC,OAAe;AAC5C,aAAW,SAAS,OAAO,CAAC,YAAY,QAAQ,OAAO,EAAE;AAC3D;","names":[]}
|
package/dist/browser/index.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,YAAY,SAAU,MAAM,IAAI,SAAS,MAAM,WAO3D,CAAA;AAED,eAAO,MAAM,cAAc,OAAQ,MAAM,SAExC,CAAA"}
|
package/dist/browser/index.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,YAAY,SAAU,MAAM,IAAI,SAAS,MAAM,WAO3D,CAAA;AAED,eAAO,MAAM,cAAc,OAAQ,MAAM,SAExC,CAAA"}
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,YAAY,SAAU,MAAM,IAAI,SAAS,MAAM,WAO3D,CAAA;AAED,eAAO,MAAM,cAAc,OAAQ,MAAM,SAExC,CAAA"}
|
package/dist/browser/index.js
CHANGED
|
@@ -9,15 +9,21 @@ var timerFunc = () => {
|
|
|
9
9
|
timeout.func();
|
|
10
10
|
}
|
|
11
11
|
const notFiring = timeouts.filter((timeout) => timeout.delay > 100);
|
|
12
|
-
timeouts = notFiring.map((timeout) => ({ delay: timeout.delay - 100, func: timeout.func }));
|
|
12
|
+
timeouts = notFiring.map((timeout) => ({ delay: timeout.delay - 100, func: timeout.func, id: timeout.id }));
|
|
13
13
|
};
|
|
14
14
|
var setTimeoutEx = (func, delay) => {
|
|
15
15
|
if (timeouts.length === 0) {
|
|
16
16
|
setTimeout(timerFunc, 100);
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
const id = `${Date.now()}|${Math.random() * 9999999999}`;
|
|
19
|
+
timeouts.push({ delay, func, id });
|
|
20
|
+
return id;
|
|
21
|
+
};
|
|
22
|
+
var clearTimeoutEx = (id) => {
|
|
23
|
+
timeouts = timeouts.filter((timeout) => timeout.id !== id);
|
|
19
24
|
};
|
|
20
25
|
export {
|
|
26
|
+
clearTimeoutEx,
|
|
21
27
|
setTimeoutEx
|
|
22
28
|
};
|
|
23
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["interface TimeoutInfo {\n delay: number\n func: () => void\n}\n\nlet timeouts: TimeoutInfo[] = []\n\nconst timerFunc = () => {\n if (timeouts.length > 0) {\n setTimeout(timerFunc, 100)\n }\n const firing = timeouts.filter((timeout) => timeout.delay <= 100)\n for (const timeout of firing) {\n timeout.func()\n }\n const notFiring = timeouts.filter((timeout) => timeout.delay > 100)\n timeouts = notFiring.map((timeout) => ({ delay: timeout.delay - 100, func: timeout.func }))\n}\n\nexport const setTimeoutEx = (func: () => void, delay: number) => {\n if (timeouts.length === 0) {\n setTimeout(timerFunc, 100)\n }\n timeouts.push({ delay, func })\n}\n"],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["interface TimeoutInfo {\n delay: number\n func: () => void\n id: string\n}\n\nlet timeouts: TimeoutInfo[] = []\n\nconst timerFunc = () => {\n if (timeouts.length > 0) {\n setTimeout(timerFunc, 100)\n }\n const firing = timeouts.filter((timeout) => timeout.delay <= 100)\n for (const timeout of firing) {\n timeout.func()\n }\n const notFiring = timeouts.filter((timeout) => timeout.delay > 100)\n timeouts = notFiring.map((timeout) => ({ delay: timeout.delay - 100, func: timeout.func, id: timeout.id }))\n}\n\nexport const setTimeoutEx = (func: () => void, delay: number) => {\n if (timeouts.length === 0) {\n setTimeout(timerFunc, 100)\n }\n const id = `${Date.now()}|${Math.random() * 9_999_999_999}`\n timeouts.push({ delay, func, id })\n return id\n}\n\nexport const clearTimeoutEx = (id: string) => {\n timeouts = timeouts.filter((timeout) => timeout.id !== id)\n}\n"],"mappings":";AAMA,IAAI,WAA0B,CAAC;AAE/B,IAAM,YAAY,MAAM;AACtB,MAAI,SAAS,SAAS,GAAG;AACvB,eAAW,WAAW,GAAG;AAAA,EAC3B;AACA,QAAM,SAAS,SAAS,OAAO,CAAC,YAAY,QAAQ,SAAS,GAAG;AAChE,aAAW,WAAW,QAAQ;AAC5B,YAAQ,KAAK;AAAA,EACf;AACA,QAAM,YAAY,SAAS,OAAO,CAAC,YAAY,QAAQ,QAAQ,GAAG;AAClE,aAAW,UAAU,IAAI,CAAC,aAAa,EAAE,OAAO,QAAQ,QAAQ,KAAK,MAAM,QAAQ,MAAM,IAAI,QAAQ,GAAG,EAAE;AAC5G;AAEO,IAAM,eAAe,CAAC,MAAkB,UAAkB;AAC/D,MAAI,SAAS,WAAW,GAAG;AACzB,eAAW,WAAW,GAAG;AAAA,EAC3B;AACA,QAAM,KAAK,GAAG,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,UAAa;AACzD,WAAS,KAAK,EAAE,OAAO,MAAM,GAAG,CAAC;AACjC,SAAO;AACT;AAEO,IAAM,iBAAiB,CAAC,OAAe;AAC5C,aAAW,SAAS,OAAO,CAAC,YAAY,QAAQ,OAAO,EAAE;AAC3D;","names":[]}
|
package/dist/node/index.cjs
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
|
+
clearTimeoutEx: () => clearTimeoutEx,
|
|
23
24
|
setTimeoutEx: () => setTimeoutEx
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -33,16 +34,22 @@ var timerFunc = () => {
|
|
|
33
34
|
timeout.func();
|
|
34
35
|
}
|
|
35
36
|
const notFiring = timeouts.filter((timeout) => timeout.delay > 100);
|
|
36
|
-
timeouts = notFiring.map((timeout) => ({ delay: timeout.delay - 100, func: timeout.func }));
|
|
37
|
+
timeouts = notFiring.map((timeout) => ({ delay: timeout.delay - 100, func: timeout.func, id: timeout.id }));
|
|
37
38
|
};
|
|
38
39
|
var setTimeoutEx = (func, delay) => {
|
|
39
40
|
if (timeouts.length === 0) {
|
|
40
41
|
setTimeout(timerFunc, 100);
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
+
const id = `${Date.now()}|${Math.random() * 9999999999}`;
|
|
44
|
+
timeouts.push({ delay, func, id });
|
|
45
|
+
return id;
|
|
46
|
+
};
|
|
47
|
+
var clearTimeoutEx = (id) => {
|
|
48
|
+
timeouts = timeouts.filter((timeout) => timeout.id !== id);
|
|
43
49
|
};
|
|
44
50
|
// Annotate the CommonJS export names for ESM import in node:
|
|
45
51
|
0 && (module.exports = {
|
|
52
|
+
clearTimeoutEx,
|
|
46
53
|
setTimeoutEx
|
|
47
54
|
});
|
|
48
55
|
//# sourceMappingURL=index.cjs.map
|
package/dist/node/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["interface TimeoutInfo {\n delay: number\n func: () => void\n}\n\nlet timeouts: TimeoutInfo[] = []\n\nconst timerFunc = () => {\n if (timeouts.length > 0) {\n setTimeout(timerFunc, 100)\n }\n const firing = timeouts.filter((timeout) => timeout.delay <= 100)\n for (const timeout of firing) {\n timeout.func()\n }\n const notFiring = timeouts.filter((timeout) => timeout.delay > 100)\n timeouts = notFiring.map((timeout) => ({ delay: timeout.delay - 100, func: timeout.func }))\n}\n\nexport const setTimeoutEx = (func: () => void, delay: number) => {\n if (timeouts.length === 0) {\n setTimeout(timerFunc, 100)\n }\n timeouts.push({ delay, func })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["interface TimeoutInfo {\n delay: number\n func: () => void\n id: string\n}\n\nlet timeouts: TimeoutInfo[] = []\n\nconst timerFunc = () => {\n if (timeouts.length > 0) {\n setTimeout(timerFunc, 100)\n }\n const firing = timeouts.filter((timeout) => timeout.delay <= 100)\n for (const timeout of firing) {\n timeout.func()\n }\n const notFiring = timeouts.filter((timeout) => timeout.delay > 100)\n timeouts = notFiring.map((timeout) => ({ delay: timeout.delay - 100, func: timeout.func, id: timeout.id }))\n}\n\nexport const setTimeoutEx = (func: () => void, delay: number) => {\n if (timeouts.length === 0) {\n setTimeout(timerFunc, 100)\n }\n const id = `${Date.now()}|${Math.random() * 9_999_999_999}`\n timeouts.push({ delay, func, id })\n return id\n}\n\nexport const clearTimeoutEx = (id: string) => {\n timeouts = timeouts.filter((timeout) => timeout.id !== id)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,IAAI,WAA0B,CAAC;AAE/B,IAAM,YAAY,MAAM;AACtB,MAAI,SAAS,SAAS,GAAG;AACvB,eAAW,WAAW,GAAG;AAAA,EAC3B;AACA,QAAM,SAAS,SAAS,OAAO,CAAC,YAAY,QAAQ,SAAS,GAAG;AAChE,aAAW,WAAW,QAAQ;AAC5B,YAAQ,KAAK;AAAA,EACf;AACA,QAAM,YAAY,SAAS,OAAO,CAAC,YAAY,QAAQ,QAAQ,GAAG;AAClE,aAAW,UAAU,IAAI,CAAC,aAAa,EAAE,OAAO,QAAQ,QAAQ,KAAK,MAAM,QAAQ,MAAM,IAAI,QAAQ,GAAG,EAAE;AAC5G;AAEO,IAAM,eAAe,CAAC,MAAkB,UAAkB;AAC/D,MAAI,SAAS,WAAW,GAAG;AACzB,eAAW,WAAW,GAAG;AAAA,EAC3B;AACA,QAAM,KAAK,GAAG,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,UAAa;AACzD,WAAS,KAAK,EAAE,OAAO,MAAM,GAAG,CAAC;AACjC,SAAO;AACT;AAEO,IAAM,iBAAiB,CAAC,OAAe;AAC5C,aAAW,SAAS,OAAO,CAAC,YAAY,QAAQ,OAAO,EAAE;AAC3D;","names":[]}
|
package/dist/node/index.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,YAAY,SAAU,MAAM,IAAI,SAAS,MAAM,WAO3D,CAAA;AAED,eAAO,MAAM,cAAc,OAAQ,MAAM,SAExC,CAAA"}
|
package/dist/node/index.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,YAAY,SAAU,MAAM,IAAI,SAAS,MAAM,WAO3D,CAAA;AAED,eAAO,MAAM,cAAc,OAAQ,MAAM,SAExC,CAAA"}
|
package/dist/node/index.d.ts
CHANGED
package/dist/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,YAAY,SAAU,MAAM,IAAI,SAAS,MAAM,WAO3D,CAAA;AAED,eAAO,MAAM,cAAc,OAAQ,MAAM,SAExC,CAAA"}
|
package/dist/node/index.js
CHANGED
|
@@ -9,15 +9,21 @@ var timerFunc = () => {
|
|
|
9
9
|
timeout.func();
|
|
10
10
|
}
|
|
11
11
|
const notFiring = timeouts.filter((timeout) => timeout.delay > 100);
|
|
12
|
-
timeouts = notFiring.map((timeout) => ({ delay: timeout.delay - 100, func: timeout.func }));
|
|
12
|
+
timeouts = notFiring.map((timeout) => ({ delay: timeout.delay - 100, func: timeout.func, id: timeout.id }));
|
|
13
13
|
};
|
|
14
14
|
var setTimeoutEx = (func, delay) => {
|
|
15
15
|
if (timeouts.length === 0) {
|
|
16
16
|
setTimeout(timerFunc, 100);
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
const id = `${Date.now()}|${Math.random() * 9999999999}`;
|
|
19
|
+
timeouts.push({ delay, func, id });
|
|
20
|
+
return id;
|
|
21
|
+
};
|
|
22
|
+
var clearTimeoutEx = (id) => {
|
|
23
|
+
timeouts = timeouts.filter((timeout) => timeout.id !== id);
|
|
19
24
|
};
|
|
20
25
|
export {
|
|
26
|
+
clearTimeoutEx,
|
|
21
27
|
setTimeoutEx
|
|
22
28
|
};
|
|
23
29
|
//# sourceMappingURL=index.js.map
|
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["interface TimeoutInfo {\n delay: number\n func: () => void\n}\n\nlet timeouts: TimeoutInfo[] = []\n\nconst timerFunc = () => {\n if (timeouts.length > 0) {\n setTimeout(timerFunc, 100)\n }\n const firing = timeouts.filter((timeout) => timeout.delay <= 100)\n for (const timeout of firing) {\n timeout.func()\n }\n const notFiring = timeouts.filter((timeout) => timeout.delay > 100)\n timeouts = notFiring.map((timeout) => ({ delay: timeout.delay - 100, func: timeout.func }))\n}\n\nexport const setTimeoutEx = (func: () => void, delay: number) => {\n if (timeouts.length === 0) {\n setTimeout(timerFunc, 100)\n }\n timeouts.push({ delay, func })\n}\n"],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["interface TimeoutInfo {\n delay: number\n func: () => void\n id: string\n}\n\nlet timeouts: TimeoutInfo[] = []\n\nconst timerFunc = () => {\n if (timeouts.length > 0) {\n setTimeout(timerFunc, 100)\n }\n const firing = timeouts.filter((timeout) => timeout.delay <= 100)\n for (const timeout of firing) {\n timeout.func()\n }\n const notFiring = timeouts.filter((timeout) => timeout.delay > 100)\n timeouts = notFiring.map((timeout) => ({ delay: timeout.delay - 100, func: timeout.func, id: timeout.id }))\n}\n\nexport const setTimeoutEx = (func: () => void, delay: number) => {\n if (timeouts.length === 0) {\n setTimeout(timerFunc, 100)\n }\n const id = `${Date.now()}|${Math.random() * 9_999_999_999}`\n timeouts.push({ delay, func, id })\n return id\n}\n\nexport const clearTimeoutEx = (id: string) => {\n timeouts = timeouts.filter((timeout) => timeout.id !== id)\n}\n"],"mappings":";AAMA,IAAI,WAA0B,CAAC;AAE/B,IAAM,YAAY,MAAM;AACtB,MAAI,SAAS,SAAS,GAAG;AACvB,eAAW,WAAW,GAAG;AAAA,EAC3B;AACA,QAAM,SAAS,SAAS,OAAO,CAAC,YAAY,QAAQ,SAAS,GAAG;AAChE,aAAW,WAAW,QAAQ;AAC5B,YAAQ,KAAK;AAAA,EACf;AACA,QAAM,YAAY,SAAS,OAAO,CAAC,YAAY,QAAQ,QAAQ,GAAG;AAClE,aAAW,UAAU,IAAI,CAAC,aAAa,EAAE,OAAO,QAAQ,QAAQ,KAAK,MAAM,QAAQ,MAAM,IAAI,QAAQ,GAAG,EAAE;AAC5G;AAEO,IAAM,eAAe,CAAC,MAAkB,UAAkB;AAC/D,MAAI,SAAS,WAAW,GAAG;AACzB,eAAW,WAAW,GAAG;AAAA,EAC3B;AACA,QAAM,KAAK,GAAG,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,UAAa;AACzD,WAAS,KAAK,EAAE,OAAO,MAAM,GAAG,CAAC;AACjC,SAAO;AACT;AAEO,IAAM,iBAAiB,CAAC,OAAe;AAC5C,aAAW,SAAS,OAAO,CAAC,YAAY,QAAQ,OAAO,EAAE;AAC3D;","names":[]}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
interface TimeoutInfo {
|
|
2
2
|
delay: number
|
|
3
3
|
func: () => void
|
|
4
|
+
id: string
|
|
4
5
|
}
|
|
5
6
|
|
|
6
7
|
let timeouts: TimeoutInfo[] = []
|
|
@@ -14,12 +15,18 @@ const timerFunc = () => {
|
|
|
14
15
|
timeout.func()
|
|
15
16
|
}
|
|
16
17
|
const notFiring = timeouts.filter((timeout) => timeout.delay > 100)
|
|
17
|
-
timeouts = notFiring.map((timeout) => ({ delay: timeout.delay - 100, func: timeout.func }))
|
|
18
|
+
timeouts = notFiring.map((timeout) => ({ delay: timeout.delay - 100, func: timeout.func, id: timeout.id }))
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export const setTimeoutEx = (func: () => void, delay: number) => {
|
|
21
22
|
if (timeouts.length === 0) {
|
|
22
23
|
setTimeout(timerFunc, 100)
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
+
const id = `${Date.now()}|${Math.random() * 9_999_999_999}`
|
|
26
|
+
timeouts.push({ delay, func, id })
|
|
27
|
+
return id
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const clearTimeoutEx = (id: string) => {
|
|
31
|
+
timeouts = timeouts.filter((timeout) => timeout.id !== id)
|
|
25
32
|
}
|