@ztimson/utils 0.21.4 → 0.21.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,91 +1,91 @@
1
- <!-- Header -->
2
- <div id="top" align="center">
3
- <br />
4
-
5
- <!-- Logo -->
6
- <img src="https://git.zakscode.com/repo-avatars/77dbab78e5fb3302dc9e751c4d6315a64df8d3a714d5cd5719b0dc39e6619119" alt="Logo" width="200" height="200">
7
-
8
- <!-- Title -->
9
- ### @ztimson/utils
10
-
11
- <!-- Description -->
12
- Javascript/Typescript Utilities
13
-
14
- <!-- Repo badges -->
15
- [![Version](https://img.shields.io/badge/dynamic/json.svg?label=Version&style=for-the-badge&url=https://git.zakscode.com/api/v1/repos/ztimson/utils/tags&query=$[0].name)](https://git.zakscode.com/ztimson/utils/tags)
16
- [![Pull Requests](https://img.shields.io/badge/dynamic/json.svg?label=Pull%20Requests&style=for-the-badge&url=https://git.zakscode.com/api/v1/repos/ztimson/utils&query=open_pr_counter)](https://git.zakscode.com/ztimson/utils/pulls)
17
- [![Issues](https://img.shields.io/badge/dynamic/json.svg?label=Issues&style=for-the-badge&url=https://git.zakscode.com/api/v1/repos/ztimson/utils&query=open_issues_count)](https://git.zakscode.com/ztimson/utils/issues)
18
-
19
- <!-- Links -->
20
-
21
- ---
22
- <div>
23
- <a href="https://utils.docs.zakscode.com" target="_blank">Documentation</a>
24
- • <a href="https://git.zakscode.com/ztimson/utils/releases" target="_blank">Release Notes</a>
25
- • <a href="https://git.zakscode.com/ztimson/utils/issues/new?template=.github%2fissue_template%2fbug.md" target="_blank">Report a Bug</a>
26
- • <a href="https://git.zakscode.com/ztimson/utils/issues/new?template=.github%2fissue_template%2fenhancement.md" target="_blank">Request a Feature</a>
27
- </div>
28
-
29
- ---
30
- </div>
31
-
32
- ## Table of Contents
33
- - [@ztimson/utils](#top)
34
- - [About](#about)
35
- - [Built With](#built-with)
36
- - [Setup](#setup)
37
- - [Production](#production)
38
- - [Development](#development)
39
- - [Documentation](https://utils.docs.zakscode.com/)
40
- - [License](#license)
41
-
42
- ## About
43
-
44
- A collection of utilities to make life a little easier
45
-
46
- ### Built With
47
- [![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?style=for-the-badge&logo=typescript&logoColor=white)](https://typescriptlang.org/)
48
-
49
- ## Setup
50
-
51
- <details>
52
- <summary>
53
- <h3 id="production" style="display: inline">
54
- Production
55
- </h3>
56
- </summary>
57
-
58
- #### Prerequisites
59
- - [Node.js](https://nodejs.org/en/download)
60
-
61
- #### Instructions
62
- 1. Install persist: `npm i @ztimosn/utils`
63
-
64
- </details>
65
-
66
- <details>
67
- <summary>
68
- <h3 id="development" style="display: inline">
69
- Development
70
- </h3>
71
- </summary>
72
-
73
- #### Prerequisites
74
- - [Node.js](https://nodejs.org/en/download)
75
-
76
- #### Instructions
77
- 1. Install the dependencies: `npm i`
78
- 2. Build library: `npm build`
79
- 3. Run unit tests: `npm test`
80
-
81
- </details>
82
-
83
- ## Documentation
84
-
85
- [Available Here](https://utils.docs.zakscode.com/)
86
-
87
- ## License
88
-
89
- Copyright © 2023 Zakary Timson | Available under MIT Licensing
90
-
91
- See the [license](_media/LICENSE) for more information.
1
+ <!-- Header -->
2
+ <div id="top" align="center">
3
+ <br />
4
+
5
+ <!-- Logo -->
6
+ <img src="https://git.zakscode.com/repo-avatars/77dbab78e5fb3302dc9e751c4d6315a64df8d3a714d5cd5719b0dc39e6619119" alt="Logo" width="200" height="200">
7
+
8
+ <!-- Title -->
9
+ ### @ztimson/utils
10
+
11
+ <!-- Description -->
12
+ Javascript/Typescript Utilities
13
+
14
+ <!-- Repo badges -->
15
+ [![Version](https://img.shields.io/badge/dynamic/json.svg?label=Version&style=for-the-badge&url=https://git.zakscode.com/api/v1/repos/ztimson/utils/tags&query=$[0].name)](https://git.zakscode.com/ztimson/utils/tags)
16
+ [![Pull Requests](https://img.shields.io/badge/dynamic/json.svg?label=Pull%20Requests&style=for-the-badge&url=https://git.zakscode.com/api/v1/repos/ztimson/utils&query=open_pr_counter)](https://git.zakscode.com/ztimson/utils/pulls)
17
+ [![Issues](https://img.shields.io/badge/dynamic/json.svg?label=Issues&style=for-the-badge&url=https://git.zakscode.com/api/v1/repos/ztimson/utils&query=open_issues_count)](https://git.zakscode.com/ztimson/utils/issues)
18
+
19
+ <!-- Links -->
20
+
21
+ ---
22
+ <div>
23
+ <a href="https://utils.docs.zakscode.com" target="_blank">Documentation</a>
24
+ • <a href="https://git.zakscode.com/ztimson/utils/releases" target="_blank">Release Notes</a>
25
+ • <a href="https://git.zakscode.com/ztimson/utils/issues/new?template=.github%2fissue_template%2fbug.md" target="_blank">Report a Bug</a>
26
+ • <a href="https://git.zakscode.com/ztimson/utils/issues/new?template=.github%2fissue_template%2fenhancement.md" target="_blank">Request a Feature</a>
27
+ </div>
28
+
29
+ ---
30
+ </div>
31
+
32
+ ## Table of Contents
33
+ - [@ztimson/utils](#top)
34
+ - [About](#about)
35
+ - [Built With](#built-with)
36
+ - [Setup](#setup)
37
+ - [Production](#production)
38
+ - [Development](#development)
39
+ - [Documentation](https://utils.docs.zakscode.com/)
40
+ - [License](#license)
41
+
42
+ ## About
43
+
44
+ A collection of utilities to make life a little easier
45
+
46
+ ### Built With
47
+ [![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?style=for-the-badge&logo=typescript&logoColor=white)](https://typescriptlang.org/)
48
+
49
+ ## Setup
50
+
51
+ <details>
52
+ <summary>
53
+ <h3 id="production" style="display: inline">
54
+ Production
55
+ </h3>
56
+ </summary>
57
+
58
+ #### Prerequisites
59
+ - [Node.js](https://nodejs.org/en/download)
60
+
61
+ #### Instructions
62
+ 1. Install persist: `npm i @ztimosn/utils`
63
+
64
+ </details>
65
+
66
+ <details>
67
+ <summary>
68
+ <h3 id="development" style="display: inline">
69
+ Development
70
+ </h3>
71
+ </summary>
72
+
73
+ #### Prerequisites
74
+ - [Node.js](https://nodejs.org/en/download)
75
+
76
+ #### Instructions
77
+ 1. Install the dependencies: `npm i`
78
+ 2. Build library: `npm build`
79
+ 3. Run unit tests: `npm test`
80
+
81
+ </details>
82
+
83
+ ## Documentation
84
+
85
+ [Available Here](https://utils.docs.zakscode.com/)
86
+
87
+ ## License
88
+
89
+ Copyright © 2023 Zakary Timson | Available under MIT Licensing
90
+
91
+ See the [license](_media/LICENSE) for more information.
package/dist/errors.d.ts CHANGED
@@ -74,4 +74,4 @@ export declare class GatewayTimeoutError extends CustomError {
74
74
  * @param {string} message Override default error message
75
75
  * @return {CustomError} The proper error type
76
76
  */
77
- export declare function errorFromCode(code: number, message?: string): CustomError | null;
77
+ export declare function errorFromCode(code: number, message?: string): CustomError;
package/dist/index.cjs CHANGED
@@ -711,7 +711,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
711
711
  }
712
712
  __publicField(GatewayTimeoutError, "code", 504);
713
713
  function errorFromCode(code, message) {
714
- if (code >= 200 && code < 300) return null;
715
714
  switch (code) {
716
715
  case 400:
717
716
  return new BadRequestError(message);
@@ -1230,7 +1229,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1230
1229
  const filtered = parsedTarget.filter((p) => r.fullPath.startsWith(p.fullPath));
1231
1230
  if (!filtered.length) return false;
1232
1231
  const combined = PathEvent.combine(...filtered);
1233
- return !combined.none && (combined.all || new ASet(combined.methods).intersection(new ASet(r.methods)).length);
1232
+ return !combined.none && (combined.all || r.all) || combined.methods.intersection(r.methods).length;
1234
1233
  });
1235
1234
  }
1236
1235
  /**
@@ -1320,6 +1319,21 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1320
1319
  emitter.on("*", (event, ...args) => this.emit(event, ...args));
1321
1320
  }
1322
1321
  }
1322
+ function adjustedInterval(cb, ms) {
1323
+ let cancel = false, timeout = null;
1324
+ const p = async () => {
1325
+ if (cancel) return;
1326
+ const start = (/* @__PURE__ */ new Date()).getTime();
1327
+ await cb();
1328
+ const end = (/* @__PURE__ */ new Date()).getTime();
1329
+ timeout = setTimeout(() => p(), ms - (end - start) || 1);
1330
+ };
1331
+ p();
1332
+ return () => {
1333
+ cancel = true;
1334
+ if (timeout) clearTimeout(timeout);
1335
+ };
1336
+ }
1323
1337
  function formatDate(date) {
1324
1338
  if (typeof date == "number" || typeof date == "string") date = new Date(date);
1325
1339
  let hours = date.getHours(), postfix = "AM";
@@ -1372,6 +1386,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1372
1386
  exports2.TypedEmitter = TypedEmitter;
1373
1387
  exports2.UnauthorizedError = UnauthorizedError;
1374
1388
  exports2.addUnique = addUnique;
1389
+ exports2.adjustedInterval = adjustedInterval;
1375
1390
  exports2.arrayDiff = arrayDiff;
1376
1391
  exports2.caseInsensitiveSort = caseInsensitiveSort;
1377
1392
  exports2.clean = clean;