@sapphire/stopwatch 1.6.0-pr-589.aa473f9.0 → 1.6.0-pr-935.7da5c8bb

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/CHANGELOG.md CHANGED
@@ -2,6 +2,52 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ # [@sapphire/stopwatch@1.5.3](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.5.2...@sapphire/stopwatch@1.5.3) - (2024-11-02)
6
+
7
+ ## 🐛 Bug Fixes
8
+
9
+ - Move browser imports ([100ffb0](https://github.com/sapphiredev/utilities/commit/100ffb0a2471bb9f74cc580d282d11059e1a0a68)) ([#826](https://github.com/sapphiredev/utilities/pull/826) by @kyranet)
10
+ - **deps:** Update all non-major dependencies ([083376a](https://github.com/sapphiredev/utilities/commit/083376aac55094dbeddb5194e8a8f0d794b8cceb)) ([#763](https://github.com/sapphiredev/utilities/pull/763) by @renovate[bot])
11
+ - **deps:** Update all non-major dependencies ([e7fdc5d](https://github.com/sapphiredev/utilities/commit/e7fdc5db3632a7f90292ef3978898da32730343a)) ([#752](https://github.com/sapphiredev/utilities/pull/752) by @renovate[bot])
12
+
13
+ ## 📝 Documentation
14
+
15
+ - **readme:** Fix readme table of contents ([c60e8bd](https://github.com/sapphiredev/utilities/commit/c60e8bd9fc89156cf973871597ec3f0ef0308c08))
16
+
17
+ # [@sapphire/stopwatch@1.5.2](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.5.2...@sapphire/stopwatch@1.5.2) - (2024-01-19)
18
+
19
+ ## 🐛 Bug Fixes
20
+
21
+ - Fixed commonjs typings export mapping (#707) ([216ff02](https://github.com/sapphiredev/utilities/commit/216ff0260d63a9590357f9a5069f1ae2b34eaf5d))
22
+
23
+ # [@sapphire/stopwatch@1.5.1](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.5.1...@sapphire/stopwatch@1.5.1) - (2023-12-04)
24
+
25
+ ## 🐛 Bug Fixes
26
+
27
+ - **stopwatch:** Properly split CJS, ESM and IIFE ([efb156a](https://github.com/sapphiredev/utilities/commit/efb156a9d578760d6c52645604bcc7cd4aa93bdb))
28
+ - Update export mapping for proper ESM/CJS split ([dd0cff8](https://github.com/sapphiredev/utilities/commit/dd0cff8e9b03a15812f25f7a1180501a92422629))
29
+ - **deps:** Update all non-major dependencies (#607) ([9cc8bd0](https://github.com/sapphiredev/utilities/commit/9cc8bd0d4b5d650deab2c913e6c3d713861bae28))
30
+ - **deps:** Update all non-major dependencies (#577) ([291dd67](https://github.com/sapphiredev/utilities/commit/291dd6783e57d8f075ce566218ba076ef6c4bbbd))
31
+ - **deps:** Update all non-major dependencies (#545) ([40ca040](https://github.com/sapphiredev/utilities/commit/40ca040a21d8a0949682051a3a974538183a400e))
32
+ - **deps:** Update all non-major dependencies (#544) ([cc78f17](https://github.com/sapphiredev/utilities/commit/cc78f17390c7f3db08af92bf46a5a70a9c11dd5f))
33
+ - **deps:** Update all non-major dependencies (#532) ([8033d1f](https://github.com/sapphiredev/utilities/commit/8033d1ff7a5a1974134c61f424f171cccb2915e1))
34
+ - **deps:** Update all non-major dependencies (#514) ([21b07d5](https://github.com/sapphiredev/utilities/commit/21b07d5db529a0d982647a60de98e46f36f1ac93))
35
+ - **deps:** Update all non-major dependencies (#505) ([6178296](https://github.com/sapphiredev/utilities/commit/617829649e1e4deeee02b14533b5377cd5bc1fb3))
36
+
37
+ ## 📝 Documentation
38
+
39
+ - Add @06000208 as a contributor ([fa3349e](https://github.com/sapphiredev/utilities/commit/fa3349e55ce4ad008785211dec7bf8e2b5d933df))
40
+ - Add @didinele as a contributor ([42ef7b6](https://github.com/sapphiredev/utilities/commit/42ef7b656c48fd0e720119db1d622c8bba2791e9))
41
+ - Add @goestav as a contributor ([0e56a92](https://github.com/sapphiredev/utilities/commit/0e56a92a4e2d0942bfa207f81a8cb03b32312034))
42
+ - Add @CitTheDev as a contributor ([34169ea](https://github.com/sapphiredev/utilities/commit/34169eae1dc0476ccf5a6c4f36e28602a204829e))
43
+ - Add @legendhimslef as a contributor ([059b6f1](https://github.com/sapphiredev/utilities/commit/059b6f1ab5362d46d58624d06c1aa39192b0716f))
44
+ - Add @r-priyam as a contributor ([fb278ba](https://github.com/sapphiredev/utilities/commit/fb278bacf627ec6fc88752eafeb12df5f3177a2c))
45
+
46
+ ## 🧪 Testing
47
+
48
+ - Update vitest to coverage v8 ([a4bc6e4](https://github.com/sapphiredev/utilities/commit/a4bc6e4f24ea60143a150ecc76fda6484f172ab9))
49
+ - Cleanup tests ([aec1bb2](https://github.com/sapphiredev/utilities/commit/aec1bb290d0f3c00a1ae4f4c86302ebbb161d348))
50
+
5
51
  # [@sapphire/stopwatch@1.5.0](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.4.1...@sapphire/stopwatch@1.5.0) - (2022-10-02)
6
52
 
7
53
  ## 🏠 Refactor
package/README.md CHANGED
@@ -7,7 +7,6 @@
7
7
  **Accurately measure passing time**
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/stopwatch?logo=webpack&style=flat-square)](https://bundlephobia.com/result?p=@sapphire/stopwatch)
12
11
  [![npm](https://img.shields.io/npm/v/@sapphire/stopwatch?color=crimson&logo=npm&style=flat-square)](https://www.npmjs.com/package/@sapphire/stopwatch)
13
12
 
@@ -15,14 +14,13 @@
15
14
 
16
15
  **Table of Contents**
17
16
 
18
- - [@sapphire/stopwatch](#sapphirestopwatch)
19
- - [Description](#description)
20
- - [Features](#features)
21
- - [Installation](#installation)
22
- - [Usage](#usage)
23
- - [Basic Usage](#basic-usage)
24
- - [Buy us some doughnuts](#buy-us-some-doughnuts)
25
- - [Contributors ✨](#contributors-)
17
+ - [Description](#description)
18
+ - [Features](#features)
19
+ - [Installation](#installation)
20
+ - [Usage](#usage)
21
+ - [Basic Usage](#basic-usage)
22
+ - [Buy us some doughnuts](#buy-us-some-doughnuts)
23
+ - [Contributors](#contributors)
26
24
 
27
25
  ## Description
28
26
 
@@ -1,34 +1,20 @@
1
1
  'use strict';
2
2
 
3
3
  var __defProp = Object.defineProperty;
4
+ var __typeError = (msg) => {
5
+ throw TypeError(msg);
6
+ };
4
7
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5
8
  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
- };
10
- var __accessCheck = (obj, member, msg) => {
11
- if (!member.has(obj))
12
- throw TypeError("Cannot " + msg);
13
- };
14
- var __privateGet = (obj, member, getter) => {
15
- __accessCheck(obj, member, "read from private field");
16
- return getter ? getter.call(obj) : member.get(obj);
17
- };
18
- var __privateAdd = (obj, member, value) => {
19
- if (member.has(obj))
20
- throw TypeError("Cannot add the same private member more than once");
21
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
22
- };
23
- var __privateSet = (obj, member, value, setter) => {
24
- __accessCheck(obj, member, "write to private field");
25
- setter ? setter.call(obj, value) : member.set(obj, value);
26
- return value;
27
- };
9
+ var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
10
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
11
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
12
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
13
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
28
14
 
29
15
  // src/index.ts
30
16
  var _start, _end;
31
- var Stopwatch = class {
17
+ var _Stopwatch = class _Stopwatch {
32
18
  /**
33
19
  * Starts a new stopwatch
34
20
  */
@@ -40,11 +26,11 @@ var Stopwatch = class {
40
26
  /**
41
27
  * The start time of this stopwatch
42
28
  */
43
- __privateAdd(this, _start, void 0);
29
+ __privateAdd(this, _start);
44
30
  /**
45
31
  * The end time of this stopwatch
46
32
  */
47
- __privateAdd(this, _end, void 0);
33
+ __privateAdd(this, _end);
48
34
  this.digits = digits;
49
35
  __privateSet(this, _start, performance.now());
50
36
  __privateSet(this, _end, null);
@@ -91,8 +77,7 @@ var Stopwatch = class {
91
77
  * Stops the Stopwatch, freezing the duration
92
78
  */
93
79
  stop() {
94
- if (this.running)
95
- __privateSet(this, _end, performance.now());
80
+ if (this.running) __privateSet(this, _end, performance.now());
96
81
  return this;
97
82
  }
98
83
  /**
@@ -100,17 +85,16 @@ var Stopwatch = class {
100
85
  */
101
86
  toString() {
102
87
  const time = this.duration;
103
- if (time >= 1e3)
104
- return `${(time / 1e3).toFixed(this.digits)}s`;
105
- if (time >= 1)
106
- return `${time.toFixed(this.digits)}ms`;
88
+ if (time >= 1e3) return `${(time / 1e3).toFixed(this.digits)}s`;
89
+ if (time >= 1) return `${time.toFixed(this.digits)}ms`;
107
90
  return `${(time * 1e3).toFixed(this.digits)}\u03BCs`;
108
91
  }
109
92
  };
110
- __name(Stopwatch, "Stopwatch");
111
93
  _start = new WeakMap();
112
94
  _end = new WeakMap();
95
+ __name(_Stopwatch, "Stopwatch");
96
+ var Stopwatch = _Stopwatch;
113
97
 
114
98
  exports.Stopwatch = Stopwatch;
115
- //# sourceMappingURL=out.js.map
116
- //# sourceMappingURL=index.js.map
99
+ //# sourceMappingURL=index.cjs.map
100
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;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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"]}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Stopwatch class, uses native node to replicate/extend performance-now dependency.
3
+ */
4
+ declare class Stopwatch {
5
+ #private;
6
+ /**
7
+ * The number of digits to appear after the decimal point when returning the friendly duration.
8
+ */
9
+ digits: number;
10
+ /**
11
+ * Starts a new stopwatch
12
+ */
13
+ constructor(digits?: number);
14
+ /**
15
+ * The duration of this stopwatch since start or start to end if this stopwatch has stopped.
16
+ */
17
+ get duration(): number;
18
+ /**
19
+ * If the stopwatch is running or not.
20
+ */
21
+ get running(): boolean;
22
+ /**
23
+ * Restarts the stopwatch (Returns a running state)
24
+ */
25
+ restart(): this;
26
+ /**
27
+ * Resets the Stopwatch to 0 duration (Returns a stopped state)
28
+ */
29
+ reset(): this;
30
+ /**
31
+ * Starts the Stopwatch
32
+ */
33
+ start(): this;
34
+ /**
35
+ * Stops the Stopwatch, freezing the duration
36
+ */
37
+ stop(): this;
38
+ /**
39
+ * Defines toString behavior
40
+ */
41
+ toString(): string;
42
+ }
43
+
44
+ export { Stopwatch };
@@ -1,32 +1,18 @@
1
1
  var __defProp = Object.defineProperty;
2
+ var __typeError = (msg) => {
3
+ throw TypeError(msg);
4
+ };
2
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
6
  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
- };
8
- var __accessCheck = (obj, member, msg) => {
9
- if (!member.has(obj))
10
- throw TypeError("Cannot " + msg);
11
- };
12
- var __privateGet = (obj, member, getter) => {
13
- __accessCheck(obj, member, "read from private field");
14
- return getter ? getter.call(obj) : member.get(obj);
15
- };
16
- var __privateAdd = (obj, member, value) => {
17
- if (member.has(obj))
18
- throw TypeError("Cannot add the same private member more than once");
19
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
20
- };
21
- var __privateSet = (obj, member, value, setter) => {
22
- __accessCheck(obj, member, "write to private field");
23
- setter ? setter.call(obj, value) : member.set(obj, value);
24
- return value;
25
- };
7
+ var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
8
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
9
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
10
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
11
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
26
12
 
27
13
  // src/index.ts
28
14
  var _start, _end;
29
- var Stopwatch = class {
15
+ var _Stopwatch = class _Stopwatch {
30
16
  /**
31
17
  * Starts a new stopwatch
32
18
  */
@@ -38,11 +24,11 @@ var Stopwatch = class {
38
24
  /**
39
25
  * The start time of this stopwatch
40
26
  */
41
- __privateAdd(this, _start, void 0);
27
+ __privateAdd(this, _start);
42
28
  /**
43
29
  * The end time of this stopwatch
44
30
  */
45
- __privateAdd(this, _end, void 0);
31
+ __privateAdd(this, _end);
46
32
  this.digits = digits;
47
33
  __privateSet(this, _start, performance.now());
48
34
  __privateSet(this, _end, null);
@@ -89,8 +75,7 @@ var Stopwatch = class {
89
75
  * Stops the Stopwatch, freezing the duration
90
76
  */
91
77
  stop() {
92
- if (this.running)
93
- __privateSet(this, _end, performance.now());
78
+ if (this.running) __privateSet(this, _end, performance.now());
94
79
  return this;
95
80
  }
96
81
  /**
@@ -98,17 +83,16 @@ var Stopwatch = class {
98
83
  */
99
84
  toString() {
100
85
  const time = this.duration;
101
- if (time >= 1e3)
102
- return `${(time / 1e3).toFixed(this.digits)}s`;
103
- if (time >= 1)
104
- return `${time.toFixed(this.digits)}ms`;
86
+ if (time >= 1e3) return `${(time / 1e3).toFixed(this.digits)}s`;
87
+ if (time >= 1) return `${time.toFixed(this.digits)}ms`;
105
88
  return `${(time * 1e3).toFixed(this.digits)}\u03BCs`;
106
89
  }
107
90
  };
108
- __name(Stopwatch, "Stopwatch");
109
91
  _start = new WeakMap();
110
92
  _end = new WeakMap();
93
+ __name(_Stopwatch, "Stopwatch");
94
+ var Stopwatch = _Stopwatch;
111
95
 
112
96
  export { Stopwatch };
113
- //# sourceMappingURL=out.js.map
97
+ //# sourceMappingURL=index.mjs.map
114
98
  //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,IAAA,MAAA,EAAA,IAAA;AAGO,IAAM,UAAA,GAAN,MAAM,UAAA,CAAU;AAAA;AAAA;AAAA;AAAA,EAmBf,WAAA,CAAY,SAAS,CAAA,EAAG;AAf/B;AAAA;AAAA;AAAA,IAAA,aAAA,CAAA,IAAA,EAAO,QAAA,CAAA;AAKP;AAAA;AAAA;AAAA,IAAA,YAAA,CAAA,IAAA,EAAA,MAAA,CAAA;AAKA;AAAA;AAAA;AAAA,IAAA,YAAA,CAAA,IAAA,EAAA,IAAA,CAAA;AAMC,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,YAAA,CAAA,IAAA,EAAK,MAAA,EAAS,YAAY,GAAA,EAAI,CAAA;AAC9B,IAAA,YAAA,CAAA,IAAA,EAAK,IAAA,EAAO,IAAA,CAAA;AAAA,EACb;AAAA;AAAA;AAAA;AAAA,EAKA,IAAW,QAAA,GAAmB;AAC7B,IAAA,OAAO,YAAA,CAAA,IAAA,EAAK,QAAO,YAAA,CAAA,IAAA,EAAK,IAAA,CAAA,GAAO,mBAAK,MAAA,CAAA,GAAS,WAAA,CAAY,GAAA,EAAI,GAAI,YAAA,CAAA,IAAA,EAAK,MAAA,CAAA;AAAA,EACvE;AAAA;AAAA;AAAA;AAAA,EAKA,IAAW,OAAA,GAAmB;AAC7B,IAAA,OAAO,OAAA,CAAQ,CAAC,YAAA,CAAA,IA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AAG,KAAK,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA,EAAA,CAAA;AAClD,IAAA,OAAO,IAAI,IAAA,GAAO,GAAA,EAAM,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA,OAAA,CAAA;AAAA,EAC7C;AACD,CAAA;AA7EC,MAAA,GAAA,IAAA,OAAA,EAAA;AAKA,IAAA,GAAA,IAAA,OAAA,EAAA;AAdsB,MAAA,CAAA,UAAA,EAAA,WAAA,CAAA;AAAhB,IAAM,SAAA,GAAN","file":"index.mjs","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"]}
@@ -2,34 +2,20 @@ var SapphireStopwatch = (function (exports) {
2
2
  'use strict';
3
3
 
4
4
  var __defProp = Object.defineProperty;
5
+ var __typeError = (msg) => {
6
+ throw TypeError(msg);
7
+ };
5
8
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
9
  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
- };
11
- var __accessCheck = (obj, member, msg) => {
12
- if (!member.has(obj))
13
- throw TypeError("Cannot " + msg);
14
- };
15
- var __privateGet = (obj, member, getter) => {
16
- __accessCheck(obj, member, "read from private field");
17
- return getter ? getter.call(obj) : member.get(obj);
18
- };
19
- var __privateAdd = (obj, member, value) => {
20
- if (member.has(obj))
21
- throw TypeError("Cannot add the same private member more than once");
22
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
23
- };
24
- var __privateSet = (obj, member, value, setter) => {
25
- __accessCheck(obj, member, "write to private field");
26
- setter ? setter.call(obj, value) : member.set(obj, value);
27
- return value;
28
- };
10
+ var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
11
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
12
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
13
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
14
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
29
15
 
30
16
  // src/index.ts
31
17
  var _start, _end;
32
- var Stopwatch = class {
18
+ var _Stopwatch = class _Stopwatch {
33
19
  /**
34
20
  * Starts a new stopwatch
35
21
  */
@@ -41,11 +27,11 @@ var SapphireStopwatch = (function (exports) {
41
27
  /**
42
28
  * The start time of this stopwatch
43
29
  */
44
- __privateAdd(this, _start, void 0);
30
+ __privateAdd(this, _start);
45
31
  /**
46
32
  * The end time of this stopwatch
47
33
  */
48
- __privateAdd(this, _end, void 0);
34
+ __privateAdd(this, _end);
49
35
  this.digits = digits;
50
36
  __privateSet(this, _start, performance.now());
51
37
  __privateSet(this, _end, null);
@@ -92,8 +78,7 @@ var SapphireStopwatch = (function (exports) {
92
78
  * Stops the Stopwatch, freezing the duration
93
79
  */
94
80
  stop() {
95
- if (this.running)
96
- __privateSet(this, _end, performance.now());
81
+ if (this.running) __privateSet(this, _end, performance.now());
97
82
  return this;
98
83
  }
99
84
  /**
@@ -101,21 +86,20 @@ var SapphireStopwatch = (function (exports) {
101
86
  */
102
87
  toString() {
103
88
  const time = this.duration;
104
- if (time >= 1e3)
105
- return `${(time / 1e3).toFixed(this.digits)}s`;
106
- if (time >= 1)
107
- return `${time.toFixed(this.digits)}ms`;
89
+ if (time >= 1e3) return `${(time / 1e3).toFixed(this.digits)}s`;
90
+ if (time >= 1) return `${time.toFixed(this.digits)}ms`;
108
91
  return `${(time * 1e3).toFixed(this.digits)}\u03BCs`;
109
92
  }
110
93
  };
111
- __name(Stopwatch, "Stopwatch");
112
94
  _start = new WeakMap();
113
95
  _end = new WeakMap();
96
+ __name(_Stopwatch, "Stopwatch");
97
+ var Stopwatch = _Stopwatch;
114
98
 
115
99
  exports.Stopwatch = Stopwatch;
116
100
 
117
101
  return exports;
118
102
 
119
103
  })({});
120
- //# sourceMappingURL=out.js.map
104
+ //# sourceMappingURL=index.global.js.map
121
105
  //# sourceMappingURL=index.global.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;EAAA,IAAA,MAAA,EAAA,IAAA;EAGO,IAAM,UAAA,GAAN,MAAM,UAAA,CAAU;EAAA;EAAA;EAAA;EAAA,EAmBf,WAAA,CAAY,SAAS,CAAA,EAAG;EAf/B;EAAA;EAAA;EAAA,IAAA,aAAA,CAAA,IAAA,EAAO,QAAA,CAAA;EAKP;EAAA;EAAA;EAAA,IAAA,YAAA,CAAA,IAAA,EAAA,MAAA,CAAA;EAKA;EAAA;EAAA;EAAA,IAAA,YAAA,CAAA,IAAA,EAAA,IAAA,CAAA;EAMC,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;EACd,IAAA,YAAA,CAAA,IAAA,EAAK,MAAA,EAAS,YAAY,GAAA,EAAI,CAAA;EAC9B,IAAA,YAAA,CAAA,IAAA,EAAK,IAAA,EAAO,IAAA,CAAA;EAAA,EACb;EAAA;EAAA;EAAA;EAAA,EAKA,IAAW,QAAA,GAAmB;EAC7B,IAAA,OAAO,YAAA,CAAA,IAAA,EAAK,QAAO,YAAA,CAAA,IAAA,EAAK,IAAA,CAAA,GAAO,mBAAK,MAAA,CAAA,GAAS,WAAA,CAAY,GAAA,EAAI,GAAI,YAAA,CAAA,IAAA,EAAK,MAAA,CAAA;EAAA,EACvE;EAAA;EAAA;EAAA;EAAA,EAKA,IAAW,OAAA,GAAmB;EAC7B,IAAA,OAAO,OAAA,CAAQ,CAAC,YAAA,CAAA,IAAA,EAAK,IAAA,CAAI,CAAA;EAAA,EAC1B;EAAA;EAAA;EAAA;EAAA,EAKO,OAAA,GAAgB;EACtB,IAAA,YAAA,CAAA,IAAA,EAAK,MAAA,EAAS,YAAY,GAAA,EAAI,CAAA;EAC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AA,CAAA;EAAA,EAC7C;EACD,CAAA;EA7EC,MAAA,GAAA,IAAA,OAAA,EAAA;EAKA,IAAA,GAAA,IAAA,OAAA,EAAA;EAdsB,MAAA,CAAA,UAAA,EAAA,WAAA,CAAA;AAAhB,MAAM,SAAA,GAAN","file":"index.global.js","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,30 +1,39 @@
1
1
  {
2
2
  "name": "@sapphire/stopwatch",
3
- "version": "1.6.0-pr-589.aa473f9.0",
3
+ "version": "1.6.0-pr-935.7da5c8bb",
4
4
  "description": "Accurately measure passing time.",
5
5
  "author": "@sapphire",
6
6
  "license": "MIT",
7
- "main": "dist/index.js",
8
- "module": "dist/index.mjs",
9
- "types": "dist/index.d.ts",
7
+ "main": "dist/cjs/index.cjs",
8
+ "module": "dist/esm/index.mjs",
9
+ "browser": "dist/iife/index.global.js",
10
+ "unpkg": "dist/iife/index.global.js",
11
+ "types": "dist/cjs/index.d.cts",
10
12
  "exports": {
11
- "import": "./dist/index.mjs",
12
- "require": "./dist/index.js",
13
- "types": "./dist/index.d.ts"
13
+ "import": {
14
+ "types": "./dist/esm/index.d.mts",
15
+ "default": "./dist/esm/index.mjs"
16
+ },
17
+ "require": {
18
+ "types": "./dist/cjs/index.d.cts",
19
+ "default": "./dist/cjs/index.cjs"
20
+ },
21
+ "browser": "./dist/iife/index.global.js"
14
22
  },
15
23
  "sideEffects": false,
16
24
  "homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/stopwatch",
17
25
  "scripts": {
18
26
  "test": "vitest run",
19
27
  "lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
20
- "build": "tsup",
28
+ "build": "tsup && yarn build:rename-cjs-index",
29
+ "build:rename-cjs-index": "tsx ../../scripts/rename-cjs-index.cts",
21
30
  "docs": "typedoc-json-parser",
22
31
  "prepack": "yarn build",
23
32
  "bump": "cliff-jumper",
24
33
  "check-update": "cliff-jumper --dry-run"
25
34
  },
26
35
  "dependencies": {
27
- "tslib": "^2.5.0"
36
+ "tslib": "^2.8.1"
28
37
  },
29
38
  "repository": {
30
39
  "type": "git",
@@ -32,9 +41,7 @@
32
41
  "directory": "packages/stopwatch"
33
42
  },
34
43
  "files": [
35
- "dist/**/*.js*",
36
- "dist/**/*.mjs*",
37
- "dist/**/*.d*"
44
+ "dist/"
38
45
  ],
39
46
  "engines": {
40
47
  "node": ">=v14.0.0",
@@ -57,14 +64,15 @@
57
64
  "access": "public"
58
65
  },
59
66
  "devDependencies": {
60
- "@favware/cliff-jumper": "^2.0.0",
61
- "@types/jsdom": "^21.1.1",
62
- "@vitest/coverage-c8": "^0.30.1",
63
- "jsdom": "^22.0.0",
64
- "tsup": "^6.7.0",
65
- "typedoc": "^0.24.6",
66
- "typedoc-json-parser": "^7.3.2",
67
- "typescript": "^5.0.4",
68
- "vitest": "^0.30.1"
67
+ "@favware/cliff-jumper": "^6.0.0",
68
+ "@types/jsdom": "^27.0.0",
69
+ "@vitest/coverage-v8": "^3.2.4",
70
+ "jsdom": "^27.1.0",
71
+ "tsup": "^8.5.0",
72
+ "tsx": "^4.20.6",
73
+ "typedoc": "^0.26.11",
74
+ "typedoc-json-parser": "^10.2.0",
75
+ "typescript": "~5.4.5",
76
+ "vitest": "^3.2.4"
69
77
  }
70
78
  }
@@ -1 +0,0 @@
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.map DELETED
@@ -1 +0,0 @@
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"]}
@@ -1 +0,0 @@
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"]}
File without changes