@sapphire/stopwatch 1.5.0 β†’ 1.5.1-next.006b002f.0

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
@@ -76,70 +76,14 @@ We accept donations through Open Collective, Ko-fi, PayPal, Patreon and GitHub S
76
76
  | Patreon | [Click Here](https://sapphirejs.dev/patreon) |
77
77
  | PayPal | [Click Here](https://sapphirejs.dev/paypal) |
78
78
 
79
- ## Contributors ✨
80
-
81
- Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
82
-
83
- <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
84
- <!-- prettier-ignore-start -->
85
- <!-- markdownlint-disable -->
86
- <table>
87
- <tr>
88
- <td align="center"><a href="https://favware.tech/"><img src="https://avatars3.githubusercontent.com/u/4019718?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jeroen Claassens</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=favna" title="Code">πŸ’»</a> <a href="#infra-favna" title="Infrastructure (Hosting, Build-Tools, etc)">πŸš‡</a> <a href="#projectManagement-favna" title="Project Management">πŸ“†</a> <a href="https://github.com/sapphiredev/utilities/commits?author=favna" title="Documentation">πŸ“–</a> <a href="https://github.com/sapphiredev/utilities/commits?author=favna" title="Tests">⚠️</a></td>
89
- <td align="center"><a href="https://github.com/kyranet"><img src="https://avatars0.githubusercontent.com/u/24852502?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Aura RomΓ‘n</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=kyranet" title="Code">πŸ’»</a> <a href="#projectManagement-kyranet" title="Project Management">πŸ“†</a> <a href="https://github.com/sapphiredev/utilities/pulls?q=is%3Apr+reviewed-by%3Akyranet" title="Reviewed Pull Requests">πŸ‘€</a> <a href="https://github.com/sapphiredev/utilities/commits?author=kyranet" title="Tests">⚠️</a></td>
90
- <td align="center"><a href="https://github.com/PyroTechniac"><img src="https://avatars2.githubusercontent.com/u/39341355?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Gryffon Bellish</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=PyroTechniac" title="Code">πŸ’»</a> <a href="https://github.com/sapphiredev/utilities/pulls?q=is%3Apr+reviewed-by%3APyroTechniac" title="Reviewed Pull Requests">πŸ‘€</a> <a href="https://github.com/sapphiredev/utilities/commits?author=PyroTechniac" title="Tests">⚠️</a></td>
91
- <td align="center"><a href="https://github.com/vladfrangu"><img src="https://avatars3.githubusercontent.com/u/17960496?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vlad Frangu</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=vladfrangu" title="Code">πŸ’»</a> <a href="https://github.com/sapphiredev/utilities/issues?q=author%3Avladfrangu" title="Bug reports">πŸ›</a> <a href="https://github.com/sapphiredev/utilities/pulls?q=is%3Apr+reviewed-by%3Avladfrangu" title="Reviewed Pull Requests">πŸ‘€</a> <a href="#userTesting-vladfrangu" title="User Testing">πŸ““</a> <a href="https://github.com/sapphiredev/utilities/commits?author=vladfrangu" title="Tests">⚠️</a></td>
92
- <td align="center"><a href="https://github.com/Stitch07"><img src="https://avatars0.githubusercontent.com/u/29275227?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stitch07</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Stitch07" title="Code">πŸ’»</a> <a href="#projectManagement-Stitch07" title="Project Management">πŸ“†</a> <a href="https://github.com/sapphiredev/utilities/commits?author=Stitch07" title="Tests">⚠️</a></td>
93
- <td align="center"><a href="https://github.com/apps/depfu"><img src="https://avatars3.githubusercontent.com/in/715?v=4?s=100" width="100px;" alt=""/><br /><sub><b>depfu[bot]</b></sub></a><br /><a href="#maintenance-depfu[bot]" title="Maintenance">🚧</a></td>
94
- <td align="center"><a href="https://github.com/apps/allcontributors"><img src="https://avatars0.githubusercontent.com/in/23186?v=4?s=100" width="100px;" alt=""/><br /><sub><b>allcontributors[bot]</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=allcontributors[bot]" title="Documentation">πŸ“–</a></td>
95
- </tr>
96
- <tr>
97
- <td align="center"><a href="https://github.com/Nytelife26"><img src="https://avatars1.githubusercontent.com/u/22531310?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tyler J Russell</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Nytelife26" title="Documentation">πŸ“–</a></td>
98
- <td align="center"><a href="https://github.com/Alcremie"><img src="https://avatars0.githubusercontent.com/u/54785334?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ivan Lieder</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Alcremie" title="Code">πŸ’»</a> <a href="https://github.com/sapphiredev/utilities/issues?q=author%3AAlcremie" title="Bug reports">πŸ›</a></td>
99
- <td align="center"><a href="https://github.com/RealShadowNova"><img src="https://avatars3.githubusercontent.com/u/46537907?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Hezekiah Hendry</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=RealShadowNova" title="Code">πŸ’»</a> <a href="#tool-RealShadowNova" title="Tools">πŸ”§</a></td>
100
- <td align="center"><a href="https://github.com/Vetlix"><img src="https://avatars.githubusercontent.com/u/31412314?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vetlix</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Vetlix" title="Code">πŸ’»</a></td>
101
- <td align="center"><a href="https://github.com/ethamitc"><img src="https://avatars.githubusercontent.com/u/27776796?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ethan Mitchell</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=ethamitc" title="Documentation">πŸ“–</a></td>
102
- <td align="center"><a href="https://github.com/noftaly"><img src="https://avatars.githubusercontent.com/u/34779161?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Elliot</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=noftaly" title="Code">πŸ’»</a></td>
103
- <td align="center"><a href="https://jurien.dev"><img src="https://avatars.githubusercontent.com/u/5418114?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jurien Hamaker</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=jurienhamaker" title="Code">πŸ’»</a></td>
104
- </tr>
105
- <tr>
106
- <td align="center"><a href="https://fanoulis.dev/"><img src="https://avatars.githubusercontent.com/u/38255093?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Charalampos Fanoulis</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=cfanoulis" title="Documentation">πŸ“–</a></td>
107
- <td align="center"><a href="https://github.com/apps/dependabot"><img src="https://avatars.githubusercontent.com/in/29110?v=4?s=100" width="100px;" alt=""/><br /><sub><b>dependabot[bot]</b></sub></a><br /><a href="#maintenance-dependabot[bot]" title="Maintenance">🚧</a></td>
108
- <td align="center"><a href="https://kaname.netlify.app/"><img src="https://avatars.githubusercontent.com/u/56084970?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kaname</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=kaname-png" title="Code">πŸ’»</a></td>
109
- <td align="center"><a href="https://github.com/nandhagk"><img src="https://avatars.githubusercontent.com/u/62976649?v=4?s=100" width="100px;" alt=""/><br /><sub><b>nandhagk</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/issues?q=author%3Anandhagk" title="Bug reports">πŸ›</a></td>
110
- <td align="center"><a href="https://megatank58.me/"><img src="https://avatars.githubusercontent.com/u/51410502?v=4?s=100" width="100px;" alt=""/><br /><sub><b>megatank58</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=megatank58" title="Code">πŸ’»</a></td>
111
- <td align="center"><a href="https://github.com/UndiedGamer"><img src="https://avatars.githubusercontent.com/u/84702365?v=4?s=100" width="100px;" alt=""/><br /><sub><b>UndiedGamer</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=UndiedGamer" title="Code">πŸ’»</a></td>
112
- <td align="center"><a href="https://github.com/Lioness100"><img src="https://avatars.githubusercontent.com/u/65814829?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Lioness100</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Lioness100" title="Documentation">πŸ“–</a> <a href="https://github.com/sapphiredev/utilities/commits?author=Lioness100" title="Code">πŸ’»</a></td>
113
- </tr>
114
- <tr>
115
- <td align="center"><a href="https://gitlab.com/DavidPH/"><img src="https://avatars.githubusercontent.com/u/44669930?v=4?s=100" width="100px;" alt=""/><br /><sub><b>David</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=DavidPHH" title="Code">πŸ’»</a></td>
116
- <td align="center"><a href="https://github.com/apps/renovate"><img src="https://avatars.githubusercontent.com/in/2740?v=4?s=100" width="100px;" alt=""/><br /><sub><b>renovate[bot]</b></sub></a><br /><a href="#maintenance-renovate[bot]" title="Maintenance">🚧</a></td>
117
- <td align="center"><a href="https://renovate.whitesourcesoftware.com/"><img src="https://avatars.githubusercontent.com/u/25180681?v=4?s=100" width="100px;" alt=""/><br /><sub><b>WhiteSource Renovate</b></sub></a><br /><a href="#maintenance-renovate-bot" title="Maintenance">🚧</a></td>
118
- <td align="center"><a href="https://fc5570.me/"><img src="https://avatars.githubusercontent.com/u/68158483?v=4?s=100" width="100px;" alt=""/><br /><sub><b>FC</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=FC5570" title="Code">πŸ’»</a></td>
119
- <td align="center"><a href="https://github.com/Tokipudi"><img src="https://avatars.githubusercontent.com/u/29551076?v=4?s=100" width="100px;" alt=""/><br /><sub><b>JΓ©rΓ©my de Saint Denis</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Tokipudi" title="Code">πŸ’»</a></td>
120
- <td align="center"><a href="https://github.com/ItsMrCube"><img src="https://avatars.githubusercontent.com/u/25201357?v=4?s=100" width="100px;" alt=""/><br /><sub><b>MrCube</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=ItsMrCube" title="Code">πŸ’»</a></td>
121
- <td align="center"><a href="https://github.com/bitomic"><img src="https://avatars.githubusercontent.com/u/35199700?v=4?s=100" width="100px;" alt=""/><br /><sub><b>bitomic</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=bitomic" title="Code">πŸ’»</a></td>
122
- </tr>
123
- <tr>
124
- <td align="center"><a href="https://c43721.dev/"><img src="https://avatars.githubusercontent.com/u/55610086?v=4?s=100" width="100px;" alt=""/><br /><sub><b>c43721</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=c43721" title="Code">πŸ’»</a></td>
125
- <td align="center"><a href="https://commandtechno.com/"><img src="https://avatars.githubusercontent.com/u/68407783?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Commandtechno</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Commandtechno" title="Code">πŸ’»</a></td>
126
- <td align="center"><a href="https://github.com/dhruv-kaushikk"><img src="https://avatars.githubusercontent.com/u/73697546?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Aura</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=dhruv-kaushikk" title="Code">πŸ’»</a></td>
127
- <td align="center"><a href="https://axis.moe/"><img src="https://avatars.githubusercontent.com/u/54381371?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jonathan</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=axisiscool" title="Code">πŸ’»</a></td>
128
- <td align="center"><a href="https://github.com/imranbarbhuiya"><img src="https://avatars.githubusercontent.com/u/74945038?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Parbez</b></sub></a><br /><a href="#maintenance-imranbarbhuiya" title="Maintenance">🚧</a></td>
129
- <td align="center"><a href="https://github.com/NotKaskus"><img src="https://avatars.githubusercontent.com/u/75168528?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Paul Andrew</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=NotKaskus" title="Documentation">πŸ“–</a></td>
130
- <td align="center"><a href="https://linktr.ee/mzato0001"><img src="https://avatars.githubusercontent.com/u/62367547?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mzato</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Mzato0001" title="Code">πŸ’»</a> <a href="https://github.com/sapphiredev/utilities/issues?q=author%3AMzato0001" title="Bug reports">πŸ›</a></td>
131
- </tr>
132
- <tr>
133
- <td align="center"><a href="https://github.com/MajesticString"><img src="https://avatars.githubusercontent.com/u/66224939?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Harry Allen</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=MajesticString" title="Documentation">πŸ“–</a></td>
134
- <td align="center"><a href="https://github.com/EvolutionX-10"><img src="https://avatars.githubusercontent.com/u/85353424?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Evo</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=EvolutionX-10" title="Code">πŸ’»</a></td>
135
- <td align="center"><a href="https://enes.ovh/"><img src="https://avatars.githubusercontent.com/u/61084101?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Enes GenΓ§</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=enxg" title="Code">πŸ’»</a></td>
136
- <td align="center"><a href="https://github.com/muchnameless"><img src="https://avatars.githubusercontent.com/u/12682826?v=4?s=100" width="100px;" alt=""/><br /><sub><b>muchnameless</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=muchnameless" title="Code">πŸ’»</a></td>
137
- </tr>
138
- </table>
139
-
140
- <!-- markdownlint-restore -->
141
- <!-- prettier-ignore-end -->
142
-
143
- <!-- ALL-CONTRIBUTORS-LIST:END -->
144
-
145
- This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
79
+ ## Contributors
80
+
81
+ Please make sure to read the [Contributing Guide][contributing] before making a pull request.
82
+
83
+ Thank you to all the people who already contributed to Sapphire!
84
+
85
+ <a href="https://github.com/sapphiredev/utilities/graphs/contributors">
86
+ <img src="https://contrib.rocks/image?repo=sapphiredev/utilities" />
87
+ </a>
88
+
89
+ [contributing]: https://github.com/sapphiredev/.github/blob/main/.github/CONTRIBUTING.md
@@ -30,30 +30,57 @@ var SapphireStopwatch = (function (exports) {
30
30
  // src/index.ts
31
31
  var _start, _end;
32
32
  var Stopwatch = class {
33
+ /**
34
+ * Starts a new stopwatch
35
+ */
33
36
  constructor(digits = 2) {
37
+ /**
38
+ * The number of digits to appear after the decimal point when returning the friendly duration.
39
+ */
34
40
  __publicField(this, "digits");
41
+ /**
42
+ * The start time of this stopwatch
43
+ */
35
44
  __privateAdd(this, _start, void 0);
45
+ /**
46
+ * The end time of this stopwatch
47
+ */
36
48
  __privateAdd(this, _end, void 0);
37
49
  this.digits = digits;
38
50
  __privateSet(this, _start, performance.now());
39
51
  __privateSet(this, _end, null);
40
52
  }
53
+ /**
54
+ * The duration of this stopwatch since start or start to end if this stopwatch has stopped.
55
+ */
41
56
  get duration() {
42
57
  return __privateGet(this, _end) ? __privateGet(this, _end) - __privateGet(this, _start) : performance.now() - __privateGet(this, _start);
43
58
  }
59
+ /**
60
+ * If the stopwatch is running or not.
61
+ */
44
62
  get running() {
45
63
  return Boolean(!__privateGet(this, _end));
46
64
  }
65
+ /**
66
+ * Restarts the stopwatch (Returns a running state)
67
+ */
47
68
  restart() {
48
69
  __privateSet(this, _start, performance.now());
49
70
  __privateSet(this, _end, null);
50
71
  return this;
51
72
  }
73
+ /**
74
+ * Resets the Stopwatch to 0 duration (Returns a stopped state)
75
+ */
52
76
  reset() {
53
77
  __privateSet(this, _start, performance.now());
54
78
  __privateSet(this, _end, __privateGet(this, _start));
55
79
  return this;
56
80
  }
81
+ /**
82
+ * Starts the Stopwatch
83
+ */
57
84
  start() {
58
85
  if (!this.running) {
59
86
  __privateSet(this, _start, performance.now() - this.duration);
@@ -61,11 +88,17 @@ var SapphireStopwatch = (function (exports) {
61
88
  }
62
89
  return this;
63
90
  }
91
+ /**
92
+ * Stops the Stopwatch, freezing the duration
93
+ */
64
94
  stop() {
65
95
  if (this.running)
66
96
  __privateSet(this, _end, performance.now());
67
97
  return this;
68
98
  }
99
+ /**
100
+ * Defines toString behavior
101
+ */
69
102
  toString() {
70
103
  const time = this.duration;
71
104
  if (time >= 1e3)
@@ -81,9 +114,8 @@ var SapphireStopwatch = (function (exports) {
81
114
 
82
115
  exports.Stopwatch = Stopwatch;
83
116
 
84
- Object.defineProperty(exports, '__esModule', { value: true });
85
-
86
117
  return exports;
87
118
 
88
119
  })({});
120
+ //# sourceMappingURL=out.js.map
89
121
  //# sourceMappingURL=index.global.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAGO,IAAM,YAAN,MAAgB;AAAA,EAmBf,YAAY,SAAS,GAAG;AAf/B,wBAAO;AAKP;AAKA;AAMC,SAAK,SAAS;AACd,uBAAK,QAAS,YAAY,IAAI;AAC9B,uBAAK,MAAO;AAAA,EACb;AAAA,EAKA,IAAW,WAAmB;AAC7B,WAAO,mBAAK,QAAO,mBAAK,QAAO,mBAAK,UAAS,YAAY,IAAI,IAAI,mBAAK;AAAA,EACvE;AAAA,EAKA,IAAW,UAAmB;AAC7B,WAAO,QAAQ,CAAC,mBAAK,KAAI;AAAA,EAC1B;AAAA,EAKO,UAAgB;AACtB,uBAAK,QAAS,YAAY,IAAI;AAC9B,uBAAK,MAAO;AACZ,WAAO;AAAA,EACR;AAAA,EAKO,QAAc;AACpB,uBAAK,QAAS,YAAY,IAAI;AAC9B,uBAAK,MAAO,mBAAK;AACjB,WAAO;AAAA,EACR;AAAA,EAKO,QAAc;AACpB,QAAI,CAAC,KAAK,SAAS;AAClB,yBAAK,QAAS,YAAY,IAAI,IAAI,KAAK;AACvC,yBAAK,MAAO;AAAA,IACb;AAEA,WAAO;AAAA,EACR;AAAA,EAKO,OAAa;AACnB,QAAI,KAAK;AAAS,yBAAK,MAAO,YAAY,IAAI;AAC9C,WAAO;AAAA,EACR;AAAA,EAKO,WAAmB;AACzB,UAAM,OAAO,KAAK;AAClB,QAAI,QAAQ;AAAM,aAAO,IAAI,OAAO,KAAM,QAAQ,KAAK,MAAM;AAC7D,QAAI,QAAQ;AAAG,aAAO,GAAG,KAAK,QAAQ,KAAK,MAAM;AACjD,WAAO,IAAI,OAAO,KAAM,QAAQ,KAAK,MAAM;AAAA,EAC5C;AACD;AAtFa;AASZ;AAKA","sourcesContent":["/**\n * Stopwatch class, uses native node to replicate/extend performance-now dependency.\n */\nexport class Stopwatch {\n\t/**\n\t * The number of digits to appear after the decimal point when returning the friendly duration.\n\t */\n\tpublic digits: number;\n\n\t/**\n\t * The start time of this stopwatch\n\t */\n\t#start: number;\n\n\t/**\n\t * The end time of this stopwatch\n\t */\n\t#end: number | null;\n\n\t/**\n\t * Starts a new stopwatch\n\t */\n\tpublic constructor(digits = 2) {\n\t\tthis.digits = digits;\n\t\tthis.#start = performance.now();\n\t\tthis.#end = null;\n\t}\n\n\t/**\n\t * The duration of this stopwatch since start or start to end if this stopwatch has stopped.\n\t */\n\tpublic get duration(): number {\n\t\treturn this.#end ? this.#end - this.#start : performance.now() - this.#start;\n\t}\n\n\t/**\n\t * If the stopwatch is running or not.\n\t */\n\tpublic get running(): boolean {\n\t\treturn Boolean(!this.#end);\n\t}\n\n\t/**\n\t * Restarts the stopwatch (Returns a running state)\n\t */\n\tpublic restart(): this {\n\t\tthis.#start = performance.now();\n\t\tthis.#end = null;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Resets the Stopwatch to 0 duration (Returns a stopped state)\n\t */\n\tpublic reset(): this {\n\t\tthis.#start = performance.now();\n\t\tthis.#end = this.#start;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Starts the Stopwatch\n\t */\n\tpublic start(): this {\n\t\tif (!this.running) {\n\t\t\tthis.#start = performance.now() - this.duration;\n\t\t\tthis.#end = null;\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Stops the Stopwatch, freezing the duration\n\t */\n\tpublic stop(): this {\n\t\tif (this.running) this.#end = performance.now();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Defines toString behavior\n\t */\n\tpublic toString(): string {\n\t\tconst time = this.duration;\n\t\tif (time >= 1000) return `${(time / 1000).toFixed(this.digits)}s`;\n\t\tif (time >= 1) return `${time.toFixed(this.digits)}ms`;\n\t\treturn `${(time * 1000).toFixed(this.digits)}ΞΌs`;\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAGO,IAAM,YAAN,MAAgB;AAAA;AAAA;AAAA;AAAA,EAmBf,YAAY,SAAS,GAAG;AAf/B;AAAA;AAAA;AAAA,wBAAO;AAKP;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAMC,SAAK,SAAS;AACd,uBAAK,QAAS,YAAY,IAAI;AAC9B,uBAAK,MAAO;AAAA,EACb;AAAA;AAAA;AAAA;AAAA,EAKA,IAAW,WAAmB;AAC7B,WAAO,mBAAK,QAAO,mBAAK,QAAO,mBAAK,UAAS,YAAY,IAAI,IAAI,mBAAK;AAAA,EACvE;AAAA;AAAA;AAAA;AAAA,EAKA,IAAW,UAAmB;AAC7B,WAAO,QAAQ,CAAC,mBAAK,KAAI;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA,EAKO,UAAgB;AACtB,uBAAK,QAAS,YAAY,IAAI;AAC9B,uBAAK,MAAO;AACZ,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKO,QAAc;AACpB,uBAAK,QAAS,YAAY,IAAI;AAC9B,uBAAK,MAAO,mBAAK;AACjB,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKO,QAAc;AACpB,QAAI,CAAC,KAAK,SAAS;AAClB,yBAAK,QAAS,YAAY,IAAI,IAAI,KAAK;AACvC,yBAAK,MAAO;AAAA,IACb;AAEA,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKO,OAAa;AACnB,QAAI,KAAK;AAAS,yBAAK,MAAO,YAAY,IAAI;AAC9C,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKO,WAAmB;AACzB,UAAM,OAAO,KAAK;AAClB,QAAI,QAAQ;AAAM,aAAO,IAAI,OAAO,KAAM,QAAQ,KAAK,MAAM;AAC7D,QAAI,QAAQ;AAAG,aAAO,GAAG,KAAK,QAAQ,KAAK,MAAM;AACjD,WAAO,IAAI,OAAO,KAAM,QAAQ,KAAK,MAAM;AAAA,EAC5C;AACD;AAtFa;AASZ;AAKA","sourcesContent":["/**\n * Stopwatch class, uses native node to replicate/extend performance-now dependency.\n */\nexport class Stopwatch {\n\t/**\n\t * The number of digits to appear after the decimal point when returning the friendly duration.\n\t */\n\tpublic digits: number;\n\n\t/**\n\t * The start time of this stopwatch\n\t */\n\t#start: number;\n\n\t/**\n\t * The end time of this stopwatch\n\t */\n\t#end: number | null;\n\n\t/**\n\t * Starts a new stopwatch\n\t */\n\tpublic constructor(digits = 2) {\n\t\tthis.digits = digits;\n\t\tthis.#start = performance.now();\n\t\tthis.#end = null;\n\t}\n\n\t/**\n\t * The duration of this stopwatch since start or start to end if this stopwatch has stopped.\n\t */\n\tpublic get duration(): number {\n\t\treturn this.#end ? this.#end - this.#start : performance.now() - this.#start;\n\t}\n\n\t/**\n\t * If the stopwatch is running or not.\n\t */\n\tpublic get running(): boolean {\n\t\treturn Boolean(!this.#end);\n\t}\n\n\t/**\n\t * Restarts the stopwatch (Returns a running state)\n\t */\n\tpublic restart(): this {\n\t\tthis.#start = performance.now();\n\t\tthis.#end = null;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Resets the Stopwatch to 0 duration (Returns a stopped state)\n\t */\n\tpublic reset(): this {\n\t\tthis.#start = performance.now();\n\t\tthis.#end = this.#start;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Starts the Stopwatch\n\t */\n\tpublic start(): this {\n\t\tif (!this.running) {\n\t\t\tthis.#start = performance.now() - this.duration;\n\t\t\tthis.#end = null;\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Stops the Stopwatch, freezing the duration\n\t */\n\tpublic stop(): this {\n\t\tif (this.running) this.#end = performance.now();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Defines toString behavior\n\t */\n\tpublic toString(): string {\n\t\tconst time = this.duration;\n\t\tif (time >= 1000) return `${(time / 1000).toFixed(this.digits)}s`;\n\t\tif (time >= 1) return `${time.toFixed(this.digits)}ms`;\n\t\treturn `${(time * 1000).toFixed(this.digits)}ΞΌs`;\n\t}\n}\n"]}
package/dist/index.js CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var __defProp = Object.defineProperty;
6
4
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
5
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
@@ -31,30 +29,57 @@ var __privateSet = (obj, member, value, setter) => {
31
29
  // src/index.ts
32
30
  var _start, _end;
33
31
  var Stopwatch = class {
32
+ /**
33
+ * Starts a new stopwatch
34
+ */
34
35
  constructor(digits = 2) {
36
+ /**
37
+ * The number of digits to appear after the decimal point when returning the friendly duration.
38
+ */
35
39
  __publicField(this, "digits");
40
+ /**
41
+ * The start time of this stopwatch
42
+ */
36
43
  __privateAdd(this, _start, void 0);
44
+ /**
45
+ * The end time of this stopwatch
46
+ */
37
47
  __privateAdd(this, _end, void 0);
38
48
  this.digits = digits;
39
49
  __privateSet(this, _start, performance.now());
40
50
  __privateSet(this, _end, null);
41
51
  }
52
+ /**
53
+ * The duration of this stopwatch since start or start to end if this stopwatch has stopped.
54
+ */
42
55
  get duration() {
43
56
  return __privateGet(this, _end) ? __privateGet(this, _end) - __privateGet(this, _start) : performance.now() - __privateGet(this, _start);
44
57
  }
58
+ /**
59
+ * If the stopwatch is running or not.
60
+ */
45
61
  get running() {
46
62
  return Boolean(!__privateGet(this, _end));
47
63
  }
64
+ /**
65
+ * Restarts the stopwatch (Returns a running state)
66
+ */
48
67
  restart() {
49
68
  __privateSet(this, _start, performance.now());
50
69
  __privateSet(this, _end, null);
51
70
  return this;
52
71
  }
72
+ /**
73
+ * Resets the Stopwatch to 0 duration (Returns a stopped state)
74
+ */
53
75
  reset() {
54
76
  __privateSet(this, _start, performance.now());
55
77
  __privateSet(this, _end, __privateGet(this, _start));
56
78
  return this;
57
79
  }
80
+ /**
81
+ * Starts the Stopwatch
82
+ */
58
83
  start() {
59
84
  if (!this.running) {
60
85
  __privateSet(this, _start, performance.now() - this.duration);
@@ -62,11 +87,17 @@ var Stopwatch = class {
62
87
  }
63
88
  return this;
64
89
  }
90
+ /**
91
+ * Stops the Stopwatch, freezing the duration
92
+ */
65
93
  stop() {
66
94
  if (this.running)
67
95
  __privateSet(this, _end, performance.now());
68
96
  return this;
69
97
  }
98
+ /**
99
+ * Defines toString behavior
100
+ */
70
101
  toString() {
71
102
  const time = this.duration;
72
103
  if (time >= 1e3)
@@ -81,4 +112,5 @@ _start = new WeakMap();
81
112
  _end = new WeakMap();
82
113
 
83
114
  exports.Stopwatch = Stopwatch;
115
+ //# sourceMappingURL=out.js.map
84
116
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAGO,IAAM,YAAN,MAAgB;AAAA,EAmBf,YAAY,SAAS,GAAG;AAf/B,wBAAO;AAKP;AAKA;AAMC,SAAK,SAAS;AACd,uBAAK,QAAS,YAAY,IAAI;AAC9B,uBAAK,MAAO;AAAA,EACb;AAAA,EAKA,IAAW,WAAmB;AAC7B,WAAO,mBAAK,QAAO,mBAAK,QAAO,mBAAK,UAAS,YAAY,IAAI,IAAI,mBAAK;AAAA,EACvE;AAAA,EAKA,IAAW,UAAmB;AAC7B,WAAO,QAAQ,CAAC,mBAAK,KAAI;AAAA,EAC1B;AAAA,EAKO,UAAgB;AACtB,uBAAK,QAAS,YAAY,IAAI;AAC9B,uBAAK,MAAO;AACZ,WAAO;AAAA,EACR;AAAA,EAKO,QAAc;AACpB,uBAAK,QAAS,YAAY,IAAI;AAC9B,uBAAK,MAAO,mBAAK;AACjB,WAAO;AAAA,EACR;AAAA,EAKO,QAAc;AACpB,QAAI,CAAC,KAAK,SAAS;AAClB,yBAAK,QAAS,YAAY,IAAI,IAAI,KAAK;AACvC,yBAAK,MAAO;AAAA,IACb;AAEA,WAAO;AAAA,EACR;AAAA,EAKO,OAAa;AACnB,QAAI,KAAK;AAAS,yBAAK,MAAO,YAAY,IAAI;AAC9C,WAAO;AAAA,EACR;AAAA,EAKO,WAAmB;AACzB,UAAM,OAAO,KAAK;AAClB,QAAI,QAAQ;AAAM,aAAO,IAAI,OAAO,KAAM,QAAQ,KAAK,MAAM;AAC7D,QAAI,QAAQ;AAAG,aAAO,GAAG,KAAK,QAAQ,KAAK,MAAM;AACjD,WAAO,IAAI,OAAO,KAAM,QAAQ,KAAK,MAAM;AAAA,EAC5C;AACD;AAtFa;AASZ;AAKA","sourcesContent":["/**\n * Stopwatch class, uses native node to replicate/extend performance-now dependency.\n */\nexport class Stopwatch {\n\t/**\n\t * The number of digits to appear after the decimal point when returning the friendly duration.\n\t */\n\tpublic digits: number;\n\n\t/**\n\t * The start time of this stopwatch\n\t */\n\t#start: number;\n\n\t/**\n\t * The end time of this stopwatch\n\t */\n\t#end: number | null;\n\n\t/**\n\t * Starts a new stopwatch\n\t */\n\tpublic constructor(digits = 2) {\n\t\tthis.digits = digits;\n\t\tthis.#start = performance.now();\n\t\tthis.#end = null;\n\t}\n\n\t/**\n\t * The duration of this stopwatch since start or start to end if this stopwatch has stopped.\n\t */\n\tpublic get duration(): number {\n\t\treturn this.#end ? this.#end - this.#start : performance.now() - this.#start;\n\t}\n\n\t/**\n\t * If the stopwatch is running or not.\n\t */\n\tpublic get running(): boolean {\n\t\treturn Boolean(!this.#end);\n\t}\n\n\t/**\n\t * Restarts the stopwatch (Returns a running state)\n\t */\n\tpublic restart(): this {\n\t\tthis.#start = performance.now();\n\t\tthis.#end = null;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Resets the Stopwatch to 0 duration (Returns a stopped state)\n\t */\n\tpublic reset(): this {\n\t\tthis.#start = performance.now();\n\t\tthis.#end = this.#start;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Starts the Stopwatch\n\t */\n\tpublic start(): this {\n\t\tif (!this.running) {\n\t\t\tthis.#start = performance.now() - this.duration;\n\t\t\tthis.#end = null;\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Stops the Stopwatch, freezing the duration\n\t */\n\tpublic stop(): this {\n\t\tif (this.running) this.#end = performance.now();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Defines toString behavior\n\t */\n\tpublic toString(): string {\n\t\tconst time = this.duration;\n\t\tif (time >= 1000) return `${(time / 1000).toFixed(this.digits)}s`;\n\t\tif (time >= 1) return `${time.toFixed(this.digits)}ms`;\n\t\treturn `${(time * 1000).toFixed(this.digits)}ΞΌs`;\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAGO,IAAM,YAAN,MAAgB;AAAA;AAAA;AAAA;AAAA,EAmBf,YAAY,SAAS,GAAG;AAf/B;AAAA;AAAA;AAAA,wBAAO;AAKP;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAMC,SAAK,SAAS;AACd,uBAAK,QAAS,YAAY,IAAI;AAC9B,uBAAK,MAAO;AAAA,EACb;AAAA;AAAA;AAAA;AAAA,EAKA,IAAW,WAAmB;AAC7B,WAAO,mBAAK,QAAO,mBAAK,QAAO,mBAAK,UAAS,YAAY,IAAI,IAAI,mBAAK;AAAA,EACvE;AAAA;AAAA;AAAA;AAAA,EAKA,IAAW,UAAmB;AAC7B,WAAO,QAAQ,CAAC,mBAAK,KAAI;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA,EAKO,UAAgB;AACtB,uBAAK,QAAS,YAAY,IAAI;AAC9B,uBAAK,MAAO;AACZ,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKO,QAAc;AACpB,uBAAK,QAAS,YAAY,IAAI;AAC9B,uBAAK,MAAO,mBAAK;AACjB,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKO,QAAc;AACpB,QAAI,CAAC,KAAK,SAAS;AAClB,yBAAK,QAAS,YAAY,IAAI,IAAI,KAAK;AACvC,yBAAK,MAAO;AAAA,IACb;AAEA,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKO,OAAa;AACnB,QAAI,KAAK;AAAS,yBAAK,MAAO,YAAY,IAAI;AAC9C,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKO,WAAmB;AACzB,UAAM,OAAO,KAAK;AAClB,QAAI,QAAQ;AAAM,aAAO,IAAI,OAAO,KAAM,QAAQ,KAAK,MAAM;AAC7D,QAAI,QAAQ;AAAG,aAAO,GAAG,KAAK,QAAQ,KAAK,MAAM;AACjD,WAAO,IAAI,OAAO,KAAM,QAAQ,KAAK,MAAM;AAAA,EAC5C;AACD;AAtFa;AASZ;AAKA","sourcesContent":["/**\n * Stopwatch class, uses native node to replicate/extend performance-now dependency.\n */\nexport class Stopwatch {\n\t/**\n\t * The number of digits to appear after the decimal point when returning the friendly duration.\n\t */\n\tpublic digits: number;\n\n\t/**\n\t * The start time of this stopwatch\n\t */\n\t#start: number;\n\n\t/**\n\t * The end time of this stopwatch\n\t */\n\t#end: number | null;\n\n\t/**\n\t * Starts a new stopwatch\n\t */\n\tpublic constructor(digits = 2) {\n\t\tthis.digits = digits;\n\t\tthis.#start = performance.now();\n\t\tthis.#end = null;\n\t}\n\n\t/**\n\t * The duration of this stopwatch since start or start to end if this stopwatch has stopped.\n\t */\n\tpublic get duration(): number {\n\t\treturn this.#end ? this.#end - this.#start : performance.now() - this.#start;\n\t}\n\n\t/**\n\t * If the stopwatch is running or not.\n\t */\n\tpublic get running(): boolean {\n\t\treturn Boolean(!this.#end);\n\t}\n\n\t/**\n\t * Restarts the stopwatch (Returns a running state)\n\t */\n\tpublic restart(): this {\n\t\tthis.#start = performance.now();\n\t\tthis.#end = null;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Resets the Stopwatch to 0 duration (Returns a stopped state)\n\t */\n\tpublic reset(): this {\n\t\tthis.#start = performance.now();\n\t\tthis.#end = this.#start;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Starts the Stopwatch\n\t */\n\tpublic start(): this {\n\t\tif (!this.running) {\n\t\t\tthis.#start = performance.now() - this.duration;\n\t\t\tthis.#end = null;\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Stops the Stopwatch, freezing the duration\n\t */\n\tpublic stop(): this {\n\t\tif (this.running) this.#end = performance.now();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Defines toString behavior\n\t */\n\tpublic toString(): string {\n\t\tconst time = this.duration;\n\t\tif (time >= 1000) return `${(time / 1000).toFixed(this.digits)}s`;\n\t\tif (time >= 1) return `${time.toFixed(this.digits)}ms`;\n\t\treturn `${(time * 1000).toFixed(this.digits)}ΞΌs`;\n\t}\n}\n"]}
package/dist/index.mjs CHANGED
@@ -27,30 +27,57 @@ var __privateSet = (obj, member, value, setter) => {
27
27
  // src/index.ts
28
28
  var _start, _end;
29
29
  var Stopwatch = class {
30
+ /**
31
+ * Starts a new stopwatch
32
+ */
30
33
  constructor(digits = 2) {
34
+ /**
35
+ * The number of digits to appear after the decimal point when returning the friendly duration.
36
+ */
31
37
  __publicField(this, "digits");
38
+ /**
39
+ * The start time of this stopwatch
40
+ */
32
41
  __privateAdd(this, _start, void 0);
42
+ /**
43
+ * The end time of this stopwatch
44
+ */
33
45
  __privateAdd(this, _end, void 0);
34
46
  this.digits = digits;
35
47
  __privateSet(this, _start, performance.now());
36
48
  __privateSet(this, _end, null);
37
49
  }
50
+ /**
51
+ * The duration of this stopwatch since start or start to end if this stopwatch has stopped.
52
+ */
38
53
  get duration() {
39
54
  return __privateGet(this, _end) ? __privateGet(this, _end) - __privateGet(this, _start) : performance.now() - __privateGet(this, _start);
40
55
  }
56
+ /**
57
+ * If the stopwatch is running or not.
58
+ */
41
59
  get running() {
42
60
  return Boolean(!__privateGet(this, _end));
43
61
  }
62
+ /**
63
+ * Restarts the stopwatch (Returns a running state)
64
+ */
44
65
  restart() {
45
66
  __privateSet(this, _start, performance.now());
46
67
  __privateSet(this, _end, null);
47
68
  return this;
48
69
  }
70
+ /**
71
+ * Resets the Stopwatch to 0 duration (Returns a stopped state)
72
+ */
49
73
  reset() {
50
74
  __privateSet(this, _start, performance.now());
51
75
  __privateSet(this, _end, __privateGet(this, _start));
52
76
  return this;
53
77
  }
78
+ /**
79
+ * Starts the Stopwatch
80
+ */
54
81
  start() {
55
82
  if (!this.running) {
56
83
  __privateSet(this, _start, performance.now() - this.duration);
@@ -58,11 +85,17 @@ var Stopwatch = class {
58
85
  }
59
86
  return this;
60
87
  }
88
+ /**
89
+ * Stops the Stopwatch, freezing the duration
90
+ */
61
91
  stop() {
62
92
  if (this.running)
63
93
  __privateSet(this, _end, performance.now());
64
94
  return this;
65
95
  }
96
+ /**
97
+ * Defines toString behavior
98
+ */
66
99
  toString() {
67
100
  const time = this.duration;
68
101
  if (time >= 1e3)
@@ -77,4 +110,5 @@ _start = new WeakMap();
77
110
  _end = new WeakMap();
78
111
 
79
112
  export { Stopwatch };
113
+ //# sourceMappingURL=out.js.map
80
114
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAGO,IAAM,YAAN,MAAgB;AAAA,EAmBf,YAAY,SAAS,GAAG;AAf/B,wBAAO;AAKP;AAKA;AAMC,SAAK,SAAS;AACd,uBAAK,QAAS,YAAY,IAAI;AAC9B,uBAAK,MAAO;AAAA,EACb;AAAA,EAKA,IAAW,WAAmB;AAC7B,WAAO,mBAAK,QAAO,mBAAK,QAAO,mBAAK,UAAS,YAAY,IAAI,IAAI,mBAAK;AAAA,EACvE;AAAA,EAKA,IAAW,UAAmB;AAC7B,WAAO,QAAQ,CAAC,mBAAK,KAAI;AAAA,EAC1B;AAAA,EAKO,UAAgB;AACtB,uBAAK,QAAS,YAAY,IAAI;AAC9B,uBAAK,MAAO;AACZ,WAAO;AAAA,EACR;AAAA,EAKO,QAAc;AACpB,uBAAK,QAAS,YAAY,IAAI;AAC9B,uBAAK,MAAO,mBAAK;AACjB,WAAO;AAAA,EACR;AAAA,EAKO,QAAc;AACpB,QAAI,CAAC,KAAK,SAAS;AAClB,yBAAK,QAAS,YAAY,IAAI,IAAI,KAAK;AACvC,yBAAK,MAAO;AAAA,IACb;AAEA,WAAO;AAAA,EACR;AAAA,EAKO,OAAa;AACnB,QAAI,KAAK;AAAS,yBAAK,MAAO,YAAY,IAAI;AAC9C,WAAO;AAAA,EACR;AAAA,EAKO,WAAmB;AACzB,UAAM,OAAO,KAAK;AAClB,QAAI,QAAQ;AAAM,aAAO,IAAI,OAAO,KAAM,QAAQ,KAAK,MAAM;AAC7D,QAAI,QAAQ;AAAG,aAAO,GAAG,KAAK,QAAQ,KAAK,MAAM;AACjD,WAAO,IAAI,OAAO,KAAM,QAAQ,KAAK,MAAM;AAAA,EAC5C;AACD;AAtFa;AASZ;AAKA","sourcesContent":["/**\n * Stopwatch class, uses native node to replicate/extend performance-now dependency.\n */\nexport class Stopwatch {\n\t/**\n\t * The number of digits to appear after the decimal point when returning the friendly duration.\n\t */\n\tpublic digits: number;\n\n\t/**\n\t * The start time of this stopwatch\n\t */\n\t#start: number;\n\n\t/**\n\t * The end time of this stopwatch\n\t */\n\t#end: number | null;\n\n\t/**\n\t * Starts a new stopwatch\n\t */\n\tpublic constructor(digits = 2) {\n\t\tthis.digits = digits;\n\t\tthis.#start = performance.now();\n\t\tthis.#end = null;\n\t}\n\n\t/**\n\t * The duration of this stopwatch since start or start to end if this stopwatch has stopped.\n\t */\n\tpublic get duration(): number {\n\t\treturn this.#end ? this.#end - this.#start : performance.now() - this.#start;\n\t}\n\n\t/**\n\t * If the stopwatch is running or not.\n\t */\n\tpublic get running(): boolean {\n\t\treturn Boolean(!this.#end);\n\t}\n\n\t/**\n\t * Restarts the stopwatch (Returns a running state)\n\t */\n\tpublic restart(): this {\n\t\tthis.#start = performance.now();\n\t\tthis.#end = null;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Resets the Stopwatch to 0 duration (Returns a stopped state)\n\t */\n\tpublic reset(): this {\n\t\tthis.#start = performance.now();\n\t\tthis.#end = this.#start;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Starts the Stopwatch\n\t */\n\tpublic start(): this {\n\t\tif (!this.running) {\n\t\t\tthis.#start = performance.now() - this.duration;\n\t\t\tthis.#end = null;\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Stops the Stopwatch, freezing the duration\n\t */\n\tpublic stop(): this {\n\t\tif (this.running) this.#end = performance.now();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Defines toString behavior\n\t */\n\tpublic toString(): string {\n\t\tconst time = this.duration;\n\t\tif (time >= 1000) return `${(time / 1000).toFixed(this.digits)}s`;\n\t\tif (time >= 1) return `${time.toFixed(this.digits)}ms`;\n\t\treturn `${(time * 1000).toFixed(this.digits)}ΞΌs`;\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAGO,IAAM,YAAN,MAAgB;AAAA;AAAA;AAAA;AAAA,EAmBf,YAAY,SAAS,GAAG;AAf/B;AAAA;AAAA;AAAA,wBAAO;AAKP;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAMC,SAAK,SAAS;AACd,uBAAK,QAAS,YAAY,IAAI;AAC9B,uBAAK,MAAO;AAAA,EACb;AAAA;AAAA;AAAA;AAAA,EAKA,IAAW,WAAmB;AAC7B,WAAO,mBAAK,QAAO,mBAAK,QAAO,mBAAK,UAAS,YAAY,IAAI,IAAI,mBAAK;AAAA,EACvE;AAAA;AAAA;AAAA;AAAA,EAKA,IAAW,UAAmB;AAC7B,WAAO,QAAQ,CAAC,mBAAK,KAAI;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA,EAKO,UAAgB;AACtB,uBAAK,QAAS,YAAY,IAAI;AAC9B,uBAAK,MAAO;AACZ,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKO,QAAc;AACpB,uBAAK,QAAS,YAAY,IAAI;AAC9B,uBAAK,MAAO,mBAAK;AACjB,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKO,QAAc;AACpB,QAAI,CAAC,KAAK,SAAS;AAClB,yBAAK,QAAS,YAAY,IAAI,IAAI,KAAK;AACvC,yBAAK,MAAO;AAAA,IACb;AAEA,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKO,OAAa;AACnB,QAAI,KAAK;AAAS,yBAAK,MAAO,YAAY,IAAI;AAC9C,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAKO,WAAmB;AACzB,UAAM,OAAO,KAAK;AAClB,QAAI,QAAQ;AAAM,aAAO,IAAI,OAAO,KAAM,QAAQ,KAAK,MAAM;AAC7D,QAAI,QAAQ;AAAG,aAAO,GAAG,KAAK,QAAQ,KAAK,MAAM;AACjD,WAAO,IAAI,OAAO,KAAM,QAAQ,KAAK,MAAM;AAAA,EAC5C;AACD;AAtFa;AASZ;AAKA","sourcesContent":["/**\n * Stopwatch class, uses native node to replicate/extend performance-now dependency.\n */\nexport class Stopwatch {\n\t/**\n\t * The number of digits to appear after the decimal point when returning the friendly duration.\n\t */\n\tpublic digits: number;\n\n\t/**\n\t * The start time of this stopwatch\n\t */\n\t#start: number;\n\n\t/**\n\t * The end time of this stopwatch\n\t */\n\t#end: number | null;\n\n\t/**\n\t * Starts a new stopwatch\n\t */\n\tpublic constructor(digits = 2) {\n\t\tthis.digits = digits;\n\t\tthis.#start = performance.now();\n\t\tthis.#end = null;\n\t}\n\n\t/**\n\t * The duration of this stopwatch since start or start to end if this stopwatch has stopped.\n\t */\n\tpublic get duration(): number {\n\t\treturn this.#end ? this.#end - this.#start : performance.now() - this.#start;\n\t}\n\n\t/**\n\t * If the stopwatch is running or not.\n\t */\n\tpublic get running(): boolean {\n\t\treturn Boolean(!this.#end);\n\t}\n\n\t/**\n\t * Restarts the stopwatch (Returns a running state)\n\t */\n\tpublic restart(): this {\n\t\tthis.#start = performance.now();\n\t\tthis.#end = null;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Resets the Stopwatch to 0 duration (Returns a stopped state)\n\t */\n\tpublic reset(): this {\n\t\tthis.#start = performance.now();\n\t\tthis.#end = this.#start;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Starts the Stopwatch\n\t */\n\tpublic start(): this {\n\t\tif (!this.running) {\n\t\t\tthis.#start = performance.now() - this.duration;\n\t\t\tthis.#end = null;\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Stops the Stopwatch, freezing the duration\n\t */\n\tpublic stop(): this {\n\t\tif (this.running) this.#end = performance.now();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Defines toString behavior\n\t */\n\tpublic toString(): string {\n\t\tconst time = this.duration;\n\t\tif (time >= 1000) return `${(time / 1000).toFixed(this.digits)}s`;\n\t\tif (time >= 1) return `${time.toFixed(this.digits)}ms`;\n\t\treturn `${(time * 1000).toFixed(this.digits)}ΞΌs`;\n\t}\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sapphire/stopwatch",
3
- "version": "1.5.0",
3
+ "version": "1.5.1-next.006b002f.0",
4
4
  "description": "Accurately measure passing time.",
5
5
  "author": "@sapphire",
6
6
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  "check-update": "cliff-jumper --dry-run"
25
25
  },
26
26
  "dependencies": {
27
- "tslib": "^2.4.0"
27
+ "tslib": "^2.5.0"
28
28
  },
29
29
  "repository": {
30
30
  "type": "git",
@@ -57,14 +57,14 @@
57
57
  "access": "public"
58
58
  },
59
59
  "devDependencies": {
60
- "@favware/cliff-jumper": "^1.8.7",
61
- "@types/jsdom": "^20.0.0",
62
- "@vitest/coverage-c8": "^0.23.4",
63
- "jsdom": "^20.0.1",
64
- "tsup": "^6.2.3",
65
- "typedoc": "^0.23.15",
66
- "typedoc-json-parser": "^5.0.1",
67
- "typescript": "^4.8.4",
68
- "vitest": "^0.23.4"
60
+ "@favware/cliff-jumper": "^2.0.0",
61
+ "@types/jsdom": "^21.1.1",
62
+ "@vitest/coverage-c8": "^0.29.8",
63
+ "jsdom": "^21.1.1",
64
+ "tsup": "^6.7.0",
65
+ "typedoc": "0.23.28",
66
+ "typedoc-json-parser": "^7.2.0",
67
+ "typescript": "^5.0.3",
68
+ "vitest": "^0.29.8"
69
69
  }
70
70
  }