@sapphire/stopwatch 1.2.5 → 1.3.0-next.365a53a.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 +4 -0
- package/dist/index.js +107 -93
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -3
- package/dist/index.mjs.map +1 -0
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -113,6 +113,10 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
113
113
|
<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>
|
|
114
114
|
<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>
|
|
115
115
|
<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>
|
|
116
|
+
<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>
|
|
117
|
+
<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>
|
|
118
|
+
<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>
|
|
119
|
+
<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>
|
|
116
120
|
</tr>
|
|
117
121
|
</table>
|
|
118
122
|
|
package/dist/index.js
CHANGED
|
@@ -1,96 +1,110 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
14
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(module2))
|
|
16
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
17
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return target;
|
|
20
|
+
};
|
|
21
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
22
|
+
return (module2, temp) => {
|
|
23
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
24
|
+
};
|
|
25
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
26
|
+
var __publicField = (obj, key, value) => {
|
|
27
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
28
|
+
return value;
|
|
29
|
+
};
|
|
30
|
+
var __accessCheck = (obj, member, msg) => {
|
|
31
|
+
if (!member.has(obj))
|
|
32
|
+
throw TypeError("Cannot " + msg);
|
|
33
|
+
};
|
|
34
|
+
var __privateGet = (obj, member, getter) => {
|
|
35
|
+
__accessCheck(obj, member, "read from private field");
|
|
36
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
37
|
+
};
|
|
38
|
+
var __privateAdd = (obj, member, value) => {
|
|
39
|
+
if (member.has(obj))
|
|
40
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
41
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
42
|
+
};
|
|
43
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
44
|
+
__accessCheck(obj, member, "write to private field");
|
|
45
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
46
|
+
return value;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// src/index.ts
|
|
50
|
+
var src_exports = {};
|
|
51
|
+
__export(src_exports, {
|
|
52
|
+
Stopwatch: () => Stopwatch
|
|
53
|
+
});
|
|
54
|
+
var import_node_perf_hooks = require("perf_hooks");
|
|
55
|
+
var _start, _end;
|
|
56
|
+
var Stopwatch = class {
|
|
57
|
+
constructor(digits = 2) {
|
|
58
|
+
__publicField(this, "digits");
|
|
59
|
+
__privateAdd(this, _start, void 0);
|
|
60
|
+
__privateAdd(this, _end, void 0);
|
|
61
|
+
this.digits = digits;
|
|
62
|
+
__privateSet(this, _start, import_node_perf_hooks.performance.now());
|
|
63
|
+
__privateSet(this, _end, null);
|
|
64
|
+
}
|
|
65
|
+
get duration() {
|
|
66
|
+
return __privateGet(this, _end) ? __privateGet(this, _end) - __privateGet(this, _start) : import_node_perf_hooks.performance.now() - __privateGet(this, _start);
|
|
67
|
+
}
|
|
68
|
+
get running() {
|
|
69
|
+
return Boolean(!__privateGet(this, _end));
|
|
70
|
+
}
|
|
71
|
+
restart() {
|
|
72
|
+
__privateSet(this, _start, import_node_perf_hooks.performance.now());
|
|
73
|
+
__privateSet(this, _end, null);
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
reset() {
|
|
77
|
+
__privateSet(this, _start, import_node_perf_hooks.performance.now());
|
|
78
|
+
__privateSet(this, _end, __privateGet(this, _start));
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
start() {
|
|
82
|
+
if (!this.running) {
|
|
83
|
+
__privateSet(this, _start, import_node_perf_hooks.performance.now() - this.duration);
|
|
84
|
+
__privateSet(this, _end, null);
|
|
35
85
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
(0, tslib_1.__classPrivateFieldSet)(this, _Stopwatch_start, perf_hooks_1.performance.now(), "f");
|
|
61
|
-
(0, tslib_1.__classPrivateFieldSet)(this, _Stopwatch_end, (0, tslib_1.__classPrivateFieldGet)(this, _Stopwatch_start, "f"), "f");
|
|
62
|
-
return this;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Starts the Stopwatch
|
|
66
|
-
*/
|
|
67
|
-
start() {
|
|
68
|
-
if (!this.running) {
|
|
69
|
-
(0, tslib_1.__classPrivateFieldSet)(this, _Stopwatch_start, perf_hooks_1.performance.now() - this.duration, "f");
|
|
70
|
-
(0, tslib_1.__classPrivateFieldSet)(this, _Stopwatch_end, null, "f");
|
|
71
|
-
}
|
|
72
|
-
return this;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Stops the Stopwatch, freezing the duration
|
|
76
|
-
*/
|
|
77
|
-
stop() {
|
|
78
|
-
if (this.running)
|
|
79
|
-
(0, tslib_1.__classPrivateFieldSet)(this, _Stopwatch_end, perf_hooks_1.performance.now(), "f");
|
|
80
|
-
return this;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Defines toString behavior
|
|
84
|
-
*/
|
|
85
|
-
toString() {
|
|
86
|
-
const time = this.duration;
|
|
87
|
-
if (time >= 1000)
|
|
88
|
-
return `${(time / 1000).toFixed(this.digits)}s`;
|
|
89
|
-
if (time >= 1)
|
|
90
|
-
return `${time.toFixed(this.digits)}ms`;
|
|
91
|
-
return `${(time * 1000).toFixed(this.digits)}μs`;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
exports.Stopwatch = Stopwatch;
|
|
95
|
-
_Stopwatch_start = new WeakMap(), _Stopwatch_end = new WeakMap();
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
stop() {
|
|
89
|
+
if (this.running)
|
|
90
|
+
__privateSet(this, _end, import_node_perf_hooks.performance.now());
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
toString() {
|
|
94
|
+
const time = this.duration;
|
|
95
|
+
if (time >= 1e3)
|
|
96
|
+
return `${(time / 1e3).toFixed(this.digits)}s`;
|
|
97
|
+
if (time >= 1)
|
|
98
|
+
return `${time.toFixed(this.digits)}ms`;
|
|
99
|
+
return `${(time * 1e3).toFixed(this.digits)}\u03BCs`;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
__name(Stopwatch, "Stopwatch");
|
|
103
|
+
_start = new WeakMap();
|
|
104
|
+
_end = new WeakMap();
|
|
105
|
+
module.exports = __toCommonJS(src_exports);
|
|
106
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
107
|
+
0 && (module.exports = {
|
|
108
|
+
Stopwatch
|
|
109
|
+
});
|
|
96
110
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { performance } from 'node:perf_hooks';\n\n/**\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA,6BAA4B;AAA5B;AAKO,sBAAgB;AAAA,EAmBf,YAAY,SAAS,GAAG;AAfxB;AAKP;AAKA;AAMC,SAAK,SAAS;AACd,uBAAK,QAAS,mCAAY;AAC1B,uBAAK,MAAO;AAAA;AAAA,MAMF,WAAmB;AAC7B,WAAO,mBAAK,QAAO,mBAAK,QAAO,mBAAK,UAAS,mCAAY,QAAQ,mBAAK;AAAA;AAAA,MAM5D,UAAmB;AAC7B,WAAO,QAAQ,CAAC,mBAAK;AAAA;AAAA,EAMf,UAAgB;AACtB,uBAAK,QAAS,mCAAY;AAC1B,uBAAK,MAAO;AACZ,WAAO;AAAA;AAAA,EAMD,QAAc;AACpB,uBAAK,QAAS,mCAAY;AAC1B,uBAAK,MAAO,mBAAK;AACjB,WAAO;AAAA;AAAA,EAMD,QAAc;AACpB,QAAI,CAAC,KAAK,SAAS;AAClB,yBAAK,QAAS,mCAAY,QAAQ,KAAK;AACvC,yBAAK,MAAO;AAAA;AAGb,WAAO;AAAA;AAAA,EAMD,OAAa;AACnB,QAAI,KAAK;AAAS,yBAAK,MAAO,mCAAY;AAC1C,WAAO;AAAA;AAAA,EAMD,WAAmB;AACzB,UAAM,OAAO,KAAK;AAClB,QAAI,QAAQ;AAAM,aAAO,GAAI,QAAO,KAAM,QAAQ,KAAK;AACvD,QAAI,QAAQ;AAAG,aAAO,GAAG,KAAK,QAAQ,KAAK;AAC3C,WAAO,GAAI,QAAO,KAAM,QAAQ,KAAK;AAAA;AAAA;AApFhC;AASN;AAKA;","names":[]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,82 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
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
|
+
};
|
|
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
|
+
};
|
|
2
26
|
|
|
3
|
-
|
|
4
|
-
|
|
27
|
+
// src/index.ts
|
|
28
|
+
import { performance } from "node:perf_hooks";
|
|
29
|
+
var _start, _end;
|
|
30
|
+
var Stopwatch = class {
|
|
31
|
+
constructor(digits = 2) {
|
|
32
|
+
__publicField(this, "digits");
|
|
33
|
+
__privateAdd(this, _start, void 0);
|
|
34
|
+
__privateAdd(this, _end, void 0);
|
|
35
|
+
this.digits = digits;
|
|
36
|
+
__privateSet(this, _start, performance.now());
|
|
37
|
+
__privateSet(this, _end, null);
|
|
38
|
+
}
|
|
39
|
+
get duration() {
|
|
40
|
+
return __privateGet(this, _end) ? __privateGet(this, _end) - __privateGet(this, _start) : performance.now() - __privateGet(this, _start);
|
|
41
|
+
}
|
|
42
|
+
get running() {
|
|
43
|
+
return Boolean(!__privateGet(this, _end));
|
|
44
|
+
}
|
|
45
|
+
restart() {
|
|
46
|
+
__privateSet(this, _start, performance.now());
|
|
47
|
+
__privateSet(this, _end, null);
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
reset() {
|
|
51
|
+
__privateSet(this, _start, performance.now());
|
|
52
|
+
__privateSet(this, _end, __privateGet(this, _start));
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
start() {
|
|
56
|
+
if (!this.running) {
|
|
57
|
+
__privateSet(this, _start, performance.now() - this.duration);
|
|
58
|
+
__privateSet(this, _end, null);
|
|
59
|
+
}
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
stop() {
|
|
63
|
+
if (this.running)
|
|
64
|
+
__privateSet(this, _end, performance.now());
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
toString() {
|
|
68
|
+
const time = this.duration;
|
|
69
|
+
if (time >= 1e3)
|
|
70
|
+
return `${(time / 1e3).toFixed(this.digits)}s`;
|
|
71
|
+
if (time >= 1)
|
|
72
|
+
return `${time.toFixed(this.digits)}ms`;
|
|
73
|
+
return `${(time * 1e3).toFixed(this.digits)}\u03BCs`;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
__name(Stopwatch, "Stopwatch");
|
|
77
|
+
_start = new WeakMap();
|
|
78
|
+
_end = new WeakMap();
|
|
79
|
+
export {
|
|
80
|
+
Stopwatch
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { performance } from 'node:perf_hooks';\n\n/**\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAKO,sBAAgB;AAAA,EAmBf,YAAY,SAAS,GAAG;AAfxB;AAKP;AAKA;AAMC,SAAK,SAAS;AACd,uBAAK,QAAS,YAAY;AAC1B,uBAAK,MAAO;AAAA;AAAA,MAMF,WAAmB;AAC7B,WAAO,mBAAK,QAAO,mBAAK,QAAO,mBAAK,UAAS,YAAY,QAAQ,mBAAK;AAAA;AAAA,MAM5D,UAAmB;AAC7B,WAAO,QAAQ,CAAC,mBAAK;AAAA;AAAA,EAMf,UAAgB;AACtB,uBAAK,QAAS,YAAY;AAC1B,uBAAK,MAAO;AACZ,WAAO;AAAA;AAAA,EAMD,QAAc;AACpB,uBAAK,QAAS,YAAY;AAC1B,uBAAK,MAAO,mBAAK;AACjB,WAAO;AAAA;AAAA,EAMD,QAAc;AACpB,QAAI,CAAC,KAAK,SAAS;AAClB,yBAAK,QAAS,YAAY,QAAQ,KAAK;AACvC,yBAAK,MAAO;AAAA;AAGb,WAAO;AAAA;AAAA,EAMD,OAAa;AACnB,QAAI,KAAK;AAAS,yBAAK,MAAO,YAAY;AAC1C,WAAO;AAAA;AAAA,EAMD,WAAmB;AACzB,UAAM,OAAO,KAAK;AAClB,QAAI,QAAQ;AAAM,aAAO,GAAI,QAAO,KAAM,QAAQ,KAAK;AACvD,QAAI,QAAQ;AAAG,aAAO,GAAG,KAAK,QAAQ,KAAK;AAC3C,WAAO,GAAI,QAAO,KAAM,QAAQ,KAAK;AAAA;AAAA;AApFhC;AASN;AAKA;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sapphire/stopwatch",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-next.365a53a.0",
|
|
4
4
|
"description": "Accurately measure passing time.",
|
|
5
5
|
"author": "@sapphire",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,8 +17,7 @@
|
|
|
17
17
|
"scripts": {
|
|
18
18
|
"test": "jest",
|
|
19
19
|
"lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
|
|
20
|
-
"build": "tsc -b src
|
|
21
|
-
"start": "yarn build -w",
|
|
20
|
+
"build": "tsup && tsc -b src",
|
|
22
21
|
"prepublishOnly": "yarn build"
|
|
23
22
|
},
|
|
24
23
|
"dependencies": {
|
|
@@ -53,5 +52,5 @@
|
|
|
53
52
|
"publishConfig": {
|
|
54
53
|
"access": "public"
|
|
55
54
|
},
|
|
56
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "365a53a5517a01a0926cf28a83c96b63f32ed9f8"
|
|
57
56
|
}
|