@gesslar/toolkit 2.7.1 → 2.8.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 +9 -0
- package/package.json +1 -1
- package/src/browser/index.js +1 -0
- package/src/browser/lib/Promised.js +120 -0
- package/src/browser/lib/Util.js +0 -98
- package/src/index.js +1 -0
- package/src/lib/FileObject.js +1 -3
- package/src/types/browser/index.d.ts +1 -0
- package/src/types/browser/lib/Promised.d.ts +119 -0
- package/src/types/browser/lib/Promised.d.ts.map +1 -0
- package/src/types/browser/lib/Util.d.ts +0 -67
- package/src/types/browser/lib/Util.d.ts.map +1 -1
- package/src/types/index.d.ts +1 -0
- package/src/types/lib/FileObject.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ a Tauri app.
|
|
|
16
16
|
| Disposer | Lifecycle management for disposable resources |
|
|
17
17
|
| HTML | HTML loading and sanitization utilities |
|
|
18
18
|
| Notify | Event system wrapper for DOM events |
|
|
19
|
+
| Promised | Promise utilities for settling, filtering, and extracting values from promise results |
|
|
19
20
|
| Sass | Custom Error class with enhanced features |
|
|
20
21
|
| Tantrum | AggregateError implementation |
|
|
21
22
|
| Type | String-based type management (exported as TypeSpec in browser) |
|
|
@@ -93,3 +94,11 @@ import { Data, Collection, Util } from '@gesslar/toolkit/browser'
|
|
|
93
94
|
```
|
|
94
95
|
|
|
95
96
|
The browser version includes: Collection, Data, Disposer, HTML, Notify, Sass, Tantrum, Type (TypeSpec), Util, and Valid. Node-only modules (Cache, CappedDirectoryObject, Contract, DirectoryObject, FileObject, FS, Glog, Schemer, TempDirectoryObject, Term, Terms) are not available in the browser version.
|
|
97
|
+
|
|
98
|
+
## Post Partum
|
|
99
|
+
|
|
100
|
+
If you made it this far, please understand that I have absolutely zero scruples when it comes to breaking changes. Primarily, the audience for this library is myself. Consequently, anything that relies on the contents of this library will dutifully crash and I'll have to refactor those things then. It's like leaving playing nicky nicky nine doors. But with myself. And there's a lazy bomb waiting for me. That I planted. For me. And the bomb just explodes poop.
|
|
101
|
+
|
|
102
|
+
You're of course welcome to use my library! It's pretty robust. Uhhh, but maybe lock in the version until you see if something is gonna poop all over you. I make robots make my PR notifications and generally they're very good at firing off klaxons about my fetish for breaking changes, so you should be all right if you're paying attention. 🤷🏻
|
|
103
|
+
|
|
104
|
+
Sincerely, Senator Yabba of the Dabba (Doo)
|
package/package.json
CHANGED
package/src/browser/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export {Disposer as DisposerClass} from "./lib/Disposer.js"
|
|
|
8
8
|
export {default as HTML} from "./lib/HTML.js"
|
|
9
9
|
export {HTML as HTMLClass} from "./lib/HTML.js"
|
|
10
10
|
export {default as Notify} from "./lib/Notify.js"
|
|
11
|
+
export {default as Promised} from "./lib/Promised.js"
|
|
11
12
|
export {default as Sass} from "./lib/Sass.js"
|
|
12
13
|
export {default as Tantrum} from "./lib/Tantrum.js"
|
|
13
14
|
export {default as Type} from "./lib/TypeSpec.js"
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import Tantrum from "./Tantrum.js"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Utility class providing helper functions for working with Promises,
|
|
5
|
+
* including settling, filtering, and extracting values from promise results.
|
|
6
|
+
*/
|
|
7
|
+
export default class Promised {
|
|
8
|
+
/**
|
|
9
|
+
* Asynchronously awaits all promises in parallel.
|
|
10
|
+
* Wrapper around Promise.all for consistency with other utility methods.
|
|
11
|
+
*
|
|
12
|
+
* @param {Array<Promise<unknown>>} promises - Array of promises to await
|
|
13
|
+
* @returns {Promise<Array<unknown>>} Results of all promises
|
|
14
|
+
*/
|
|
15
|
+
static async await(promises) {
|
|
16
|
+
return await Promise.all(promises)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Settles all promises (both fulfilled and rejected) in parallel.
|
|
21
|
+
* Wrapper around Promise.allSettled for consistency with other utility methods.
|
|
22
|
+
*
|
|
23
|
+
* @param {Array<Promise<unknown>>} promises - Array of promises to settle
|
|
24
|
+
* @returns {Promise<Array<{status: 'fulfilled'|'rejected', value?: unknown, reason?: unknown}>>} Results of all settled promises with status and value/reason
|
|
25
|
+
*/
|
|
26
|
+
static async settle(promises) {
|
|
27
|
+
return await Promise.allSettled(promises)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Checks if any result in the settled promise array is rejected.
|
|
32
|
+
*
|
|
33
|
+
* @param {Array<{status: 'fulfilled'|'rejected', value?: unknown, reason?: unknown}>} settled - Array of settled promise results
|
|
34
|
+
* @returns {boolean} True if any result is rejected, false otherwise
|
|
35
|
+
*/
|
|
36
|
+
static hasRejected(settled) {
|
|
37
|
+
return settled.some(r => r.status === "rejected")
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Checks if any result in the settled promise array is fulfilled.
|
|
42
|
+
*
|
|
43
|
+
* @param {Array<{status: 'fulfilled'|'rejected', value?: unknown, reason?: unknown}>} settled - Array of settled promise results
|
|
44
|
+
* @returns {boolean} True if any result is fulfilled, false otherwise
|
|
45
|
+
*/
|
|
46
|
+
static hasFulfilled(settled) {
|
|
47
|
+
return settled.some(r => r.status === "fulfilled")
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Filters and returns all rejected results from a settled promise array.
|
|
52
|
+
*
|
|
53
|
+
* @param {Array<{status: 'fulfilled'|'rejected', value?: unknown, reason?: unknown}>} settled - Array of settled promise results
|
|
54
|
+
* @returns {Array<{status: 'rejected', reason: unknown}>} Array of rejected results
|
|
55
|
+
*/
|
|
56
|
+
static rejected(settled) {
|
|
57
|
+
return settled.filter(r => r.status === "rejected")
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Filters and returns all fulfilled results from a settled promise array.
|
|
62
|
+
*
|
|
63
|
+
* @param {Array<{status: 'fulfilled'|'rejected', value?: unknown, reason?: unknown}>} result - Array of settled promise results
|
|
64
|
+
* @returns {Array<{status: 'fulfilled', value: unknown}>} Array of fulfilled results
|
|
65
|
+
*/
|
|
66
|
+
static fulfilled(result) {
|
|
67
|
+
return result.filter(r => r.status === "fulfilled")
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Extracts the rejection reasons from a settled promise array.
|
|
72
|
+
*
|
|
73
|
+
* @param {Array<{status: 'fulfilled'|'rejected', value?: unknown, reason?: unknown}>} settled - Array of settled promise results
|
|
74
|
+
* @returns {Array<unknown>} Array of rejection reasons
|
|
75
|
+
*/
|
|
76
|
+
static reasons(settled) {
|
|
77
|
+
const rejected = this.rejected(settled)
|
|
78
|
+
const reasons = rejected.map(e => e.reason)
|
|
79
|
+
|
|
80
|
+
return reasons
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Extracts the values from fulfilled results in a settled promise array.
|
|
85
|
+
*
|
|
86
|
+
* @param {Array<{status: 'fulfilled'|'rejected', value?: unknown, reason?: unknown}>} settled - Array of settled promise results
|
|
87
|
+
* @returns {Array<unknown>} Array of fulfilled values
|
|
88
|
+
*/
|
|
89
|
+
static values(settled) {
|
|
90
|
+
const fulfilled = this.fulfilled(settled)
|
|
91
|
+
const values = fulfilled.map(e => e.value)
|
|
92
|
+
|
|
93
|
+
return values
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Throws a Tantrum containing all rejection reasons from settled promises.
|
|
98
|
+
*
|
|
99
|
+
* @param {string} message - Error message. Defaults to "GIGO"
|
|
100
|
+
* @param {Array<{status: 'fulfilled'|'rejected', value?: unknown, reason?: unknown}>} settled - Array of settled promise results
|
|
101
|
+
* @throws {Tantrum} Throws a Tantrum error with rejection reasons
|
|
102
|
+
*/
|
|
103
|
+
static throw(message="GIGO", settled) {
|
|
104
|
+
const rejected = this.rejected(settled)
|
|
105
|
+
const reasons = this.reasons(rejected)
|
|
106
|
+
|
|
107
|
+
throw Tantrum.new(message, reasons)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Returns the first promise to resolve or reject from an array of promises.
|
|
112
|
+
* Wrapper around Promise.race for consistency with other utility methods.
|
|
113
|
+
*
|
|
114
|
+
* @param {Array<Promise<unknown>>} promises - Array of promises to race
|
|
115
|
+
* @returns {Promise<unknown>} Result of the first settled promise
|
|
116
|
+
*/
|
|
117
|
+
static async race(promises) {
|
|
118
|
+
return await Promise.race(promises)
|
|
119
|
+
}
|
|
120
|
+
}
|
package/src/browser/lib/Util.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import Tantrum from "./Tantrum.js"
|
|
2
1
|
import Valid from "./Valid.js"
|
|
3
2
|
import Collection from "./Collection.js"
|
|
4
3
|
|
|
@@ -80,103 +79,6 @@ export default class Util {
|
|
|
80
79
|
return `${" ".repeat(leftPadding)}${work}${" ".repeat(rightPadding)}`
|
|
81
80
|
}
|
|
82
81
|
|
|
83
|
-
/**
|
|
84
|
-
* Asynchronously awaits all promises in parallel.
|
|
85
|
-
* Wrapper around Promise.all for consistency with other utility methods.
|
|
86
|
-
*
|
|
87
|
-
* @param {Array<Promise<unknown>>} promises - Array of promises to await
|
|
88
|
-
* @returns {Promise<Array<unknown>>} Results of all promises
|
|
89
|
-
*/
|
|
90
|
-
static async awaitAll(promises) {
|
|
91
|
-
return await Promise.all(promises)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Settles all promises (both fulfilled and rejected) in parallel.
|
|
96
|
-
* Wrapper around Promise.allSettled for consistency with other utility methods.
|
|
97
|
-
*
|
|
98
|
-
* @param {Array<Promise<unknown>>} promises - Array of promises to settle
|
|
99
|
-
* @returns {Promise<Array<object>>} Results of all settled promises with status and value/reason
|
|
100
|
-
*/
|
|
101
|
-
static async settleAll(promises) {
|
|
102
|
-
return await Promise.allSettled(promises)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Checks if any result in the settled promise array is rejected.
|
|
107
|
-
*
|
|
108
|
-
* @param {Array<object>} result - Array of settled promise results.
|
|
109
|
-
* @returns {boolean} True if any result is rejected, false otherwise.
|
|
110
|
-
*/
|
|
111
|
-
static anyRejected(result) {
|
|
112
|
-
return result.some(r => r.status === "rejected")
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Filters and returns all rejected results from a settled promise array.
|
|
117
|
-
*
|
|
118
|
-
* @param {Array<object>} result - Array of settled promise results.
|
|
119
|
-
* @returns {Array<object>} Array of rejected results.
|
|
120
|
-
*/
|
|
121
|
-
static settledAndRejected(result) {
|
|
122
|
-
return result.filter(r => r.status === "rejected")
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Extracts the rejection reasons from an array of rejected promise results.
|
|
127
|
-
*
|
|
128
|
-
* @param {Array<object>} rejected - Array of rejected results.
|
|
129
|
-
* @returns {Array<unknown>} Array of rejection reasons.
|
|
130
|
-
*/
|
|
131
|
-
static rejectedReasons(rejected) {
|
|
132
|
-
return rejected.map(r => r.reason)
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Throws a Sass error containing all rejection reasons from settled promises.
|
|
137
|
-
*
|
|
138
|
-
* @param {string} [_message] - Optional error message. Defaults to "GIGO"
|
|
139
|
-
* @param {Array<object>} rejected - Array of rejected results.
|
|
140
|
-
* @throws {Error} Throws a Tantrum error with rejection reasons.
|
|
141
|
-
*/
|
|
142
|
-
static throwRejected(message="GIGO", settled) {
|
|
143
|
-
throw Tantrum.new(
|
|
144
|
-
message,
|
|
145
|
-
this.rejectedReasons(this.settledAndRejected(settled))
|
|
146
|
-
)
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Filters and returns all fulfilled results from a settled promise array.
|
|
151
|
-
*
|
|
152
|
-
* @param {Array<object>} result - Array of settled promise results.
|
|
153
|
-
* @returns {Array<object>} Array of fulfilled results.
|
|
154
|
-
*/
|
|
155
|
-
static settledAndFulfilled(result) {
|
|
156
|
-
return result.filter(r => r.status === "fulfilled")
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Extracts the values from all fulfilled results in a settled promise array.
|
|
161
|
-
*
|
|
162
|
-
* @param {Array<object>} result - Array of settled promise results.
|
|
163
|
-
* @returns {Array<unknown>} Array of fulfilled values.
|
|
164
|
-
*/
|
|
165
|
-
static fulfilledValues(result) {
|
|
166
|
-
return this.settledAndFulfilled(result).map(r => r.value)
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Returns the first promise to resolve or reject from an array of promises.
|
|
171
|
-
* Wrapper around Promise.race for consistency with other utility methods.
|
|
172
|
-
*
|
|
173
|
-
* @param {Array<Promise<unknown>>} promises - Array of promises to race
|
|
174
|
-
* @returns {Promise<unknown>} Result of the first settled promise
|
|
175
|
-
*/
|
|
176
|
-
static async race(promises) {
|
|
177
|
-
return await Promise.race(promises)
|
|
178
|
-
}
|
|
179
|
-
|
|
180
82
|
/**
|
|
181
83
|
* Determine the Levenshtein distance between two string values
|
|
182
84
|
*
|
package/src/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export {default as Collection} from "./browser/lib/Collection.js"
|
|
|
3
3
|
export {default as Data} from "./browser/lib/Data.js"
|
|
4
4
|
export {default as Disposer} from "./browser/lib/Disposer.js"
|
|
5
5
|
export {Disposer as DisposerClass} from "./browser/lib/Disposer.js"
|
|
6
|
+
export {default as Promised} from "./browser/lib/Promised.js"
|
|
6
7
|
export {default as Type} from "./browser/lib/TypeSpec.js"
|
|
7
8
|
export {default as Valid} from "./lib/Valid.js"
|
|
8
9
|
|
package/src/lib/FileObject.js
CHANGED
|
@@ -85,12 +85,10 @@ export default class FileObject extends FS {
|
|
|
85
85
|
if(Data.isType(fileName, "FileObject"))
|
|
86
86
|
fileName = fileName.path
|
|
87
87
|
|
|
88
|
-
if(!fileName || typeof fileName !== "string" || fileName.length === 0)
|
|
88
|
+
if(!fileName || typeof fileName !== "string" || fileName.length === 0)
|
|
89
89
|
throw Sass.new("fileName must be a non-empty string")
|
|
90
|
-
}
|
|
91
90
|
|
|
92
91
|
const fixedFile = FS.fixSlashes(fileName)
|
|
93
|
-
|
|
94
92
|
const {dir,base,ext} = this.#deconstructFilenameToParts(fixedFile)
|
|
95
93
|
|
|
96
94
|
const parentObject = (() => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as Collection } from "./lib/Collection.js";
|
|
2
2
|
export { default as Data } from "./lib/Data.js";
|
|
3
3
|
export { default as Notify } from "./lib/Notify.js";
|
|
4
|
+
export { default as Promised } from "./lib/Promised.js";
|
|
4
5
|
export { default as Sass } from "./lib/Sass.js";
|
|
5
6
|
export { default as Tantrum } from "./lib/Tantrum.js";
|
|
6
7
|
export { default as Type } from "./lib/TypeSpec.js";
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility class providing helper functions for working with Promises,
|
|
3
|
+
* including settling, filtering, and extracting values from promise results.
|
|
4
|
+
*/
|
|
5
|
+
export default class Promised {
|
|
6
|
+
/**
|
|
7
|
+
* Asynchronously awaits all promises in parallel.
|
|
8
|
+
* Wrapper around Promise.all for consistency with other utility methods.
|
|
9
|
+
*
|
|
10
|
+
* @param {Array<Promise<unknown>>} promises - Array of promises to await
|
|
11
|
+
* @returns {Promise<Array<unknown>>} Results of all promises
|
|
12
|
+
*/
|
|
13
|
+
static await(promises: Array<Promise<unknown>>): Promise<Array<unknown>>;
|
|
14
|
+
/**
|
|
15
|
+
* Settles all promises (both fulfilled and rejected) in parallel.
|
|
16
|
+
* Wrapper around Promise.allSettled for consistency with other utility methods.
|
|
17
|
+
*
|
|
18
|
+
* @param {Array<Promise<unknown>>} promises - Array of promises to settle
|
|
19
|
+
* @returns {Promise<Array<{status: 'fulfilled'|'rejected', value?: unknown, reason?: unknown}>>} Results of all settled promises with status and value/reason
|
|
20
|
+
*/
|
|
21
|
+
static settle(promises: Array<Promise<unknown>>): Promise<Array<{
|
|
22
|
+
status: "fulfilled" | "rejected";
|
|
23
|
+
value?: unknown;
|
|
24
|
+
reason?: unknown;
|
|
25
|
+
}>>;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if any result in the settled promise array is rejected.
|
|
28
|
+
*
|
|
29
|
+
* @param {Array<{status: 'fulfilled'|'rejected', value?: unknown, reason?: unknown}>} settled - Array of settled promise results
|
|
30
|
+
* @returns {boolean} True if any result is rejected, false otherwise
|
|
31
|
+
*/
|
|
32
|
+
static hasRejected(settled: Array<{
|
|
33
|
+
status: "fulfilled" | "rejected";
|
|
34
|
+
value?: unknown;
|
|
35
|
+
reason?: unknown;
|
|
36
|
+
}>): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Checks if any result in the settled promise array is fulfilled.
|
|
39
|
+
*
|
|
40
|
+
* @param {Array<{status: 'fulfilled'|'rejected', value?: unknown, reason?: unknown}>} settled - Array of settled promise results
|
|
41
|
+
* @returns {boolean} True if any result is fulfilled, false otherwise
|
|
42
|
+
*/
|
|
43
|
+
static hasFulfilled(settled: Array<{
|
|
44
|
+
status: "fulfilled" | "rejected";
|
|
45
|
+
value?: unknown;
|
|
46
|
+
reason?: unknown;
|
|
47
|
+
}>): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Filters and returns all rejected results from a settled promise array.
|
|
50
|
+
*
|
|
51
|
+
* @param {Array<{status: 'fulfilled'|'rejected', value?: unknown, reason?: unknown}>} settled - Array of settled promise results
|
|
52
|
+
* @returns {Array<{status: 'rejected', reason: unknown}>} Array of rejected results
|
|
53
|
+
*/
|
|
54
|
+
static rejected(settled: Array<{
|
|
55
|
+
status: "fulfilled" | "rejected";
|
|
56
|
+
value?: unknown;
|
|
57
|
+
reason?: unknown;
|
|
58
|
+
}>): Array<{
|
|
59
|
+
status: "rejected";
|
|
60
|
+
reason: unknown;
|
|
61
|
+
}>;
|
|
62
|
+
/**
|
|
63
|
+
* Filters and returns all fulfilled results from a settled promise array.
|
|
64
|
+
*
|
|
65
|
+
* @param {Array<{status: 'fulfilled'|'rejected', value?: unknown, reason?: unknown}>} result - Array of settled promise results
|
|
66
|
+
* @returns {Array<{status: 'fulfilled', value: unknown}>} Array of fulfilled results
|
|
67
|
+
*/
|
|
68
|
+
static fulfilled(result: Array<{
|
|
69
|
+
status: "fulfilled" | "rejected";
|
|
70
|
+
value?: unknown;
|
|
71
|
+
reason?: unknown;
|
|
72
|
+
}>): Array<{
|
|
73
|
+
status: "fulfilled";
|
|
74
|
+
value: unknown;
|
|
75
|
+
}>;
|
|
76
|
+
/**
|
|
77
|
+
* Extracts the rejection reasons from a settled promise array.
|
|
78
|
+
*
|
|
79
|
+
* @param {Array<{status: 'fulfilled'|'rejected', value?: unknown, reason?: unknown}>} settled - Array of settled promise results
|
|
80
|
+
* @returns {Array<unknown>} Array of rejection reasons
|
|
81
|
+
*/
|
|
82
|
+
static reasons(settled: Array<{
|
|
83
|
+
status: "fulfilled" | "rejected";
|
|
84
|
+
value?: unknown;
|
|
85
|
+
reason?: unknown;
|
|
86
|
+
}>): Array<unknown>;
|
|
87
|
+
/**
|
|
88
|
+
* Extracts the values from fulfilled results in a settled promise array.
|
|
89
|
+
*
|
|
90
|
+
* @param {Array<{status: 'fulfilled'|'rejected', value?: unknown, reason?: unknown}>} settled - Array of settled promise results
|
|
91
|
+
* @returns {Array<unknown>} Array of fulfilled values
|
|
92
|
+
*/
|
|
93
|
+
static values(settled: Array<{
|
|
94
|
+
status: "fulfilled" | "rejected";
|
|
95
|
+
value?: unknown;
|
|
96
|
+
reason?: unknown;
|
|
97
|
+
}>): Array<unknown>;
|
|
98
|
+
/**
|
|
99
|
+
* Throws a Tantrum containing all rejection reasons from settled promises.
|
|
100
|
+
*
|
|
101
|
+
* @param {string} message - Error message. Defaults to "GIGO"
|
|
102
|
+
* @param {Array<{status: 'fulfilled'|'rejected', value?: unknown, reason?: unknown}>} settled - Array of settled promise results
|
|
103
|
+
* @throws {Tantrum} Throws a Tantrum error with rejection reasons
|
|
104
|
+
*/
|
|
105
|
+
static throw(message: string, settled: Array<{
|
|
106
|
+
status: "fulfilled" | "rejected";
|
|
107
|
+
value?: unknown;
|
|
108
|
+
reason?: unknown;
|
|
109
|
+
}>): void;
|
|
110
|
+
/**
|
|
111
|
+
* Returns the first promise to resolve or reject from an array of promises.
|
|
112
|
+
* Wrapper around Promise.race for consistency with other utility methods.
|
|
113
|
+
*
|
|
114
|
+
* @param {Array<Promise<unknown>>} promises - Array of promises to race
|
|
115
|
+
* @returns {Promise<unknown>} Result of the first settled promise
|
|
116
|
+
*/
|
|
117
|
+
static race(promises: Array<Promise<unknown>>): Promise<unknown>;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=Promised.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Promised.d.ts","sourceRoot":"","sources":["../../../browser/lib/Promised.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH;IACE;;;;;;OAMG;IACH,uBAHW,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GACrB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAInC;IAED;;;;;;OAMG;IACH,wBAHW,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GACrB,OAAO,CAAC,KAAK,CAAC;QAAC,MAAM,EAAE,WAAW,GAAC,UAAU,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAC,CAAC,CAAC,CAI/F;IAED;;;;;OAKG;IACH,4BAHW,KAAK,CAAC;QAAC,MAAM,EAAE,WAAW,GAAC,UAAU,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAC,CAAC,GACxE,OAAO,CAInB;IAED;;;;;OAKG;IACH,6BAHW,KAAK,CAAC;QAAC,MAAM,E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AAC,CAAC,QAQpF;IAED;;;;;;OAMG;IACH,sBAHW,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GACrB,OAAO,CAAC,OAAO,CAAC,CAI5B;CACF"}
|
|
@@ -39,73 +39,6 @@ export default class Util {
|
|
|
39
39
|
* @returns {string} Padded string with text centred.
|
|
40
40
|
*/
|
|
41
41
|
static centreAlignText(text: string | number, width?: number): string;
|
|
42
|
-
/**
|
|
43
|
-
* Asynchronously awaits all promises in parallel.
|
|
44
|
-
* Wrapper around Promise.all for consistency with other utility methods.
|
|
45
|
-
*
|
|
46
|
-
* @param {Array<Promise<unknown>>} promises - Array of promises to await
|
|
47
|
-
* @returns {Promise<Array<unknown>>} Results of all promises
|
|
48
|
-
*/
|
|
49
|
-
static awaitAll(promises: Array<Promise<unknown>>): Promise<Array<unknown>>;
|
|
50
|
-
/**
|
|
51
|
-
* Settles all promises (both fulfilled and rejected) in parallel.
|
|
52
|
-
* Wrapper around Promise.allSettled for consistency with other utility methods.
|
|
53
|
-
*
|
|
54
|
-
* @param {Array<Promise<unknown>>} promises - Array of promises to settle
|
|
55
|
-
* @returns {Promise<Array<object>>} Results of all settled promises with status and value/reason
|
|
56
|
-
*/
|
|
57
|
-
static settleAll(promises: Array<Promise<unknown>>): Promise<Array<object>>;
|
|
58
|
-
/**
|
|
59
|
-
* Checks if any result in the settled promise array is rejected.
|
|
60
|
-
*
|
|
61
|
-
* @param {Array<object>} result - Array of settled promise results.
|
|
62
|
-
* @returns {boolean} True if any result is rejected, false otherwise.
|
|
63
|
-
*/
|
|
64
|
-
static anyRejected(result: Array<object>): boolean;
|
|
65
|
-
/**
|
|
66
|
-
* Filters and returns all rejected results from a settled promise array.
|
|
67
|
-
*
|
|
68
|
-
* @param {Array<object>} result - Array of settled promise results.
|
|
69
|
-
* @returns {Array<object>} Array of rejected results.
|
|
70
|
-
*/
|
|
71
|
-
static settledAndRejected(result: Array<object>): Array<object>;
|
|
72
|
-
/**
|
|
73
|
-
* Extracts the rejection reasons from an array of rejected promise results.
|
|
74
|
-
*
|
|
75
|
-
* @param {Array<object>} rejected - Array of rejected results.
|
|
76
|
-
* @returns {Array<unknown>} Array of rejection reasons.
|
|
77
|
-
*/
|
|
78
|
-
static rejectedReasons(rejected: Array<object>): Array<unknown>;
|
|
79
|
-
/**
|
|
80
|
-
* Throws a Sass error containing all rejection reasons from settled promises.
|
|
81
|
-
*
|
|
82
|
-
* @param {string} [_message] - Optional error message. Defaults to "GIGO"
|
|
83
|
-
* @param {Array<object>} rejected - Array of rejected results.
|
|
84
|
-
* @throws {Error} Throws a Tantrum error with rejection reasons.
|
|
85
|
-
*/
|
|
86
|
-
static throwRejected(message: string, settled: any): void;
|
|
87
|
-
/**
|
|
88
|
-
* Filters and returns all fulfilled results from a settled promise array.
|
|
89
|
-
*
|
|
90
|
-
* @param {Array<object>} result - Array of settled promise results.
|
|
91
|
-
* @returns {Array<object>} Array of fulfilled results.
|
|
92
|
-
*/
|
|
93
|
-
static settledAndFulfilled(result: Array<object>): Array<object>;
|
|
94
|
-
/**
|
|
95
|
-
* Extracts the values from all fulfilled results in a settled promise array.
|
|
96
|
-
*
|
|
97
|
-
* @param {Array<object>} result - Array of settled promise results.
|
|
98
|
-
* @returns {Array<unknown>} Array of fulfilled values.
|
|
99
|
-
*/
|
|
100
|
-
static fulfilledValues(result: Array<object>): Array<unknown>;
|
|
101
|
-
/**
|
|
102
|
-
* Returns the first promise to resolve or reject from an array of promises.
|
|
103
|
-
* Wrapper around Promise.race for consistency with other utility methods.
|
|
104
|
-
*
|
|
105
|
-
* @param {Array<Promise<unknown>>} promises - Array of promises to race
|
|
106
|
-
* @returns {Promise<unknown>} Result of the first settled promise
|
|
107
|
-
*/
|
|
108
|
-
static race(promises: Array<Promise<unknown>>): Promise<unknown>;
|
|
109
42
|
/**
|
|
110
43
|
* Determine the Levenshtein distance between two string values
|
|
111
44
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Util.d.ts","sourceRoot":"","sources":["../../../browser/lib/Util.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Util.d.ts","sourceRoot":"","sources":["../../../browser/lib/Util.js"],"names":[],"mappings":"AAGA;;;GAGG;AACH;IACE;;;;;OAKG;IACH,wBAHW,MAAM,GACJ,MAAM,CAYlB;IAED;;;;;;OAMG;IACH,YAJa,CAAC,MACH,MAAM,OAAO,CAAC,CAAC,CAAC,GACd,OAAO,CAAC;QAAC,MAAM,EAAE,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,CAAC,CAQ9C;IAED;;;;;;;OAOG;IACH,4BAJW,MAAM,GAAC,MAAM,UACb,MAAM,GACJ,MAAM,CAWlB;IAED;;;;;;;OAOG;IACH,6BAJW,MAAM,GAAC,MAAM,UACb,MAAM,GACJ,MAAM,CAalB;IAED;;;;;;OAMG;IACH,8BAJW,MAAM,KACN,MAAM,GACJ,MAAM,CAsBlB;IAED;;;;;;;;OAQG;IACH,+BALW,MAAM,iBACN,KAAK,CAAC,MAAM,CAAC,cACb,MAAM,GACJ,MAAM,CAwBlB;IAED,mEAiBC;CACF"}
|
package/src/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { default as Collection } from "./browser/lib/Collection.js";
|
|
2
2
|
export { default as Data } from "./browser/lib/Data.js";
|
|
3
|
+
export { default as Promised } from "./browser/lib/Promised.js";
|
|
3
4
|
export { default as Type } from "./browser/lib/TypeSpec.js";
|
|
4
5
|
export { default as Valid } from "./lib/Valid.js";
|
|
5
6
|
export { default as Sass } from "./lib/Sass.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileObject.d.ts","sourceRoot":"","sources":["../../lib/FileObject.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;GAcG;AAEH;
|
|
1
|
+
{"version":3,"file":"FileObject.d.ts","sourceRoot":"","sources":["../../lib/FileObject.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;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