@sapphire/timer-manager 1.0.3-next.a3da0ab0 → 1.0.3-next.a6c8ccda

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/README.md CHANGED
@@ -7,7 +7,6 @@
7
7
  **Timer manager utilities for JavaScript.**
8
8
 
9
9
  [![GitHub](https://img.shields.io/github/license/sapphiredev/utilities)](https://github.com/sapphiredev/utilities/blob/main/LICENSE.md)
10
- [![codecov](https://codecov.io/gh/sapphiredev/utilities/branch/main/graph/badge.svg?token=OEGIV6RFDO)](https://codecov.io/gh/sapphiredev/utilities)
11
10
  [![npm bundle size](https://img.shields.io/bundlephobia/min/@sapphire/timer-manager?logo=webpack&style=flat-square)](https://bundlephobia.com/result?p=@sapphire/timer-manager)
12
11
  [![npm](https://img.shields.io/npm/v/@sapphire/timer-manager?color=crimson&logo=npm&style=flat-square)](https://www.npmjs.com/package/@sapphire/timer-manager)
13
12
 
@@ -3,10 +3,7 @@
3
3
  var __defProp = Object.defineProperty;
4
4
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5
5
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
- var __publicField = (obj, key, value) => {
7
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
8
- return value;
9
- };
6
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
10
7
 
11
8
  // src/lib/TimerManager.ts
12
9
  var _TimerManager = class _TimerManager extends null {
@@ -55,10 +52,8 @@ var _TimerManager = class _TimerManager extends null {
55
52
  * Clears running timeouts and intervals created through this class so NodeJS can gracefully exit
56
53
  */
57
54
  static destroy() {
58
- for (const i of this.storedTimeouts)
59
- clearTimeout(i);
60
- for (const i of this.storedIntervals)
61
- clearInterval(i);
55
+ for (const i of this.storedTimeouts) clearTimeout(i);
56
+ for (const i of this.storedIntervals) clearInterval(i);
62
57
  this.storedTimeouts.clear();
63
58
  this.storedIntervals.clear();
64
59
  }
@@ -75,5 +70,5 @@ __publicField(_TimerManager, "storedIntervals", /* @__PURE__ */ new Set());
75
70
  var TimerManager = _TimerManager;
76
71
 
77
72
  exports.TimerManager = TimerManager;
78
- //# sourceMappingURL=out.js.map
73
+ //# sourceMappingURL=index.cjs.map
79
74
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/TimerManager.ts"],"names":[],"mappings":";;;;;;;;;AAGO,IAAM,gBAAN,MAAM,sBAAqB,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBtC,OAAc,WAAwB,IAA4B,UAAkB,MAA2B;AAC9G,UAAM,UAAU,WAAW,MAAM;AAChC,WAAK,eAAe,OAAO,OAAO;AAClC,SAAG,GAAG,IAAI;AAAA,IACX,GAAG,KAAK;AACR,SAAK,eAAe,IAAI,OAAO;AAC/B,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAc,aAAa,SAA+B;AACzD,iBAAa,OAAO;AACpB,SAAK,eAAe,OAAO,OAAO;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAc,YAAyB,IAA4B,UAAkB,MAA2B;AAC/G,UAAM,WAAW,YAAY,IAAI,OAAO,GAAG,IAAI;AAC/C,SAAK,gBAAgB,IAAI,QAAQ;AACjC,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAc,cAAc,UAAgC;AAC3D,kBAAc,QAAQ;AACtB,SAAK,gBAAgB,OAAO,QAAQ;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAc,UAAgB;AAC7B,eAAW,KAAK,KAAK;AAAgB,mBAAa,CAAC;AACnD,eAAW,KAAK,KAAK;AAAiB,oBAAc,CAAC;AACrD,SAAK,eAAe,MAAM;AAC1B,SAAK,gBAAgB,MAAM;AAAA,EAC5B;AACD;AAjEuC;AAAA;AAAA;AAAA;AAItC,cAJY,eAIG,kBAAiB,oBAAI,IAAoB;AAAA;AAAA;AAAA;AAKxD,cATY,eASG,mBAAkB,oBAAI,IAAoB;AATnD,IAAM,eAAN","sourcesContent":["/**\n * Manages timers so that this application can be cleanly exited\n */\nexport class TimerManager extends null {\n\t/**\n\t * A set of timeouts to clear on destroy\n\t */\n\tprivate static storedTimeouts = new Set<NodeJS.Timeout>();\n\n\t/**\n\t * A set of intervals to clear on destroy\n\t */\n\tprivate static storedIntervals = new Set<NodeJS.Timeout>();\n\n\t/**\n\t * Creates a timeout gets cleared when destroyed\n\t * @param fn callback function\n\t * @param delay amount of time before running the callback\n\t * @param args additional arguments to pass back to the callback\n\t */\n\tpublic static setTimeout<A = unknown>(fn: (...args: A[]) => void, delay: number, ...args: A[]): NodeJS.Timeout {\n\t\tconst timeout = setTimeout(() => {\n\t\t\tthis.storedTimeouts.delete(timeout);\n\t\t\tfn(...args);\n\t\t}, delay);\n\t\tthis.storedTimeouts.add(timeout);\n\t\treturn timeout;\n\t}\n\n\t/**\n\t * Clears a timeout created through this class\n\t * @param timeout The timeout to clear\n\t */\n\tpublic static clearTimeout(timeout: NodeJS.Timeout): void {\n\t\tclearTimeout(timeout);\n\t\tthis.storedTimeouts.delete(timeout);\n\t}\n\n\t/**\n\t * Creates an interval gets cleared when destroyed\n\t * @param fn callback function\n\t * @param delay amount of time before running the callback\n\t * @param args additional arguments to pass back to the callback\n\t */\n\tpublic static setInterval<A = unknown>(fn: (...args: A[]) => void, delay: number, ...args: A[]): NodeJS.Timeout {\n\t\tconst interval = setInterval(fn, delay, ...args);\n\t\tthis.storedIntervals.add(interval);\n\t\treturn interval;\n\t}\n\n\t/**\n\t * Clears an internal created through this class\n\t * @param interval The interval to clear\n\t */\n\tpublic static clearInterval(interval: NodeJS.Timeout): void {\n\t\tclearInterval(interval);\n\t\tthis.storedIntervals.delete(interval);\n\t}\n\n\t/**\n\t * Clears running timeouts and intervals created through this class so NodeJS can gracefully exit\n\t */\n\tpublic static destroy(): void {\n\t\tfor (const i of this.storedTimeouts) clearTimeout(i);\n\t\tfor (const i of this.storedIntervals) clearInterval(i);\n\t\tthis.storedTimeouts.clear();\n\t\tthis.storedIntervals.clear();\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../src/lib/TimerManager.ts"],"names":[],"mappings":";;;;;;;;AAGO,IAAM,aAAA,GAAN,MAAM,aAAA,SAAqB,IAAK,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBtC,OAAc,UAAA,CAAwB,EAA4B,EAAA,KAAA,EAAA,GAAkB,IAA2B,EAAA;AAC9G,IAAM,MAAA,OAAA,GAAU,WAAW,MAAM;AAChC,MAAK,IAAA,CAAA,cAAA,CAAe,OAAO,OAAO,CAAA,CAAA;AAClC,MAAA,EAAA,CAAG,GAAG,IAAI,CAAA,CAAA;AAAA,OACR,KAAK,CAAA,CAAA;AACR,IAAK,IAAA,CAAA,cAAA,CAAe,IAAI,OAAO,CAAA,CAAA;AAC/B,IAAO,OAAA,OAAA,CAAA;AAAA,GACR;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAc,aAAa,OAA+B,EAAA;AACzD,IAAA,YAAA,CAAa,OAAO,CAAA,CAAA;AACpB,IAAK,IAAA,CAAA,cAAA,CAAe,OAAO,OAAO,CAAA,CAAA;AAAA,GACnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAc,WAAA,CAAyB,EAA4B,EAAA,KAAA,EAAA,GAAkB,IAA2B,EAAA;AAC/G,IAAA,MAAM,QAAW,GAAA,WAAA,CAAY,EAAI,EAAA,KAAA,EAAO,GAAG,IAAI,CAAA,CAAA;AAC/C,IAAK,IAAA,CAAA,eAAA,CAAgB,IAAI,QAAQ,CAAA,CAAA;AACjC,IAAO,OAAA,QAAA,CAAA;AAAA,GACR;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAc,cAAc,QAAgC,EAAA;AAC3D,IAAA,aAAA,CAAc,QAAQ,CAAA,CAAA;AACtB,IAAK,IAAA,CAAA,eAAA,CAAgB,OAAO,QAAQ,CAAA,CAAA;AAAA,GACrC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAc,OAAgB,GAAA;AAC7B,IAAA,KAAA,MAAW,CAAK,IAAA,IAAA,CAAK,cAAgB,EAAA,YAAA,CAAa,CAAC,CAAA,CAAA;AACnD,IAAA,KAAA,MAAW,CAAK,IAAA,IAAA,CAAK,eAAiB,EAAA,aAAA,CAAc,CAAC,CAAA,CAAA;AACrD,IAAA,IAAA,CAAK,eAAe,KAAM,EAAA,CAAA;AAC1B,IAAA,IAAA,CAAK,gBAAgB,KAAM,EAAA,CAAA;AAAA,GAC5B;AACD,CAAA,CAAA;AAjEuC,MAAA,CAAA,aAAA,EAAA,cAAA,CAAA,CAAA;AAAA;AAAA;AAAA;AAItC,aAJY,CAAA,aAAA,EAIG,gBAAiB,kBAAA,IAAI,GAAoB,EAAA,CAAA,CAAA;AAAA;AAAA;AAAA;AAKxD,aATY,CAAA,aAAA,EASG,iBAAkB,kBAAA,IAAI,GAAoB,EAAA,CAAA,CAAA;AATnD,IAAM,YAAN,GAAA","file":"index.cjs","sourcesContent":["/**\n * Manages timers so that this application can be cleanly exited\n */\nexport class TimerManager extends null {\n\t/**\n\t * A set of timeouts to clear on destroy\n\t */\n\tprivate static storedTimeouts = new Set<NodeJS.Timeout>();\n\n\t/**\n\t * A set of intervals to clear on destroy\n\t */\n\tprivate static storedIntervals = new Set<NodeJS.Timeout>();\n\n\t/**\n\t * Creates a timeout gets cleared when destroyed\n\t * @param fn callback function\n\t * @param delay amount of time before running the callback\n\t * @param args additional arguments to pass back to the callback\n\t */\n\tpublic static setTimeout<A = unknown>(fn: (...args: A[]) => void, delay: number, ...args: A[]): NodeJS.Timeout {\n\t\tconst timeout = setTimeout(() => {\n\t\t\tthis.storedTimeouts.delete(timeout);\n\t\t\tfn(...args);\n\t\t}, delay);\n\t\tthis.storedTimeouts.add(timeout);\n\t\treturn timeout;\n\t}\n\n\t/**\n\t * Clears a timeout created through this class\n\t * @param timeout The timeout to clear\n\t */\n\tpublic static clearTimeout(timeout: NodeJS.Timeout): void {\n\t\tclearTimeout(timeout);\n\t\tthis.storedTimeouts.delete(timeout);\n\t}\n\n\t/**\n\t * Creates an interval gets cleared when destroyed\n\t * @param fn callback function\n\t * @param delay amount of time before running the callback\n\t * @param args additional arguments to pass back to the callback\n\t */\n\tpublic static setInterval<A = unknown>(fn: (...args: A[]) => void, delay: number, ...args: A[]): NodeJS.Timeout {\n\t\tconst interval = setInterval(fn, delay, ...args);\n\t\tthis.storedIntervals.add(interval);\n\t\treturn interval;\n\t}\n\n\t/**\n\t * Clears an internal created through this class\n\t * @param interval The interval to clear\n\t */\n\tpublic static clearInterval(interval: NodeJS.Timeout): void {\n\t\tclearInterval(interval);\n\t\tthis.storedIntervals.delete(interval);\n\t}\n\n\t/**\n\t * Clears running timeouts and intervals created through this class so NodeJS can gracefully exit\n\t */\n\tpublic static destroy(): void {\n\t\tfor (const i of this.storedTimeouts) clearTimeout(i);\n\t\tfor (const i of this.storedIntervals) clearInterval(i);\n\t\tthis.storedTimeouts.clear();\n\t\tthis.storedIntervals.clear();\n\t}\n}\n"]}
@@ -1,10 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
- var __publicField = (obj, key, value) => {
5
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
6
- return value;
7
- };
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
8
5
 
9
6
  // src/lib/TimerManager.ts
10
7
  var _TimerManager = class _TimerManager extends null {
@@ -53,10 +50,8 @@ var _TimerManager = class _TimerManager extends null {
53
50
  * Clears running timeouts and intervals created through this class so NodeJS can gracefully exit
54
51
  */
55
52
  static destroy() {
56
- for (const i of this.storedTimeouts)
57
- clearTimeout(i);
58
- for (const i of this.storedIntervals)
59
- clearInterval(i);
53
+ for (const i of this.storedTimeouts) clearTimeout(i);
54
+ for (const i of this.storedIntervals) clearInterval(i);
60
55
  this.storedTimeouts.clear();
61
56
  this.storedIntervals.clear();
62
57
  }
@@ -73,5 +68,5 @@ __publicField(_TimerManager, "storedIntervals", /* @__PURE__ */ new Set());
73
68
  var TimerManager = _TimerManager;
74
69
 
75
70
  export { TimerManager };
76
- //# sourceMappingURL=out.js.map
71
+ //# sourceMappingURL=index.mjs.map
77
72
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/TimerManager.ts"],"names":[],"mappings":";;;;;;;;;AAGO,IAAM,gBAAN,MAAM,sBAAqB,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBtC,OAAc,WAAwB,IAA4B,UAAkB,MAA2B;AAC9G,UAAM,UAAU,WAAW,MAAM;AAChC,WAAK,eAAe,OAAO,OAAO;AAClC,SAAG,GAAG,IAAI;AAAA,IACX,GAAG,KAAK;AACR,SAAK,eAAe,IAAI,OAAO;AAC/B,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAc,aAAa,SAA+B;AACzD,iBAAa,OAAO;AACpB,SAAK,eAAe,OAAO,OAAO;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAc,YAAyB,IAA4B,UAAkB,MAA2B;AAC/G,UAAM,WAAW,YAAY,IAAI,OAAO,GAAG,IAAI;AAC/C,SAAK,gBAAgB,IAAI,QAAQ;AACjC,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAc,cAAc,UAAgC;AAC3D,kBAAc,QAAQ;AACtB,SAAK,gBAAgB,OAAO,QAAQ;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAc,UAAgB;AAC7B,eAAW,KAAK,KAAK;AAAgB,mBAAa,CAAC;AACnD,eAAW,KAAK,KAAK;AAAiB,oBAAc,CAAC;AACrD,SAAK,eAAe,MAAM;AAC1B,SAAK,gBAAgB,MAAM;AAAA,EAC5B;AACD;AAjEuC;AAAA;AAAA;AAAA;AAItC,cAJY,eAIG,kBAAiB,oBAAI,IAAoB;AAAA;AAAA;AAAA;AAKxD,cATY,eASG,mBAAkB,oBAAI,IAAoB;AATnD,IAAM,eAAN","sourcesContent":["/**\n * Manages timers so that this application can be cleanly exited\n */\nexport class TimerManager extends null {\n\t/**\n\t * A set of timeouts to clear on destroy\n\t */\n\tprivate static storedTimeouts = new Set<NodeJS.Timeout>();\n\n\t/**\n\t * A set of intervals to clear on destroy\n\t */\n\tprivate static storedIntervals = new Set<NodeJS.Timeout>();\n\n\t/**\n\t * Creates a timeout gets cleared when destroyed\n\t * @param fn callback function\n\t * @param delay amount of time before running the callback\n\t * @param args additional arguments to pass back to the callback\n\t */\n\tpublic static setTimeout<A = unknown>(fn: (...args: A[]) => void, delay: number, ...args: A[]): NodeJS.Timeout {\n\t\tconst timeout = setTimeout(() => {\n\t\t\tthis.storedTimeouts.delete(timeout);\n\t\t\tfn(...args);\n\t\t}, delay);\n\t\tthis.storedTimeouts.add(timeout);\n\t\treturn timeout;\n\t}\n\n\t/**\n\t * Clears a timeout created through this class\n\t * @param timeout The timeout to clear\n\t */\n\tpublic static clearTimeout(timeout: NodeJS.Timeout): void {\n\t\tclearTimeout(timeout);\n\t\tthis.storedTimeouts.delete(timeout);\n\t}\n\n\t/**\n\t * Creates an interval gets cleared when destroyed\n\t * @param fn callback function\n\t * @param delay amount of time before running the callback\n\t * @param args additional arguments to pass back to the callback\n\t */\n\tpublic static setInterval<A = unknown>(fn: (...args: A[]) => void, delay: number, ...args: A[]): NodeJS.Timeout {\n\t\tconst interval = setInterval(fn, delay, ...args);\n\t\tthis.storedIntervals.add(interval);\n\t\treturn interval;\n\t}\n\n\t/**\n\t * Clears an internal created through this class\n\t * @param interval The interval to clear\n\t */\n\tpublic static clearInterval(interval: NodeJS.Timeout): void {\n\t\tclearInterval(interval);\n\t\tthis.storedIntervals.delete(interval);\n\t}\n\n\t/**\n\t * Clears running timeouts and intervals created through this class so NodeJS can gracefully exit\n\t */\n\tpublic static destroy(): void {\n\t\tfor (const i of this.storedTimeouts) clearTimeout(i);\n\t\tfor (const i of this.storedIntervals) clearInterval(i);\n\t\tthis.storedTimeouts.clear();\n\t\tthis.storedIntervals.clear();\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../src/lib/TimerManager.ts"],"names":[],"mappings":";;;;;;AAGO,IAAM,aAAA,GAAN,MAAM,aAAA,SAAqB,IAAK,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBtC,OAAc,UAAA,CAAwB,EAA4B,EAAA,KAAA,EAAA,GAAkB,IAA2B,EAAA;AAC9G,IAAM,MAAA,OAAA,GAAU,WAAW,MAAM;AAChC,MAAK,IAAA,CAAA,cAAA,CAAe,OAAO,OAAO,CAAA,CAAA;AAClC,MAAA,EAAA,CAAG,GAAG,IAAI,CAAA,CAAA;AAAA,OACR,KAAK,CAAA,CAAA;AACR,IAAK,IAAA,CAAA,cAAA,CAAe,IAAI,OAAO,CAAA,CAAA;AAC/B,IAAO,OAAA,OAAA,CAAA;AAAA,GACR;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAc,aAAa,OAA+B,EAAA;AACzD,IAAA,YAAA,CAAa,OAAO,CAAA,CAAA;AACpB,IAAK,IAAA,CAAA,cAAA,CAAe,OAAO,OAAO,CAAA,CAAA;AAAA,GACnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAc,WAAA,CAAyB,EAA4B,EAAA,KAAA,EAAA,GAAkB,IAA2B,EAAA;AAC/G,IAAA,MAAM,QAAW,GAAA,WAAA,CAAY,EAAI,EAAA,KAAA,EAAO,GAAG,IAAI,CAAA,CAAA;AAC/C,IAAK,IAAA,CAAA,eAAA,CAAgB,IAAI,QAAQ,CAAA,CAAA;AACjC,IAAO,OAAA,QAAA,CAAA;AAAA,GACR;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAc,cAAc,QAAgC,EAAA;AAC3D,IAAA,aAAA,CAAc,QAAQ,CAAA,CAAA;AACtB,IAAK,IAAA,CAAA,eAAA,CAAgB,OAAO,QAAQ,CAAA,CAAA;AAAA,GACrC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAc,OAAgB,GAAA;AAC7B,IAAA,KAAA,MAAW,CAAK,IAAA,IAAA,CAAK,cAAgB,EAAA,YAAA,CAAa,CAAC,CAAA,CAAA;AACnD,IAAA,KAAA,MAAW,CAAK,IAAA,IAAA,CAAK,eAAiB,EAAA,aAAA,CAAc,CAAC,CAAA,CAAA;AACrD,IAAA,IAAA,CAAK,eAAe,KAAM,EAAA,CAAA;AAC1B,IAAA,IAAA,CAAK,gBAAgB,KAAM,EAAA,CAAA;AAAA,GAC5B;AACD,CAAA,CAAA;AAjEuC,MAAA,CAAA,aAAA,EAAA,cAAA,CAAA,CAAA;AAAA;AAAA;AAAA;AAItC,aAJY,CAAA,aAAA,EAIG,gBAAiB,kBAAA,IAAI,GAAoB,EAAA,CAAA,CAAA;AAAA;AAAA;AAAA;AAKxD,aATY,CAAA,aAAA,EASG,iBAAkB,kBAAA,IAAI,GAAoB,EAAA,CAAA,CAAA;AATnD,IAAM,YAAN,GAAA","file":"index.mjs","sourcesContent":["/**\n * Manages timers so that this application can be cleanly exited\n */\nexport class TimerManager extends null {\n\t/**\n\t * A set of timeouts to clear on destroy\n\t */\n\tprivate static storedTimeouts = new Set<NodeJS.Timeout>();\n\n\t/**\n\t * A set of intervals to clear on destroy\n\t */\n\tprivate static storedIntervals = new Set<NodeJS.Timeout>();\n\n\t/**\n\t * Creates a timeout gets cleared when destroyed\n\t * @param fn callback function\n\t * @param delay amount of time before running the callback\n\t * @param args additional arguments to pass back to the callback\n\t */\n\tpublic static setTimeout<A = unknown>(fn: (...args: A[]) => void, delay: number, ...args: A[]): NodeJS.Timeout {\n\t\tconst timeout = setTimeout(() => {\n\t\t\tthis.storedTimeouts.delete(timeout);\n\t\t\tfn(...args);\n\t\t}, delay);\n\t\tthis.storedTimeouts.add(timeout);\n\t\treturn timeout;\n\t}\n\n\t/**\n\t * Clears a timeout created through this class\n\t * @param timeout The timeout to clear\n\t */\n\tpublic static clearTimeout(timeout: NodeJS.Timeout): void {\n\t\tclearTimeout(timeout);\n\t\tthis.storedTimeouts.delete(timeout);\n\t}\n\n\t/**\n\t * Creates an interval gets cleared when destroyed\n\t * @param fn callback function\n\t * @param delay amount of time before running the callback\n\t * @param args additional arguments to pass back to the callback\n\t */\n\tpublic static setInterval<A = unknown>(fn: (...args: A[]) => void, delay: number, ...args: A[]): NodeJS.Timeout {\n\t\tconst interval = setInterval(fn, delay, ...args);\n\t\tthis.storedIntervals.add(interval);\n\t\treturn interval;\n\t}\n\n\t/**\n\t * Clears an internal created through this class\n\t * @param interval The interval to clear\n\t */\n\tpublic static clearInterval(interval: NodeJS.Timeout): void {\n\t\tclearInterval(interval);\n\t\tthis.storedIntervals.delete(interval);\n\t}\n\n\t/**\n\t * Clears running timeouts and intervals created through this class so NodeJS can gracefully exit\n\t */\n\tpublic static destroy(): void {\n\t\tfor (const i of this.storedTimeouts) clearTimeout(i);\n\t\tfor (const i of this.storedIntervals) clearInterval(i);\n\t\tthis.storedTimeouts.clear();\n\t\tthis.storedIntervals.clear();\n\t}\n}\n"]}
@@ -4,10 +4,7 @@ var SapphireTimerManager = (function (exports) {
4
4
  var __defProp = Object.defineProperty;
5
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
6
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
- var __publicField = (obj, key, value) => {
8
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
9
- return value;
10
- };
7
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
11
8
 
12
9
  // src/lib/TimerManager.ts
13
10
  var _TimerManager = class _TimerManager extends null {
@@ -56,10 +53,8 @@ var SapphireTimerManager = (function (exports) {
56
53
  * Clears running timeouts and intervals created through this class so NodeJS can gracefully exit
57
54
  */
58
55
  static destroy() {
59
- for (const i of this.storedTimeouts)
60
- clearTimeout(i);
61
- for (const i of this.storedIntervals)
62
- clearInterval(i);
56
+ for (const i of this.storedTimeouts) clearTimeout(i);
57
+ for (const i of this.storedIntervals) clearInterval(i);
63
58
  this.storedTimeouts.clear();
64
59
  this.storedIntervals.clear();
65
60
  }
@@ -80,5 +75,5 @@ var SapphireTimerManager = (function (exports) {
80
75
  return exports;
81
76
 
82
77
  })({});
83
- //# sourceMappingURL=out.js.map
78
+ //# sourceMappingURL=index.global.js.map
84
79
  //# sourceMappingURL=index.global.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/TimerManager.ts"],"names":[],"mappings":";;;;;;;;;AAGO,IAAM,gBAAN,MAAM,sBAAqB,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBtC,OAAc,WAAwB,IAA4B,UAAkB,MAA2B;AAC9G,UAAM,UAAU,WAAW,MAAM;AAChC,WAAK,eAAe,OAAO,OAAO;AAClC,SAAG,GAAG,IAAI;AAAA,IACX,GAAG,KAAK;AACR,SAAK,eAAe,IAAI,OAAO;AAC/B,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAc,aAAa,SAA+B;AACzD,iBAAa,OAAO;AACpB,SAAK,eAAe,OAAO,OAAO;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAc,YAAyB,IAA4B,UAAkB,MAA2B;AAC/G,UAAM,WAAW,YAAY,IAAI,OAAO,GAAG,IAAI;AAC/C,SAAK,gBAAgB,IAAI,QAAQ;AACjC,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAc,cAAc,UAAgC;AAC3D,kBAAc,QAAQ;AACtB,SAAK,gBAAgB,OAAO,QAAQ;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAc,UAAgB;AAC7B,eAAW,KAAK,KAAK;AAAgB,mBAAa,CAAC;AACnD,eAAW,KAAK,KAAK;AAAiB,oBAAc,CAAC;AACrD,SAAK,eAAe,MAAM;AAC1B,SAAK,gBAAgB,MAAM;AAAA,EAC5B;AACD;AAjEuC;AAAA;AAAA;AAAA;AAItC,cAJY,eAIG,kBAAiB,oBAAI,IAAoB;AAAA;AAAA;AAAA;AAKxD,cATY,eASG,mBAAkB,oBAAI,IAAoB;AATnD,IAAM,eAAN","sourcesContent":["/**\n * Manages timers so that this application can be cleanly exited\n */\nexport class TimerManager extends null {\n\t/**\n\t * A set of timeouts to clear on destroy\n\t */\n\tprivate static storedTimeouts = new Set<NodeJS.Timeout>();\n\n\t/**\n\t * A set of intervals to clear on destroy\n\t */\n\tprivate static storedIntervals = new Set<NodeJS.Timeout>();\n\n\t/**\n\t * Creates a timeout gets cleared when destroyed\n\t * @param fn callback function\n\t * @param delay amount of time before running the callback\n\t * @param args additional arguments to pass back to the callback\n\t */\n\tpublic static setTimeout<A = unknown>(fn: (...args: A[]) => void, delay: number, ...args: A[]): NodeJS.Timeout {\n\t\tconst timeout = setTimeout(() => {\n\t\t\tthis.storedTimeouts.delete(timeout);\n\t\t\tfn(...args);\n\t\t}, delay);\n\t\tthis.storedTimeouts.add(timeout);\n\t\treturn timeout;\n\t}\n\n\t/**\n\t * Clears a timeout created through this class\n\t * @param timeout The timeout to clear\n\t */\n\tpublic static clearTimeout(timeout: NodeJS.Timeout): void {\n\t\tclearTimeout(timeout);\n\t\tthis.storedTimeouts.delete(timeout);\n\t}\n\n\t/**\n\t * Creates an interval gets cleared when destroyed\n\t * @param fn callback function\n\t * @param delay amount of time before running the callback\n\t * @param args additional arguments to pass back to the callback\n\t */\n\tpublic static setInterval<A = unknown>(fn: (...args: A[]) => void, delay: number, ...args: A[]): NodeJS.Timeout {\n\t\tconst interval = setInterval(fn, delay, ...args);\n\t\tthis.storedIntervals.add(interval);\n\t\treturn interval;\n\t}\n\n\t/**\n\t * Clears an internal created through this class\n\t * @param interval The interval to clear\n\t */\n\tpublic static clearInterval(interval: NodeJS.Timeout): void {\n\t\tclearInterval(interval);\n\t\tthis.storedIntervals.delete(interval);\n\t}\n\n\t/**\n\t * Clears running timeouts and intervals created through this class so NodeJS can gracefully exit\n\t */\n\tpublic static destroy(): void {\n\t\tfor (const i of this.storedTimeouts) clearTimeout(i);\n\t\tfor (const i of this.storedIntervals) clearInterval(i);\n\t\tthis.storedTimeouts.clear();\n\t\tthis.storedIntervals.clear();\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../src/lib/TimerManager.ts"],"names":[],"mappings":";;;;;;;;;EAGO,IAAM,aAAA,GAAN,MAAM,aAAA,SAAqB,IAAK,CAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA,EAiBtC,OAAc,UAAA,CAAwB,EAA4B,EAAA,KAAA,EAAA,GAAkB,IAA2B,EAAA;EAC9G,IAAM,MAAA,OAAA,GAAU,WAAW,MAAM;EAChC,MAAK,IAAA,CAAA,cAAA,CAAe,OAAO,OAAO,CAAA,CAAA;EAClC,MAAA,EAAA,CAAG,GAAG,IAAI,CAAA,CAAA;EAAA,OACR,KAAK,CAAA,CAAA;EACR,IAAK,IAAA,CAAA,cAAA,CAAe,IAAI,OAAO,CAAA,CAAA;EAC/B,IAAO,OAAA,OAAA,CAAA;EAAA,GACR;EAAA;EAAA;EAAA;EAAA;EAAA,EAMA,OAAc,aAAa,OAA+B,EAAA;EACzD,IAAA,YAAA,CAAa,OAAO,CAAA,CAAA;EACpB,IAAK,IAAA,CAAA,cAAA,CAAe,OAAO,OAAO,CAAA,CAAA;EAAA,GACnC;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA,EAQA,OAAc,WAAA,CAAyB,EAA4B,EAAA,KAAA,EAAA,GAAkB,IAA2B,EAAA;EAC/G,IAAA,MAAM,QAAW,GAAA,WAAA,CAAY,EAAI,EAAA,KAAA,EAAO,GAAG,IAAI,CAAA,CAAA;EAC/C,IAAK,IAAA,CAAA,eAAA,CAAgB,IAAI,QAAQ,CAAA,CAAA;EACjC,IAAO,OAAA,QAAA,CAAA;EAAA,GACR;EAAA;EAAA;EAAA;EAAA;EAAA,EAMA,OAAc,cAAc,QAAgC,EAAA;EAC3D,IAAA,aAAA,CAAc,QAAQ,CAAA,CAAA;EACtB,IAAK,IAAA,CAAA,eAAA,CAAgB,OAAO,QAAQ,CAAA,CAAA;EAAA,GACrC;EAAA;EAAA;EAAA;EAAA,EAKA,OAAc,OAAgB,GAAA;EAC7B,IAAA,KAAA,MAAW,CAAK,IAAA,IAAA,CAAK,cAAgB,EAAA,YAAA,CAAa,CAAC,CAAA,CAAA;EACnD,IAAA,KAAA,MAAW,CAAK,IAAA,IAAA,CAAK,eAAiB,EAAA,aAAA,CAAc,CAAC,CAAA,CAAA;EACrD,IAAA,IAAA,CAAK,eAAe,KAAM,EAAA,CAAA;EAC1B,IAAA,IAAA,CAAK,gBAAgB,KAAM,EAAA,CAAA;EAAA,GAC5B;EACD,CAAA,CAAA;EAjEuC,MAAA,CAAA,aAAA,EAAA,cAAA,CAAA,CAAA;EAAA;EAAA;EAAA;EAItC,aAJY,CAAA,aAAA,EAIG,gBAAiB,kBAAA,IAAI,GAAoB,EAAA,CAAA,CAAA;EAAA;EAAA;EAAA;EAKxD,aATY,CAAA,aAAA,EASG,iBAAkB,kBAAA,IAAI,GAAoB,EAAA,CAAA,CAAA;AATnD,MAAM,YAAN,GAAA","file":"index.global.js","sourcesContent":["/**\n * Manages timers so that this application can be cleanly exited\n */\nexport class TimerManager extends null {\n\t/**\n\t * A set of timeouts to clear on destroy\n\t */\n\tprivate static storedTimeouts = new Set<NodeJS.Timeout>();\n\n\t/**\n\t * A set of intervals to clear on destroy\n\t */\n\tprivate static storedIntervals = new Set<NodeJS.Timeout>();\n\n\t/**\n\t * Creates a timeout gets cleared when destroyed\n\t * @param fn callback function\n\t * @param delay amount of time before running the callback\n\t * @param args additional arguments to pass back to the callback\n\t */\n\tpublic static setTimeout<A = unknown>(fn: (...args: A[]) => void, delay: number, ...args: A[]): NodeJS.Timeout {\n\t\tconst timeout = setTimeout(() => {\n\t\t\tthis.storedTimeouts.delete(timeout);\n\t\t\tfn(...args);\n\t\t}, delay);\n\t\tthis.storedTimeouts.add(timeout);\n\t\treturn timeout;\n\t}\n\n\t/**\n\t * Clears a timeout created through this class\n\t * @param timeout The timeout to clear\n\t */\n\tpublic static clearTimeout(timeout: NodeJS.Timeout): void {\n\t\tclearTimeout(timeout);\n\t\tthis.storedTimeouts.delete(timeout);\n\t}\n\n\t/**\n\t * Creates an interval gets cleared when destroyed\n\t * @param fn callback function\n\t * @param delay amount of time before running the callback\n\t * @param args additional arguments to pass back to the callback\n\t */\n\tpublic static setInterval<A = unknown>(fn: (...args: A[]) => void, delay: number, ...args: A[]): NodeJS.Timeout {\n\t\tconst interval = setInterval(fn, delay, ...args);\n\t\tthis.storedIntervals.add(interval);\n\t\treturn interval;\n\t}\n\n\t/**\n\t * Clears an internal created through this class\n\t * @param interval The interval to clear\n\t */\n\tpublic static clearInterval(interval: NodeJS.Timeout): void {\n\t\tclearInterval(interval);\n\t\tthis.storedIntervals.delete(interval);\n\t}\n\n\t/**\n\t * Clears running timeouts and intervals created through this class so NodeJS can gracefully exit\n\t */\n\tpublic static destroy(): void {\n\t\tfor (const i of this.storedTimeouts) clearTimeout(i);\n\t\tfor (const i of this.storedIntervals) clearInterval(i);\n\t\tthis.storedTimeouts.clear();\n\t\tthis.storedIntervals.clear();\n\t}\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sapphire/timer-manager",
3
- "version": "1.0.3-next.a3da0ab0",
3
+ "version": "1.0.3-next.a6c8ccda",
4
4
  "description": "A timer manager utility library for JavaScript.",
5
5
  "author": "@sapphire",
6
6
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "prepack": "yarn build",
32
32
  "bump": "cliff-jumper",
33
33
  "check-update": "cliff-jumper --dry-run",
34
- "gen-index": "tsx ../../scripts/gen-index.cts -w timer-manager"
34
+ "gen-index": "tsx ../../scripts/gen-index.cts timer-manager --write"
35
35
  },
36
36
  "repository": {
37
37
  "type": "git",
@@ -63,13 +63,13 @@
63
63
  "access": "public"
64
64
  },
65
65
  "devDependencies": {
66
- "@favware/cliff-jumper": "^4.0.2",
67
- "@vitest/coverage-v8": "^1.6.0",
68
- "tsup": "^8.0.2",
69
- "tsx": "^4.11.0",
66
+ "@favware/cliff-jumper": "^5.0.0",
67
+ "@vitest/coverage-v8": "^2.1.3",
68
+ "tsup": "^8.3.0",
69
+ "tsx": "^4.19.1",
70
70
  "typedoc": "^0.25.13",
71
71
  "typedoc-json-parser": "^10.0.0",
72
- "typescript": "^5.4.5",
73
- "vitest": "^1.6.0"
72
+ "typescript": "~5.4.5",
73
+ "vitest": "^2.1.3"
74
74
  }
75
75
  }