@sapphire/stopwatch 1.4.1 → 1.4.2-next.1114e5c.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 ADDED
@@ -0,0 +1,121 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## [1.4.1](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.4.0...@sapphire/stopwatch@1.4.1) (2022-04-01)
6
+
7
+ **Note:** Version bump only for package @sapphire/stopwatch
8
+
9
+ # [1.4.0](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.3.0...@sapphire/stopwatch@1.4.0) (2022-03-06)
10
+
11
+ ### Features
12
+
13
+ - allow module: NodeNext ([#306](https://github.com/sapphiredev/utilities/issues/306)) ([9dc6dd6](https://github.com/sapphiredev/utilities/commit/9dc6dd619efab879bb2b0b3c9e64304e10a67ed6))
14
+ - **ts-config:** add multi-config structure ([#281](https://github.com/sapphiredev/utilities/issues/281)) ([b5191d7](https://github.com/sapphiredev/utilities/commit/b5191d7f2416dc5838590c4ff221454925553e37))
15
+
16
+ # [1.3.0](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.2.5...@sapphire/stopwatch@1.3.0) (2022-01-28)
17
+
18
+ ### Features
19
+
20
+ - change build system to tsup ([#270](https://github.com/sapphiredev/utilities/issues/270)) ([365a53a](https://github.com/sapphiredev/utilities/commit/365a53a5517a01a0926cf28a83c96b63f32ed9f8))
21
+
22
+ ## [1.2.5](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.2.4...@sapphire/stopwatch@1.2.5) (2022-01-10)
23
+
24
+ **Note:** Version bump only for package @sapphire/stopwatch
25
+
26
+ ## [1.2.4](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.2.3...@sapphire/stopwatch@1.2.4) (2021-11-06)
27
+
28
+ **Note:** Version bump only for package @sapphire/stopwatch
29
+
30
+ ## [1.2.3](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.2.2...@sapphire/stopwatch@1.2.3) (2021-10-17)
31
+
32
+ ### Bug Fixes
33
+
34
+ - allow more node & npm versions in engines field ([5977d2a](https://github.com/sapphiredev/utilities/commit/5977d2a30a4b2cfdf84aff3f33af03ffde1bbec5))
35
+
36
+ ## [1.2.2](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.2.1...@sapphire/stopwatch@1.2.2) (2021-10-11)
37
+
38
+ **Note:** Version bump only for package @sapphire/stopwatch
39
+
40
+ ## [1.2.1](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.2.0...@sapphire/stopwatch@1.2.1) (2021-10-08)
41
+
42
+ ### Bug Fixes
43
+
44
+ - **stopwatch:** properly run postbuild scripts ([e022d28](https://github.com/sapphiredev/utilities/commit/e022d2870a5ef613e2a6377dbf5db115f93f98c7))
45
+
46
+ # [1.2.0](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.1.4...@sapphire/stopwatch@1.2.0) (2021-10-04)
47
+
48
+ ### Features
49
+
50
+ - **stopwatch:** set minimum NodeJS to v14 ([8154bb7](https://github.com/sapphiredev/utilities/commit/8154bb7ce344b6675295d083f5ede9265fa0ae52))
51
+
52
+ ## [1.1.4](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.1.3...@sapphire/stopwatch@1.1.4) (2021-06-27)
53
+
54
+ **Note:** Version bump only for package @sapphire/stopwatch
55
+
56
+ ## [1.1.3](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.1.2...@sapphire/stopwatch@1.1.3) (2021-06-06)
57
+
58
+ ### Bug Fixes
59
+
60
+ - remove peer deps, update dev deps, update READMEs ([#124](https://github.com/sapphiredev/utilities/issues/124)) ([67256ed](https://github.com/sapphiredev/utilities/commit/67256ed43b915b02a8b5c68230ba82d6210c5032))
61
+
62
+ ## [1.1.2](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.1.1...@sapphire/stopwatch@1.1.2) (2021-05-20)
63
+
64
+ ### Bug Fixes
65
+
66
+ - **stopwatch:** mark package as side effect free ([332ee5c](https://github.com/sapphiredev/utilities/commit/332ee5c2992af062f1d81de78f45046689288129))
67
+
68
+ ## [1.1.1](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.1.0...@sapphire/stopwatch@1.1.1) (2021-05-02)
69
+
70
+ ### Bug Fixes
71
+
72
+ - drop the `www.` from the SapphireJS URL ([494d89f](https://github.com/sapphiredev/utilities/commit/494d89ffa04f78c195b93d7905b3232884f7d7e2))
73
+ - update all the SapphireJS URLs from `.com` to `.dev` ([f59b46d](https://github.com/sapphiredev/utilities/commit/f59b46d1a0ebd39cad17b17d71cd3b9da808d5fd))
74
+
75
+ # [1.1.0](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.0.8...@sapphire/stopwatch@1.1.0) (2021-04-21)
76
+
77
+ ### Features
78
+
79
+ - add @sapphire/embed-jsx ([#100](https://github.com/sapphiredev/utilities/issues/100)) ([7277a23](https://github.com/sapphiredev/utilities/commit/7277a236015236ed8e81b7882875410facc4ce17))
80
+
81
+ ## [1.0.8](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.0.7...@sapphire/stopwatch@1.0.8) (2021-04-19)
82
+
83
+ ### Bug Fixes
84
+
85
+ - change all Sapphire URLs from "project"->"community" & use our domain where applicable 👨‍🌾🚜 ([#102](https://github.com/sapphiredev/utilities/issues/102)) ([835b408](https://github.com/sapphiredev/utilities/commit/835b408e8e57130c3787aca2e32613346ff23e4d))
86
+
87
+ ## [1.0.7](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.0.6...@sapphire/stopwatch@1.0.7) (2021-04-03)
88
+
89
+ **Note:** Version bump only for package @sapphire/stopwatch
90
+
91
+ ## [1.0.6](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.0.5...@sapphire/stopwatch@1.0.6) (2021-03-16)
92
+
93
+ ### Bug Fixes
94
+
95
+ - **stopwatch:** add tslib dependency ([5e7f690](https://github.com/sapphiredev/utilities/commit/5e7f6903475ccfec2147b97f8aa56fb7c037a860))
96
+
97
+ ## [1.0.5](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.0.4...@sapphire/stopwatch@1.0.5) (2021-02-16)
98
+
99
+ **Note:** Version bump only for package @sapphire/stopwatch
100
+
101
+ ## [1.0.4](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.0.3...@sapphire/stopwatch@1.0.4) (2021-01-16)
102
+
103
+ **Note:** Version bump only for package @sapphire/stopwatch
104
+
105
+ ## [1.0.3](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.0.2...@sapphire/stopwatch@1.0.3) (2021-01-01)
106
+
107
+ **Note:** Version bump only for package @sapphire/stopwatch
108
+
109
+ ## [1.0.2](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.0.1...@sapphire/stopwatch@1.0.2) (2020-12-26)
110
+
111
+ **Note:** Version bump only for package @sapphire/stopwatch
112
+
113
+ ## [1.0.1](https://github.com/sapphiredev/utilities/compare/@sapphire/stopwatch@1.0.0...@sapphire/stopwatch@1.0.1) (2020-12-22)
114
+
115
+ **Note:** Version bump only for package @sapphire/stopwatch
116
+
117
+ # 1.0.0 (2020-12-22)
118
+
119
+ ### Features
120
+
121
+ - add stopwatch package ([#44](https://github.com/sapphiredev/utilities/issues/44)) ([cb4370b](https://github.com/sapphiredev/utilities/commit/cb4370b034bced94142755316e933108b7b15a17))
package/dist/index.js CHANGED
@@ -95,6 +95,7 @@ var Stopwatch = class {
95
95
  return `${(time * 1e3).toFixed(this.digits)}\u03BCs`;
96
96
  }
97
97
  };
98
+ __name(Stopwatch, "Stopwatch");
98
99
  _start = new WeakMap();
99
100
  _end = new WeakMap();
100
101
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.js.map CHANGED
@@ -1 +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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, 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":";;;;;;;;;;;;;;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76
+ __name(Stopwatch, "Stopwatch");
76
77
  _start = new WeakMap();
77
78
  _end = new WeakMap();
78
79
  export {
@@ -1 +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,IAAI;AAC9B,uBAAK,MAAO;AAAA,EACb;AAAA,MAKW,WAAmB;AAC7B,WAAO,mBAAK,QAAO,mBAAK,QAAO,mBAAK,UAAS,YAAY,IAAI,IAAI,mBAAK;AAAA,EACvE;AAAA,MAKW,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,GAAI,QAAO,KAAM,QAAQ,KAAK,MAAM;AAC7D,QAAI,QAAQ;AAAG,aAAO,GAAG,KAAK,QAAQ,KAAK,MAAM;AACjD,WAAO,GAAI,QAAO,KAAM,QAAQ,KAAK,MAAM;AAAA,EAC5C;AACD;AAtFO,AASN;AAKA;","names":[]}
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,IAAI;AAC9B,uBAAK,MAAO;AAAA,EACb;AAAA,MAKW,WAAmB;AAC7B,WAAO,mBAAK,QAAO,mBAAK,QAAO,mBAAK,UAAS,YAAY,IAAI,IAAI,mBAAK;AAAA,EACvE;AAAA,MAKW,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,GAAI,QAAO,KAAM,QAAQ,KAAK,MAAM;AAC7D,QAAI,QAAQ;AAAG,aAAO,GAAG,KAAK,QAAQ,KAAK,MAAM;AACjD,WAAO,GAAI,QAAO,KAAM,QAAQ,KAAK,MAAM;AAAA,EAC5C;AACD;AAtFO;AASN;AAKA;","names":[]}
package/package.json CHANGED
@@ -1,57 +1,62 @@
1
1
  {
2
- "name": "@sapphire/stopwatch",
3
- "version": "1.4.1",
4
- "description": "Accurately measure passing time.",
5
- "author": "@sapphire",
6
- "license": "MIT",
7
- "main": "dist/index.js",
8
- "module": "dist/index.mjs",
9
- "types": "dist/index.d.ts",
10
- "typedocMain": "src/index.ts",
11
- "exports": {
12
- "import": "./dist/index.mjs",
13
- "require": "./dist/index.js",
14
- "types": "./dist/index.d.ts"
15
- },
16
- "sideEffects": false,
17
- "homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/stopwatch",
18
- "scripts": {
19
- "test": "jest",
20
- "lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
21
- "build": "tsup && tsc -b src",
22
- "prepublishOnly": "yarn build"
23
- },
24
- "dependencies": {
25
- "tslib": "^2.3.1"
26
- },
27
- "repository": {
28
- "type": "git",
29
- "url": "git+https://github.com/sapphiredev/utilities.git",
30
- "directory": "packages/stopwatch"
31
- },
32
- "files": [
33
- "dist",
34
- "!dist/*.tsbuildinfo"
35
- ],
36
- "engines": {
37
- "node": ">=v14.0.0",
38
- "npm": ">=7.0.0"
39
- },
40
- "keywords": [
41
- "@sapphire/stopwatch",
42
- "bot",
43
- "typescript",
44
- "ts",
45
- "yarn",
46
- "discord",
47
- "sapphire",
48
- "standalone"
49
- ],
50
- "bugs": {
51
- "url": "https://github.com/sapphiredev/utilities/issues"
52
- },
53
- "publishConfig": {
54
- "access": "public"
55
- },
56
- "gitHead": "bf5ac56e547bfdbfac38e020882004e0f136546e"
57
- }
2
+ "name": "@sapphire/stopwatch",
3
+ "version": "1.4.2-next.1114e5c.0",
4
+ "description": "Accurately measure passing time.",
5
+ "author": "@sapphire",
6
+ "license": "MIT",
7
+ "main": "dist/index.js",
8
+ "module": "dist/index.mjs",
9
+ "types": "dist/index.d.ts",
10
+ "exports": {
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js",
13
+ "types": "./dist/index.d.ts"
14
+ },
15
+ "sideEffects": false,
16
+ "homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/stopwatch",
17
+ "scripts": {
18
+ "test": "jest",
19
+ "lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
20
+ "build": "tsup && tsc -b src",
21
+ "prepublish": "yarn build",
22
+ "bump": "cliff-jumper",
23
+ "check-update": "cliff-jumper --dry-run"
24
+ },
25
+ "dependencies": {
26
+ "tslib": "^2.3.1"
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/sapphiredev/utilities.git",
31
+ "directory": "packages/stopwatch"
32
+ },
33
+ "files": [
34
+ "dist/**/*.js*",
35
+ "dist/**/*.mjs*",
36
+ "dist/**/*.d*"
37
+ ],
38
+ "engines": {
39
+ "node": ">=v14.0.0",
40
+ "npm": ">=7.0.0"
41
+ },
42
+ "keywords": [
43
+ "@sapphire/stopwatch",
44
+ "bot",
45
+ "typescript",
46
+ "ts",
47
+ "yarn",
48
+ "discord",
49
+ "sapphire",
50
+ "standalone"
51
+ ],
52
+ "bugs": {
53
+ "url": "https://github.com/sapphiredev/utilities/issues"
54
+ },
55
+ "publishConfig": {
56
+ "access": "public"
57
+ },
58
+ "devDependencies": {
59
+ "tsup": "^5.12.5",
60
+ "typescript": "^4.6.3"
61
+ }
62
+ }
package/LICENSE.md DELETED
@@ -1,24 +0,0 @@
1
- # The MIT License (MIT)
2
-
3
- Copyright © `2020` `The Sapphire Community and its contributors`
4
-
5
- Permission is hereby granted, free of charge, to any person
6
- obtaining a copy of this software and associated documentation
7
- files (the “Software”), to deal in the Software without
8
- restriction, including without limitation the rights to use,
9
- copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the
11
- Software is furnished to do so, subject to the following
12
- conditions:
13
-
14
- The above copyright notice and this permission notice shall be
15
- included in all copies or substantial portions of the Software.
16
-
17
- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
18
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24
- OTHER DEALINGS IN THE SOFTWARE.