@sapphire/stopwatch 1.5.0-next.dfe32a0.0 → 1.5.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/CHANGELOG.md +38 -0
- package/dist/index.global.js +11 -24
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +6 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,44 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
# [@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
|
+
|
|
7
|
+
## 🏠 Refactor
|
|
8
|
+
|
|
9
|
+
- Split `@sapphire/time-utilities` into 4 sub-packages (#462) ([574299a](https://github.com/sapphiredev/utilities/commit/574299a99e658f6500a2a7efa587a0919b2d1313))
|
|
10
|
+
|
|
11
|
+
## 🐛 Bug Fixes
|
|
12
|
+
|
|
13
|
+
- **deps:** Update all non-major dependencies (#466) ([dc08606](https://github.com/sapphiredev/utilities/commit/dc08606a97154e47c65536123ac5f8b1262f7bd2))
|
|
14
|
+
- **deps:** Update all non-major dependencies ([e20f299](https://github.com/sapphiredev/utilities/commit/e20f29906e83cee000aaba9c6827e3bec5173d28))
|
|
15
|
+
- **deps:** Update all non-major dependencies ([2308bd7](https://github.com/sapphiredev/utilities/commit/2308bd74356b6b2e0c12995b25f4d8ade4803fe9))
|
|
16
|
+
- **deps:** Update all non-major dependencies ([84af0db](https://github.com/sapphiredev/utilities/commit/84af0db2db749223b036aa99fe19a2e9af5681c6))
|
|
17
|
+
- **deps:** Update all non-major dependencies ([50cd8de](https://github.com/sapphiredev/utilities/commit/50cd8dea593b6f5ae75571209456b3421e2ca59a))
|
|
18
|
+
|
|
19
|
+
## 📝 Documentation
|
|
20
|
+
|
|
21
|
+
- Change name of @kyranet (#451) ([df4fdef](https://github.com/sapphiredev/utilities/commit/df4fdefce18659975a4ebc224723638507d02d35))
|
|
22
|
+
- Update @RealShadowNova as a contributor ([a869ba0](https://github.com/sapphiredev/utilities/commit/a869ba0abfad041610b9115187d426aebe671af6))
|
|
23
|
+
- Add @muchnameless as a contributor ([a1221fe](https://github.com/sapphiredev/utilities/commit/a1221fea68506e99591d5d00ec552a07c26833f9))
|
|
24
|
+
- Add @enxg as a contributor ([d2382f0](https://github.com/sapphiredev/utilities/commit/d2382f04e3909cb4ad11798a0a10e683f6cf5383))
|
|
25
|
+
- Add @EvolutionX-10 as a contributor ([efc3a32](https://github.com/sapphiredev/utilities/commit/efc3a320a72ae258996dd62866d206c33f8d4961))
|
|
26
|
+
- Add @MajesticString as a contributor ([295b3e9](https://github.com/sapphiredev/utilities/commit/295b3e9849a4b0fe64074bae02f6426378a303c3))
|
|
27
|
+
- Add @Mzato0001 as a contributor ([c790ef2](https://github.com/sapphiredev/utilities/commit/c790ef25df2d7e22888fa9f8169167aa555e9e19))
|
|
28
|
+
- Add @NotKaskus as a contributor ([00da8f1](https://github.com/sapphiredev/utilities/commit/00da8f199137b9277119823f322d1f2d168d928a))
|
|
29
|
+
- Add @imranbarbhuiya as a contributor ([fb674c2](https://github.com/sapphiredev/utilities/commit/fb674c2c5594d41e71662263553dcb4bac9e37f4))
|
|
30
|
+
- Add @axisiscool as a contributor ([ce1aa31](https://github.com/sapphiredev/utilities/commit/ce1aa316871a88d3663efbdf2a42d3d8dfe6a27f))
|
|
31
|
+
- Add @dhruv-kaushikk as a contributor ([ebbf43f](https://github.com/sapphiredev/utilities/commit/ebbf43f63617daba96e72c50a234bf8b64f6ddc4))
|
|
32
|
+
- Add @Commandtechno as a contributor ([f1d69fa](https://github.com/sapphiredev/utilities/commit/f1d69fabe1ee0abe4be08b19e63dbec03102f7ce))
|
|
33
|
+
- Fix typedoc causing OOM crashes ([63ba41c](https://github.com/sapphiredev/utilities/commit/63ba41c4b6678554b1c7043a22d3296db4f59360))
|
|
34
|
+
|
|
35
|
+
## 🚀 Features
|
|
36
|
+
|
|
37
|
+
- Make @sapphire/stopwatch browser compitible (#470) ([a02f23a](https://github.com/sapphiredev/utilities/commit/a02f23aec0a6de86746dfd0a7f1fbb6954aac113))
|
|
38
|
+
|
|
39
|
+
## 🧪 Testing
|
|
40
|
+
|
|
41
|
+
- Migrate to vitest (#380) ([075ec73](https://github.com/sapphiredev/utilities/commit/075ec73c7a8e3374fad3ada612d37eb4ac36ec8d))
|
|
42
|
+
|
|
5
43
|
## [1.4.1](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.4.0...@sapphire/stopwatch@1.4.1) (2022-04-01)
|
|
6
44
|
|
|
7
45
|
**Note:** Version bump only for package @sapphire/stopwatch
|
package/dist/index.global.js
CHANGED
|
@@ -1,24 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var SapphireStopwatch = (function (exports) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
6
|
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 __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
7
|
var __publicField = (obj, key, value) => {
|
|
23
8
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
9
|
return value;
|
|
@@ -43,10 +28,6 @@ var SapphireStopwatch = (() => {
|
|
|
43
28
|
};
|
|
44
29
|
|
|
45
30
|
// src/index.ts
|
|
46
|
-
var src_exports = {};
|
|
47
|
-
__export(src_exports, {
|
|
48
|
-
Stopwatch: () => Stopwatch
|
|
49
|
-
});
|
|
50
31
|
var _start, _end;
|
|
51
32
|
var Stopwatch = class {
|
|
52
33
|
constructor(digits = 2) {
|
|
@@ -97,6 +78,12 @@ var SapphireStopwatch = (() => {
|
|
|
97
78
|
__name(Stopwatch, "Stopwatch");
|
|
98
79
|
_start = new WeakMap();
|
|
99
80
|
_end = new WeakMap();
|
|
100
|
-
|
|
101
|
-
|
|
81
|
+
|
|
82
|
+
exports.Stopwatch = Stopwatch;
|
|
83
|
+
|
|
84
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
85
|
+
|
|
86
|
+
return exports;
|
|
87
|
+
|
|
88
|
+
})({});
|
|
102
89
|
//# sourceMappingURL=index.global.js.map
|
package/dist/index.global.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"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,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"]}
|
package/dist/index.js
CHANGED
|
@@ -1,24 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
6
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
7
|
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 __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
8
|
var __publicField = (obj, key, value) => {
|
|
23
9
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
10
|
return value;
|
|
@@ -43,11 +29,6 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
43
29
|
};
|
|
44
30
|
|
|
45
31
|
// src/index.ts
|
|
46
|
-
var src_exports = {};
|
|
47
|
-
__export(src_exports, {
|
|
48
|
-
Stopwatch: () => Stopwatch
|
|
49
|
-
});
|
|
50
|
-
module.exports = __toCommonJS(src_exports);
|
|
51
32
|
var _start, _end;
|
|
52
33
|
var Stopwatch = class {
|
|
53
34
|
constructor(digits = 2) {
|
|
@@ -98,8 +79,6 @@ var Stopwatch = class {
|
|
|
98
79
|
__name(Stopwatch, "Stopwatch");
|
|
99
80
|
_start = new WeakMap();
|
|
100
81
|
_end = new WeakMap();
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
Stopwatch
|
|
104
|
-
});
|
|
82
|
+
|
|
83
|
+
exports.Stopwatch = Stopwatch;
|
|
105
84
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"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,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"]}
|
package/dist/index.mjs
CHANGED
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"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,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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sapphire/stopwatch",
|
|
3
|
-
"version": "1.5.0
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Accurately measure passing time.",
|
|
5
5
|
"author": "@sapphire",
|
|
6
6
|
"license": "MIT",
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"@favware/cliff-jumper": "^1.8.7",
|
|
61
61
|
"@types/jsdom": "^20.0.0",
|
|
62
62
|
"@vitest/coverage-c8": "^0.23.4",
|
|
63
|
-
"jsdom": "^20.0.
|
|
63
|
+
"jsdom": "^20.0.1",
|
|
64
64
|
"tsup": "^6.2.3",
|
|
65
65
|
"typedoc": "^0.23.15",
|
|
66
|
-
"typedoc-json-parser": "^5.0.
|
|
66
|
+
"typedoc-json-parser": "^5.0.1",
|
|
67
67
|
"typescript": "^4.8.4",
|
|
68
68
|
"vitest": "^0.23.4"
|
|
69
69
|
}
|