@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.
@@ -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
- timeouts.push({ delay, func });
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;AAKA,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,KAAK,EAAE;AAC5F;AAEO,IAAM,eAAe,CAAC,MAAkB,UAAkB;AAC/D,MAAI,SAAS,WAAW,GAAG;AACzB,eAAW,WAAW,GAAG;AAAA,EAC3B;AACA,WAAS,KAAK,EAAE,OAAO,KAAK,CAAC;AAC/B;","names":[]}
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":[]}
@@ -1,2 +1,3 @@
1
- export declare const setTimeoutEx: (func: () => void, delay: number) => void;
1
+ export declare const setTimeoutEx: (func: () => void, delay: number) => string;
2
+ export declare const clearTimeoutEx: (id: string) => void;
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,YAAY,SAAU,MAAM,IAAI,SAAS,MAAM,SAK3D,CAAA"}
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"}
@@ -1,2 +1,3 @@
1
- export declare const setTimeoutEx: (func: () => void, delay: number) => void;
1
+ export declare const setTimeoutEx: (func: () => void, delay: number) => string;
2
+ export declare const clearTimeoutEx: (id: string) => void;
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,YAAY,SAAU,MAAM,IAAI,SAAS,MAAM,SAK3D,CAAA"}
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"}
@@ -1,2 +1,3 @@
1
- export declare const setTimeoutEx: (func: () => void, delay: number) => void;
1
+ export declare const setTimeoutEx: (func: () => void, delay: number) => string;
2
+ export declare const clearTimeoutEx: (id: string) => void;
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,YAAY,SAAU,MAAM,IAAI,SAAS,MAAM,SAK3D,CAAA"}
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"}
@@ -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
- timeouts.push({ delay, func });
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":";AAKA,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,KAAK,EAAE;AAC5F;AAEO,IAAM,eAAe,CAAC,MAAkB,UAAkB;AAC/D,MAAI,SAAS,WAAW,GAAG;AACzB,eAAW,WAAW,GAAG;AAAA,EAC3B;AACA,WAAS,KAAK,EAAE,OAAO,KAAK,CAAC;AAC/B;","names":[]}
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":[]}
@@ -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
- timeouts.push({ delay, func });
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
@@ -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;AAKA,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,KAAK,EAAE;AAC5F;AAEO,IAAM,eAAe,CAAC,MAAkB,UAAkB;AAC/D,MAAI,SAAS,WAAW,GAAG;AACzB,eAAW,WAAW,GAAG;AAAA,EAC3B;AACA,WAAS,KAAK,EAAE,OAAO,KAAK,CAAC;AAC/B;","names":[]}
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":[]}
@@ -1,2 +1,3 @@
1
- export declare const setTimeoutEx: (func: () => void, delay: number) => void;
1
+ export declare const setTimeoutEx: (func: () => void, delay: number) => string;
2
+ export declare const clearTimeoutEx: (id: string) => void;
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,YAAY,SAAU,MAAM,IAAI,SAAS,MAAM,SAK3D,CAAA"}
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"}
@@ -1,2 +1,3 @@
1
- export declare const setTimeoutEx: (func: () => void, delay: number) => void;
1
+ export declare const setTimeoutEx: (func: () => void, delay: number) => string;
2
+ export declare const clearTimeoutEx: (id: string) => void;
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,YAAY,SAAU,MAAM,IAAI,SAAS,MAAM,SAK3D,CAAA"}
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"}
@@ -1,2 +1,3 @@
1
- export declare const setTimeoutEx: (func: () => void, delay: number) => void;
1
+ export declare const setTimeoutEx: (func: () => void, delay: number) => string;
2
+ export declare const clearTimeoutEx: (id: string) => void;
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,YAAY,SAAU,MAAM,IAAI,SAAS,MAAM,SAK3D,CAAA"}
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"}
@@ -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
- timeouts.push({ delay, func });
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":";AAKA,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,KAAK,EAAE;AAC5F;AAEO,IAAM,eAAe,CAAC,MAAkB,UAAkB;AAC/D,MAAI,SAAS,WAAW,GAAG;AACzB,eAAW,WAAW,GAAG;AAAA,EAC3B;AACA,WAAS,KAAK,EAAE,OAAO,KAAK,CAAC;AAC/B;","names":[]}
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
@@ -52,6 +52,6 @@
52
52
  "url": "https://github.com/xylabs/sdk-js.git"
53
53
  },
54
54
  "sideEffects": false,
55
- "version": "2.13.24",
55
+ "version": "2.13.25",
56
56
  "type": "module"
57
57
  }
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
- timeouts.push({ delay, func })
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
  }