@everyonesoftware/common 5.0.0 → 7.0.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/outputs/characterWriteStream-ogvZec-U.d.cts +798 -0
- package/outputs/characterWriteStream-ogvZec-U.d.ts +798 -0
- package/outputs/{chunk-AY3YWKOM.js → chunk-MMAX3IZF.js} +4911 -3470
- package/outputs/chunk-MMAX3IZF.js.map +1 -0
- package/outputs/chunk-VF6FBNAU.js +1062 -0
- package/outputs/chunk-VF6FBNAU.js.map +1 -0
- package/outputs/{sources.cjs → sourceIndex.cjs} +926 -560
- package/outputs/sourceIndex.cjs.map +1 -0
- package/outputs/{sources.d.cts → sourceIndex.d.cts} +457 -1160
- package/outputs/{sources.d.ts → sourceIndex.d.ts} +457 -1160
- package/outputs/sourceIndex.js +331 -0
- package/outputs/sourceIndex.js.map +1 -0
- package/outputs/testIndex.cjs +6522 -0
- package/outputs/testIndex.cjs.map +1 -0
- package/outputs/testIndex.d.cts +476 -0
- package/outputs/testIndex.d.ts +476 -0
- package/outputs/testIndex.js +26 -0
- package/outputs/testIndex.js.map +1 -0
- package/outputs/tests.cjs +13935 -12780
- package/outputs/tests.cjs.map +1 -1
- package/outputs/tests.js +2763 -3032
- package/outputs/tests.js.map +1 -1
- package/package.json +7 -7
- package/outputs/chunk-AY3YWKOM.js.map +0 -1
- package/outputs/sources.cjs.map +0 -1
- package/outputs/sources.js +0 -1370
- package/outputs/sources.js.map +0 -1
|
@@ -0,0 +1,798 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The result of comparing two values.
|
|
3
|
+
*/
|
|
4
|
+
declare enum Comparison {
|
|
5
|
+
/**
|
|
6
|
+
* The left value is less than the right value.
|
|
7
|
+
*/
|
|
8
|
+
LessThan = 0,
|
|
9
|
+
/**
|
|
10
|
+
* The two values are equal.
|
|
11
|
+
*/
|
|
12
|
+
Equal = 1,
|
|
13
|
+
/**
|
|
14
|
+
* The left value is greater than the right value.
|
|
15
|
+
*/
|
|
16
|
+
GreaterThan = 2
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* An type that can be compared against another type.
|
|
21
|
+
*/
|
|
22
|
+
declare abstract class Comparable<T> {
|
|
23
|
+
protected constructor();
|
|
24
|
+
/**
|
|
25
|
+
* Compare this value against the provided value.
|
|
26
|
+
* @param value The value to compare against.
|
|
27
|
+
*/
|
|
28
|
+
abstract compareTo(value: T): Comparison;
|
|
29
|
+
/**
|
|
30
|
+
* Get whether this value is less than the provided value.
|
|
31
|
+
* @param value The value to compare against.
|
|
32
|
+
*/
|
|
33
|
+
lessThan(value: T): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Get whether the left value is less than the right value.
|
|
36
|
+
* @param left The left value in the comparison.
|
|
37
|
+
* @param right The right value in the comparison.
|
|
38
|
+
*/
|
|
39
|
+
static lessThan<T>(left: Comparable<T>, right: T): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Get whether this value is less than or equal to the provided value.
|
|
42
|
+
* @param value The value to compare against.
|
|
43
|
+
*/
|
|
44
|
+
lessThanOrEqualTo(value: T): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Get whether the left value is less than or equal to the right value.
|
|
47
|
+
* @param left The left value in the comparison.
|
|
48
|
+
* @param right The right value in the comparison.
|
|
49
|
+
*/
|
|
50
|
+
static lessThanOrEqualTo<T>(left: Comparable<T>, right: T): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Get whether this value equals the provided value.
|
|
53
|
+
* @param value The value to compare against.
|
|
54
|
+
*/
|
|
55
|
+
equals(value: T): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Get whether the left value equals the right value.
|
|
58
|
+
* @param left The left value in the comparison.
|
|
59
|
+
* @param right The right value in the comparison.
|
|
60
|
+
*/
|
|
61
|
+
static equals<T>(left: Comparable<T>, right: T): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Get whether this value is not equal to the provided value.
|
|
64
|
+
* @param value The value to compare against.
|
|
65
|
+
*/
|
|
66
|
+
notEquals(value: T): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Get whether the left value is not equal to the right value.
|
|
69
|
+
* @param left The left value in the comparison.
|
|
70
|
+
* @param right The right value in the comparison.
|
|
71
|
+
*/
|
|
72
|
+
static notEquals<T>(left: Comparable<T>, right: T): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Get whether this value is greater than or equal to the provided value.
|
|
75
|
+
* @param value The value to compare against.
|
|
76
|
+
*/
|
|
77
|
+
greaterThanOrEqualTo(value: T): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Get whether the left value is greater than or equal to the right value.
|
|
80
|
+
* @param left The left value in the comparison.
|
|
81
|
+
* @param right The right value in the comparison.
|
|
82
|
+
*/
|
|
83
|
+
static greaterThanOrEqualTo<T>(left: Comparable<T>, right: T): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Get whether this value is greater than the provided value.
|
|
86
|
+
* @param value The value to compare against.
|
|
87
|
+
*/
|
|
88
|
+
greaterThan(value: T): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Get whether the left value is greater than the right value.
|
|
91
|
+
* @param left The left value in the comparison.
|
|
92
|
+
* @param right The right value in the comparison.
|
|
93
|
+
*/
|
|
94
|
+
static greaterThan<T>(left: Comparable<T>, right: T): boolean;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
declare class PromiseAsyncResult<T> implements AsyncResult<T> {
|
|
98
|
+
private readonly promise;
|
|
99
|
+
private constructor();
|
|
100
|
+
static create<T>(actionOrPromise: (() => (T | Promise<T>)) | Promise<T>): PromiseAsyncResult<T>;
|
|
101
|
+
static empty(): PromiseAsyncResult<void>;
|
|
102
|
+
static value<T>(value: T): PromiseAsyncResult<T>;
|
|
103
|
+
static error<T>(error: unknown): PromiseAsyncResult<T>;
|
|
104
|
+
static yield(): PromiseAsyncResult<void>;
|
|
105
|
+
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): PromiseAsyncResult<TResult1 | TResult2>;
|
|
106
|
+
onValue(onValueFunction: (value: T) => (void | Promise<void>)): PromiseAsyncResult<T>;
|
|
107
|
+
catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): PromiseAsyncResult<T | TResult>;
|
|
108
|
+
catch<TError, TResult = never>(errorType: Type<TError>, onrejected: (reason: TError) => (TResult | PromiseLike<TResult>)): PromiseAsyncResult<T | TResult>;
|
|
109
|
+
onError(onErrorFunction: (reason: unknown) => (void | PromiseLike<void>)): PromiseAsyncResult<T>;
|
|
110
|
+
onError<TError>(errorType: Type<TError>, onErrorFunction: (reason: TError) => (void | PromiseLike<void>)): PromiseAsyncResult<T>;
|
|
111
|
+
convertError(convertErrorFunction: (reason: unknown) => (unknown | PromiseLike<unknown>)): PromiseAsyncResult<T>;
|
|
112
|
+
convertError<TError>(errorType: Type<TError>, convertErrorFunction: (reason: TError) => (unknown | PromiseLike<unknown>)): PromiseAsyncResult<T>;
|
|
113
|
+
finally(onfinally?: (() => (void | Promise<void>)) | null): PromiseAsyncResult<T>;
|
|
114
|
+
readonly [Symbol.toStringTag]: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
declare class SyncResult<T> implements AsyncResult<T> {
|
|
118
|
+
private value;
|
|
119
|
+
private error;
|
|
120
|
+
private constructor();
|
|
121
|
+
static create<T>(action: () => T): SyncResult<T>;
|
|
122
|
+
static value<T>(value: T): SyncResult<T>;
|
|
123
|
+
static error<T>(error: unknown): SyncResult<T>;
|
|
124
|
+
await(): T;
|
|
125
|
+
then<TResult1 = T, TResult2 = never>(onfullfilled?: ((value: T) => TResult1) | null, onrejected?: ((reason: unknown) => TResult2) | null): SyncResult<TResult1 | TResult2>;
|
|
126
|
+
then<TResult1 = T, TResult2 = never>(onfullfilled?: ((value: T) => (TResult1 | PromiseLike<TResult1>)) | null, onrejected?: ((reason: unknown) => (TResult2 | PromiseLike<TResult2>)) | null): SyncResult<TResult1 | TResult2>;
|
|
127
|
+
onValue(onValueFunction: (value: T) => void): SyncResult<T>;
|
|
128
|
+
onValue(onValueFunction: (value: T) => Promise<void>): PromiseAsyncResult<T>;
|
|
129
|
+
catch<TResult = never>(onrejected: (reason: unknown) => TResult): SyncResult<T | TResult>;
|
|
130
|
+
catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): SyncResult<T | TResult> | PromiseAsyncResult<T | TResult>;
|
|
131
|
+
catch<TError, TResult = never>(errorType: Type<TError>, onrejected: (reason: TError) => TResult): SyncResult<T | TResult>;
|
|
132
|
+
catch<TError, TResult = never>(errorType: Type<TError>, onrejected: (reason: TError) => PromiseLike<TResult>): PromiseAsyncResult<T | TResult>;
|
|
133
|
+
onError(onErrorFunction: (reason: unknown) => void): SyncResult<T>;
|
|
134
|
+
onError(onErrorFunction: (reason: unknown) => PromiseLike<void>): PromiseAsyncResult<T>;
|
|
135
|
+
onError<TError>(errorType: Type<TError>, onErrorFunction: (reason: TError) => void): SyncResult<T>;
|
|
136
|
+
onError<TError>(errorType: Type<TError>, onErrorFunction: (reason: TError) => PromiseLike<void>): PromiseAsyncResult<T>;
|
|
137
|
+
convertError(convertErrorFunction: (reason: unknown) => unknown): SyncResult<T>;
|
|
138
|
+
convertError(onErrorFunction: (reason: unknown) => PromiseLike<unknown>): PromiseAsyncResult<T>;
|
|
139
|
+
convertError<TError>(errorType: Type<TError>, convertErrorFunction: (reason: TError) => unknown): SyncResult<T>;
|
|
140
|
+
convertError<TError>(errorType: Type<TError>, convertErrorFunction: (reason: TError) => PromiseLike<unknown>): PromiseAsyncResult<T>;
|
|
141
|
+
finally(onfinally?: (() => void) | null): SyncResult<T>;
|
|
142
|
+
finally(onfinally?: (() => Promise<void>) | null): PromiseAsyncResult<T>;
|
|
143
|
+
readonly [Symbol.toStringTag]: string;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* A collection of {@link Function}s that can be used to determine if two values are equal.
|
|
148
|
+
*/
|
|
149
|
+
declare class EqualFunctions {
|
|
150
|
+
private readonly equalFunctions;
|
|
151
|
+
private constructor();
|
|
152
|
+
static create(): EqualFunctions;
|
|
153
|
+
private defaultEqualFunction;
|
|
154
|
+
/**
|
|
155
|
+
* Get whether the provided values are equal based on the registered equal {@link Function}s.
|
|
156
|
+
* @param left The left value in the comparison.
|
|
157
|
+
* @param right The right value in the comparison.
|
|
158
|
+
*/
|
|
159
|
+
areEqual(left: unknown, right: unknown): SyncResult<boolean>;
|
|
160
|
+
add(equalFunction: (left: unknown, right: unknown) => (boolean | undefined)): this;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* The built-in {@link Array} type.
|
|
165
|
+
*
|
|
166
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
|
|
167
|
+
*/
|
|
168
|
+
type JavascriptArray<T> = Array<T>;
|
|
169
|
+
/**
|
|
170
|
+
* The built-in {@link Iterator} type.
|
|
171
|
+
*
|
|
172
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators#iterators
|
|
173
|
+
*/
|
|
174
|
+
type JavascriptIterator<T> = Iterator<T>;
|
|
175
|
+
/**
|
|
176
|
+
* The built-in {@link IteratorResult} type.
|
|
177
|
+
*/
|
|
178
|
+
type JavascriptIteratorResult<T> = IteratorResult<T, T>;
|
|
179
|
+
/**
|
|
180
|
+
* The built-in {@link Iterable} type.
|
|
181
|
+
*
|
|
182
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators#iterables
|
|
183
|
+
*/
|
|
184
|
+
type JavascriptIterable<T> = Iterable<T>;
|
|
185
|
+
/**
|
|
186
|
+
* The built-in {@link Map} type.
|
|
187
|
+
*
|
|
188
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
|
|
189
|
+
*/
|
|
190
|
+
type JavascriptMap<TKey, TValue> = Map<TKey, TValue>;
|
|
191
|
+
/**
|
|
192
|
+
* The built-in {@link Map} type.
|
|
193
|
+
*
|
|
194
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
|
|
195
|
+
*/
|
|
196
|
+
declare const JavascriptMap: MapConstructor;
|
|
197
|
+
/**
|
|
198
|
+
* The built-in {@link AsyncIterator} type.
|
|
199
|
+
*
|
|
200
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncIterator
|
|
201
|
+
*/
|
|
202
|
+
type JavascriptAsyncIterator<T> = AsyncIterator<T>;
|
|
203
|
+
interface JavascriptAsyncIterable<T> {
|
|
204
|
+
[Symbol.asyncIterator](): JavascriptAsyncIterator<T>;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* The built-in {@link Set} type.
|
|
208
|
+
*
|
|
209
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
210
|
+
*/
|
|
211
|
+
type JavascriptSet<T> = Set<T>;
|
|
212
|
+
declare const JavascriptSet: SetConstructor;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* A type that can be used to iterate over a collection.
|
|
216
|
+
*/
|
|
217
|
+
declare abstract class Iterator$1<T> implements JavascriptIterable<T> {
|
|
218
|
+
/**
|
|
219
|
+
* Create a new {@link Iterator} that contains the provided values.
|
|
220
|
+
* @param values The values that the new {@link Iterator} will iterate over.
|
|
221
|
+
*/
|
|
222
|
+
static create<T>(values: JavascriptIterator<T> | JavascriptIterable<T>): Iterator$1<T>;
|
|
223
|
+
/**
|
|
224
|
+
* Move to the next value in the collection. Return whether this {@link Iterator} points to a
|
|
225
|
+
* value after the move.
|
|
226
|
+
*/
|
|
227
|
+
abstract next(): SyncResult<boolean>;
|
|
228
|
+
/**
|
|
229
|
+
* Get whether this {@link Iterator} has started iterating over the values in the collection.
|
|
230
|
+
*/
|
|
231
|
+
abstract hasStarted(): boolean;
|
|
232
|
+
/**
|
|
233
|
+
* Get whether this {@link Iterator} currently points at a value in the collection.
|
|
234
|
+
*/
|
|
235
|
+
abstract hasCurrent(): boolean;
|
|
236
|
+
/**
|
|
237
|
+
* Get the value that this {@link Iterator} points to.
|
|
238
|
+
*/
|
|
239
|
+
abstract getCurrent(): T;
|
|
240
|
+
/**
|
|
241
|
+
* Move to the first value if this {@link Iterator} hasn't started yet.
|
|
242
|
+
* @returns This object for method chaining.
|
|
243
|
+
*/
|
|
244
|
+
start(): SyncResult<this>;
|
|
245
|
+
/**
|
|
246
|
+
* Move the provided {@link Iterator} to its first value if it hasn't started yet.
|
|
247
|
+
*/
|
|
248
|
+
static start<T, TIterator extends Iterator$1<T>>(iterator: TIterator): SyncResult<TIterator>;
|
|
249
|
+
/**
|
|
250
|
+
* Get the current value from this {@link Iterator} and advance this {@link Iterator} to the
|
|
251
|
+
* next value.
|
|
252
|
+
*/
|
|
253
|
+
takeCurrent(): SyncResult<T>;
|
|
254
|
+
static takeCurrent<T>(iterator: Iterator$1<T>): SyncResult<T>;
|
|
255
|
+
[Symbol.iterator](): JavascriptIterator<T>;
|
|
256
|
+
/**
|
|
257
|
+
* Convert the provided {@link Iterator} to a {@link IteratorToJavascriptIteratorAdapter}.
|
|
258
|
+
* @param iterator The {@link Iterator} to convert.
|
|
259
|
+
*/
|
|
260
|
+
static [Symbol.iterator]<T>(iterator: Iterator$1<T>): JavascriptIterator<T>;
|
|
261
|
+
/**
|
|
262
|
+
* Get whether this {@link Iterator} contains any values.
|
|
263
|
+
* Note: This may advance the {@link Iterator} to the first value if it hasn't been
|
|
264
|
+
* started yet.
|
|
265
|
+
*/
|
|
266
|
+
any(): SyncResult<boolean>;
|
|
267
|
+
/**
|
|
268
|
+
* Get whether this {@link Iterator} contains any values.
|
|
269
|
+
* Note: This may advance the {@link Iterator} to the first value if it hasn't been
|
|
270
|
+
* started yet.
|
|
271
|
+
*/
|
|
272
|
+
static any<T>(iterator: Iterator$1<T>): SyncResult<boolean>;
|
|
273
|
+
/**
|
|
274
|
+
* Get the number of values in this {@link Iterator}.
|
|
275
|
+
* Note: This will consume all of the values in this {@link Iterator}.
|
|
276
|
+
*/
|
|
277
|
+
getCount(): SyncResult<number>;
|
|
278
|
+
/**
|
|
279
|
+
* Get the number of values in the provided {@link Iterator}.
|
|
280
|
+
* Note: This will consume all of the values in the provided {@link Iterator}.
|
|
281
|
+
*/
|
|
282
|
+
static getCount<T>(iterator: Iterator$1<T>): SyncResult<number>;
|
|
283
|
+
/**
|
|
284
|
+
* Get all of the remaining values in this {@link Iterator} in a {@link T} {@link Array}.
|
|
285
|
+
*/
|
|
286
|
+
toArray(): SyncResult<T[]>;
|
|
287
|
+
/**
|
|
288
|
+
* Get all of the remaining values in the provided {@link Iterator} in a {@link T}
|
|
289
|
+
* {@link Array}.
|
|
290
|
+
*/
|
|
291
|
+
static toArray<T>(iterator: Iterator$1<T>): SyncResult<T[]>;
|
|
292
|
+
concatenate(...toConcatenate: JavascriptIterable<T>[]): Iterator$1<T>;
|
|
293
|
+
static concatenate<T>(iterator: Iterator$1<T>, ...toConcatenate: JavascriptIterable<T>[]): Iterator$1<T>;
|
|
294
|
+
/**
|
|
295
|
+
* Get an {@link Iterator} that will only return values that match the provided condition.
|
|
296
|
+
* @param condition The condition to run against each of the values in this {@link Iterator}.
|
|
297
|
+
*/
|
|
298
|
+
where(condition: (value: T) => (boolean | SyncResult<boolean>)): Iterator$1<T>;
|
|
299
|
+
static where<T>(iterator: Iterator$1<T>, condition: (value: T) => (boolean | SyncResult<boolean>)): Iterator$1<T>;
|
|
300
|
+
/**
|
|
301
|
+
* Get a {@link MapIterator} that will map all {@link T} values from this {@link Iterator} to
|
|
302
|
+
* {@link TOutput} values.
|
|
303
|
+
* @param mapping The mapping that maps {@link T} values to {@link TOutput} values.
|
|
304
|
+
*/
|
|
305
|
+
map<TOutput>(mapping: (value: T) => (TOutput | SyncResult<TOutput>)): Iterator$1<TOutput>;
|
|
306
|
+
static map<T, TOutput>(iterator: Iterator$1<T>, mapping: (value: T) => (TOutput | SyncResult<TOutput>)): Iterator$1<TOutput>;
|
|
307
|
+
flatMap<TOutput>(mapping: (value: T) => JavascriptIterable<TOutput>): Iterator$1<TOutput>;
|
|
308
|
+
static flatMap<T, TOutput>(iterator: Iterator$1<T>, mapping: (value: T) => JavascriptIterable<TOutput>): Iterator$1<TOutput>;
|
|
309
|
+
/**
|
|
310
|
+
* Get an {@link Iterator} that will filter this {@link Iterator} to only the values that are
|
|
311
|
+
* instances of {@link U} based on the provided type check {@link Function}.
|
|
312
|
+
* @param typeCheck The {@link Function} that will be used to determine if values are of type
|
|
313
|
+
* {@link U}.
|
|
314
|
+
*/
|
|
315
|
+
whereInstanceOf<U extends T>(typeCheck: (value: T) => value is U): Iterator$1<U>;
|
|
316
|
+
static whereInstanceOf<T, U extends T>(iterator: Iterator$1<T>, typeCheck: (value: T) => value is U): Iterator$1<U>;
|
|
317
|
+
/**
|
|
318
|
+
* Get an {@link Iterator} that will filter this {@link Iterator} to only the values that are
|
|
319
|
+
* instances of the provided {@link Type}.
|
|
320
|
+
* @param type The type of values to return from the new {@link Iterator}.
|
|
321
|
+
*/
|
|
322
|
+
whereInstanceOfType<U extends T>(type: Type<U>): Iterator$1<U>;
|
|
323
|
+
static whereInstanceOfType<T, U extends T>(iterator: Iterator$1<T>, type: Type<U>): Iterator$1<U>;
|
|
324
|
+
/**
|
|
325
|
+
* If the condition function is undefined, then this function will return the first value in
|
|
326
|
+
* this {@link Iterator}. If this condition function is provided, then this function will return
|
|
327
|
+
* the first value that matches the provided condition.
|
|
328
|
+
* @param condition The condition that the returned value must satisfy.
|
|
329
|
+
*/
|
|
330
|
+
first(condition?: (value: T) => (boolean | SyncResult<boolean>)): SyncResult<T>;
|
|
331
|
+
/**
|
|
332
|
+
* If the condition function is undefined, then this function will return the first value in
|
|
333
|
+
* the {@link Iterator}. If this condition function is provided, then this function will return
|
|
334
|
+
* the first value that matches the provided condition.
|
|
335
|
+
* @param iterator The {@link Iterator} to get the first value from.
|
|
336
|
+
*/
|
|
337
|
+
static first<T>(iterator: Iterator$1<T>, condition?: (value: T) => (boolean | SyncResult<boolean>)): SyncResult<T>;
|
|
338
|
+
/**
|
|
339
|
+
* If the condition function is undefined, then this function will return the last value in this
|
|
340
|
+
* {@link Iterator}. If this condition function is provided, then this function will return the
|
|
341
|
+
* last value that matches the provided condition.
|
|
342
|
+
* @param condition The condition that the returned value must satisfy.
|
|
343
|
+
*/
|
|
344
|
+
last(condition?: (value: T) => (boolean | SyncResult<boolean>)): SyncResult<T>;
|
|
345
|
+
/**
|
|
346
|
+
* If the condition function is undefined, then this function will return the last value in the
|
|
347
|
+
* {@link Iterator}. If this condition function is provided, then this function will return the
|
|
348
|
+
* last value that matches the provided condition.
|
|
349
|
+
* @param iterator The {@link Iterator} to get the last value from.
|
|
350
|
+
*/
|
|
351
|
+
static last<T>(iterator: Iterator$1<T>, condition?: (value: T) => (boolean | SyncResult<boolean>)): SyncResult<T>;
|
|
352
|
+
/**
|
|
353
|
+
* Find the maximum value in the provided {@link Iterator}.
|
|
354
|
+
* @param iterator The values to find the maximum of.
|
|
355
|
+
*/
|
|
356
|
+
static findMaximum<T extends Comparable<T>>(iterator: JavascriptIterator<T> | Iterator$1<T>): SyncResult<T>;
|
|
357
|
+
/**
|
|
358
|
+
* Get a new {@link Iterator} that wraps around this {@link Iterator} and only
|
|
359
|
+
* returns a maximum number of values from this {@link Iterator}.
|
|
360
|
+
* @param maximumToTake The maximum number of values to take from this {@link Iterator}.
|
|
361
|
+
*/
|
|
362
|
+
take(maximumToTake: number): Iterator$1<T>;
|
|
363
|
+
static take<T>(iterator: Iterator$1<T>, maximumToTake: number): Iterator$1<T>;
|
|
364
|
+
/**
|
|
365
|
+
* Get a new {@link Iterator} that wraps around this {@link Iterator} and will skip the initial
|
|
366
|
+
* provided number of values before beginning to return values.
|
|
367
|
+
* @param maximumToSkip The maximum number of values to skip from this {@link Iterator}.
|
|
368
|
+
*/
|
|
369
|
+
skip(maximumToSkip: number): Iterator$1<T>;
|
|
370
|
+
static skip<T>(iterator: Iterator$1<T>, maximumToSkip: number): Iterator$1<T>;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* A collection of {@link ToStringFunction}s.
|
|
375
|
+
*/
|
|
376
|
+
declare class ToStringFunctions {
|
|
377
|
+
private readonly functions;
|
|
378
|
+
private constructor();
|
|
379
|
+
static create(): ToStringFunctions;
|
|
380
|
+
private defaultToString;
|
|
381
|
+
/**
|
|
382
|
+
* Get the {@link String} representation of the value with the registered
|
|
383
|
+
* {@link ToStringFunction}s.
|
|
384
|
+
* @param value The value to get the {@link String} representation of.
|
|
385
|
+
*/
|
|
386
|
+
toString(value: unknown): string;
|
|
387
|
+
add(toStringFunction: (value: unknown) => (string | undefined)): this;
|
|
388
|
+
add<T>(typeCheckFunction: (value: unknown) => value is T, typedToStringFunction: (value: T) => string): this;
|
|
389
|
+
private iterableToString;
|
|
390
|
+
private mapToString;
|
|
391
|
+
private setToString;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* An object that can be iterated over.
|
|
396
|
+
*/
|
|
397
|
+
declare abstract class Iterable$1<T> implements JavascriptIterable<T> {
|
|
398
|
+
static create<T>(values?: JavascriptIterable<T>): Iterable$1<T>;
|
|
399
|
+
/**
|
|
400
|
+
* Iterate over the values in this {@link Iterable}.
|
|
401
|
+
*/
|
|
402
|
+
abstract iterate(): Iterator$1<T>;
|
|
403
|
+
[Symbol.iterator](): JavascriptIterator<T>;
|
|
404
|
+
static [Symbol.iterator]<T>(iterable: Iterable$1<T>): JavascriptIterator<T>;
|
|
405
|
+
/**
|
|
406
|
+
* Get all of the values in this {@link Iterable} in an {@link Array}.
|
|
407
|
+
*/
|
|
408
|
+
toArray(): SyncResult<T[]>;
|
|
409
|
+
/**
|
|
410
|
+
* Get all of the values in the provided {@link Iterable} in an {@link Array}.
|
|
411
|
+
*/
|
|
412
|
+
static toArray<T>(iterable: Iterable$1<T>): SyncResult<T[]>;
|
|
413
|
+
/**
|
|
414
|
+
* Get whether this {@link Iterable} contains any values.
|
|
415
|
+
*/
|
|
416
|
+
any(): SyncResult<boolean>;
|
|
417
|
+
/**
|
|
418
|
+
* Get whether the provided {@link JavascriptIterable} contains any values.
|
|
419
|
+
*/
|
|
420
|
+
static any<T>(iterable: JavascriptIterable<T>): SyncResult<boolean>;
|
|
421
|
+
/**
|
|
422
|
+
* Get the number of values in this {@link Iterable}.
|
|
423
|
+
*/
|
|
424
|
+
getCount(): SyncResult<number>;
|
|
425
|
+
/**
|
|
426
|
+
* Get the number of values in the provided {@link Iterable}.
|
|
427
|
+
*/
|
|
428
|
+
static getCount<T>(iterable: Iterable$1<T>): SyncResult<number>;
|
|
429
|
+
/**
|
|
430
|
+
* Get whether this {@link Iterable} is equal to the provided {@link Iterable}.
|
|
431
|
+
* @param right The {@link Iterable} to compare against this {@link Iterable}.
|
|
432
|
+
* @param equalFunctions The optional {@link EqualFunctions} to use to determine if the two
|
|
433
|
+
* {@link Iterable}s are equal.
|
|
434
|
+
*/
|
|
435
|
+
equals(right: JavascriptIterable<T>, equalFunctions?: EqualFunctions): SyncResult<boolean>;
|
|
436
|
+
static equals<T>(left: JavascriptIterable<T>, right: JavascriptIterable<T>, equalFunctions?: EqualFunctions): SyncResult<boolean>;
|
|
437
|
+
/**
|
|
438
|
+
* Get the {@link String} representation of this {@link Iterable}.
|
|
439
|
+
*/
|
|
440
|
+
toString(toStringFunctions?: ToStringFunctions): string;
|
|
441
|
+
/**
|
|
442
|
+
* Get the {@link String} representation of the provided {@link Iterable}.
|
|
443
|
+
*/
|
|
444
|
+
static toString<T>(iterable: Iterable$1<T>, toStringFunctions?: ToStringFunctions): string;
|
|
445
|
+
concatenate(...toConcatenate: JavascriptIterable<T>[]): Iterable$1<T>;
|
|
446
|
+
static concatenate<T>(iterable: Iterable$1<T>, ...toConcatenate: JavascriptIterable<T>[]): Iterable$1<T>;
|
|
447
|
+
/**
|
|
448
|
+
* Get a {@link MapIterable} that maps all of the {@link T} values in this {@link Iterable} to
|
|
449
|
+
* {@link TOutput} values.
|
|
450
|
+
* @param mapping The mapping function to use to convert values of type {@link T} to
|
|
451
|
+
* {@link TOutput}.
|
|
452
|
+
*/
|
|
453
|
+
map<TOutput>(mapping: (value: T) => (TOutput | SyncResult<TOutput>)): Iterable$1<TOutput>;
|
|
454
|
+
/**
|
|
455
|
+
* Get a {@link MapIterable} that maps all of the {@link T} values in the provided
|
|
456
|
+
* {@link Iterable} to {@link TOutput} values.
|
|
457
|
+
* @param mapping The mapping function to use to convert values of type {@link T} to
|
|
458
|
+
* {@link TOutput}.
|
|
459
|
+
*/
|
|
460
|
+
static map<TInput, TOutput>(iterable: Iterable$1<TInput>, mapping: (value: TInput) => (TOutput | SyncResult<TOutput>)): Iterable$1<TOutput>;
|
|
461
|
+
flatMap<TOutput>(mapping: (value: T) => JavascriptIterable<TOutput>): Iterable$1<TOutput>;
|
|
462
|
+
static flatMap<T, TOutput>(iterable: Iterable$1<T>, mapping: (value: T) => JavascriptIterable<TOutput>): Iterable$1<TOutput>;
|
|
463
|
+
/**
|
|
464
|
+
* Get an {@link Iterable} that contains values from this {@link Iterable} that match the
|
|
465
|
+
* provided condition.
|
|
466
|
+
* @param condition The condition to run against each of the values in this {@link Iterable}.
|
|
467
|
+
*/
|
|
468
|
+
where(condition: (value: T) => (boolean | SyncResult<boolean>)): Iterable$1<T>;
|
|
469
|
+
/**
|
|
470
|
+
* Get an {@link Iterable} that contains values from the provided {@link Iterable} that match
|
|
471
|
+
* the provided condition.
|
|
472
|
+
* @param iterable The {@link Iterable} to get values from.
|
|
473
|
+
* @param condition The condition that the values must match to be contained in the new
|
|
474
|
+
* {@link Iterable}.
|
|
475
|
+
*/
|
|
476
|
+
static where<T>(iterable: JavascriptIterable<T>, condition: (value: T) => (boolean | SyncResult<boolean>)): Iterable$1<T>;
|
|
477
|
+
/**
|
|
478
|
+
* Get an {@link Iterable} that contains values from this {@link Iterable} that match the
|
|
479
|
+
* provided {@link Type} or type check function.
|
|
480
|
+
* @param typeOrTypeCheck The {@link Type} or type check function that returned values must
|
|
481
|
+
* match.
|
|
482
|
+
*/
|
|
483
|
+
instanceOf<TOutput extends T>(typeOrTypeCheck: Type<TOutput> | ((value: T) => value is TOutput)): Iterable$1<TOutput>;
|
|
484
|
+
/**
|
|
485
|
+
* Get an {@link Iterable} that contains values from the provided {@link Iterable} that match
|
|
486
|
+
* the provided {@link Type} or type check function.
|
|
487
|
+
* @param iterable The {@link Iterable} to get values from.
|
|
488
|
+
* @param typeOrTypeCheck The {@link Type} or type check function that returned values must
|
|
489
|
+
* match.
|
|
490
|
+
*/
|
|
491
|
+
static instanceOf<TInput, TOutput extends TInput>(iterable: JavascriptIterable<TInput>, typeOrTypeCheck: Type<TOutput> | ((value: TInput) => value is TOutput)): Iterable$1<TOutput>;
|
|
492
|
+
/**
|
|
493
|
+
* Get the first value in this {@link Iterable}.
|
|
494
|
+
*/
|
|
495
|
+
first(condition?: (value: T) => (boolean | SyncResult<boolean>)): SyncResult<T>;
|
|
496
|
+
/**
|
|
497
|
+
* Get the first value from the provided {@link JavascriptIterable}.
|
|
498
|
+
* @param iterable The {@link JavascriptIterable} to get the first value from.
|
|
499
|
+
*/
|
|
500
|
+
static first<T>(iterable: JavascriptIterable<T>, condition?: (value: T) => (boolean | SyncResult<boolean>)): SyncResult<T>;
|
|
501
|
+
/**
|
|
502
|
+
* Get the last value in this {@link Iterable}.
|
|
503
|
+
*/
|
|
504
|
+
last(condition?: (value: T) => (boolean | SyncResult<boolean>)): SyncResult<T>;
|
|
505
|
+
/**
|
|
506
|
+
* Get the last value from the provided {@link JavascriptIterable}.
|
|
507
|
+
* @param iterable The {@link JavascriptIterable} to get the last value from.
|
|
508
|
+
*/
|
|
509
|
+
static last<T>(iterable: JavascriptIterable<T>, condition?: (value: T) => (boolean | SyncResult<boolean>)): SyncResult<T>;
|
|
510
|
+
/**
|
|
511
|
+
* Find the maximum value in the provided {@link Iterable}.
|
|
512
|
+
* @param iterable The values to find the maximum of.
|
|
513
|
+
*/
|
|
514
|
+
static findMaximum<T extends Comparable<T>>(iterable: JavascriptIterable<T> | Iterable$1<T>): SyncResult<T>;
|
|
515
|
+
contains(value: T, equalFunctions?: EqualFunctions): SyncResult<boolean>;
|
|
516
|
+
static contains<T>(iterable: Iterable$1<T>, value: T, equalFunctions?: EqualFunctions): SyncResult<boolean>;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* A {@link Type} that can be used to pass types as parameters.
|
|
521
|
+
*/
|
|
522
|
+
type Type<T> = Function & {
|
|
523
|
+
prototype: T;
|
|
524
|
+
};
|
|
525
|
+
/**
|
|
526
|
+
* Get whether the provided value is an instance of {@link Type} {@link T}.
|
|
527
|
+
* @param typeOrTypeCheck The {@link Type} to look for or type check {@link Function} to determine
|
|
528
|
+
* if the provided value is a {@link T}.
|
|
529
|
+
* @param value The value to check.
|
|
530
|
+
*/
|
|
531
|
+
declare function instanceOf<T>(value: unknown, typeCheck: (value: unknown) => value is T): value is T;
|
|
532
|
+
/**
|
|
533
|
+
* Get whether the provided value is an instance of {@link Type} {@link T}.
|
|
534
|
+
* @param typeOrTypeCheck The {@link Type} to look for or type check {@link Function} to determine
|
|
535
|
+
* if the provided value is a {@link T}.
|
|
536
|
+
* @param value The value to check.
|
|
537
|
+
*/
|
|
538
|
+
declare function instanceOf<T>(value: unknown, type: Type<T>, typeCheck?: (value: unknown) => value is T): value is T;
|
|
539
|
+
/**
|
|
540
|
+
* Get whether the provided value is an instance of the provided {@link Type}. This will return
|
|
541
|
+
* false if value only implements the provided {@link Type} but doesn't extend it.
|
|
542
|
+
* @param value The value to check.
|
|
543
|
+
* @param type The {@link Type} to see if value is an instance of.
|
|
544
|
+
*/
|
|
545
|
+
declare function instanceOfType<T>(value: unknown, type: Type<T>): value is T;
|
|
546
|
+
/**
|
|
547
|
+
* If the provided {@link value} is of type {@link T} (according to the provided {@link typeCheck}),
|
|
548
|
+
* then return the {@link value}. Otherwise return undefined.
|
|
549
|
+
* @param value The value to check.
|
|
550
|
+
* @param typeOrTypeCheck The {@link Type} to look for or type check {@link Function} to determine
|
|
551
|
+
* if the provided value is a {@link T}.
|
|
552
|
+
*/
|
|
553
|
+
declare function as<T>(value: unknown, typeOrTypeCheck: Type<T> | ((value: unknown) => value is T)): T | undefined;
|
|
554
|
+
/**
|
|
555
|
+
* Get whether the provided value is undefined.
|
|
556
|
+
* @param value The value to check.
|
|
557
|
+
*/
|
|
558
|
+
declare function isUndefined(value: unknown): value is undefined;
|
|
559
|
+
/**
|
|
560
|
+
* Get whether the provided value is null.
|
|
561
|
+
* @param value The value to check.
|
|
562
|
+
*/
|
|
563
|
+
declare function isNull(value: unknown): value is null;
|
|
564
|
+
/**
|
|
565
|
+
* Return the provided value if it is null, otherwise return undefined.
|
|
566
|
+
* @param value The value to check.
|
|
567
|
+
*/
|
|
568
|
+
declare function asNull(value: unknown): null | undefined;
|
|
569
|
+
/**
|
|
570
|
+
* Get whether the provided value is undefined or null.
|
|
571
|
+
* @param value The value to check.
|
|
572
|
+
*/
|
|
573
|
+
declare function isUndefinedOrNull(value: unknown): value is undefined | null;
|
|
574
|
+
/**
|
|
575
|
+
* Get whether the provided value is a {@link boolean}.
|
|
576
|
+
* @param value The value to check.
|
|
577
|
+
*/
|
|
578
|
+
declare function isBoolean(value: unknown): value is boolean;
|
|
579
|
+
/**
|
|
580
|
+
* Return the provided value if it is a boolean, otherwise return undefined.
|
|
581
|
+
* @param value The value to check.
|
|
582
|
+
*/
|
|
583
|
+
declare function asBoolean(value: unknown): boolean | undefined;
|
|
584
|
+
/**
|
|
585
|
+
* Get whether the provided value is a {@link number}.
|
|
586
|
+
* @param value The value to check.
|
|
587
|
+
*/
|
|
588
|
+
declare function isNumber(value: unknown): value is number;
|
|
589
|
+
/**
|
|
590
|
+
* Return the provided value if it is a number, otherwise return undefined.
|
|
591
|
+
* @param value The value to check.
|
|
592
|
+
*/
|
|
593
|
+
declare function asNumber(value: unknown): number | undefined;
|
|
594
|
+
/**
|
|
595
|
+
* Get whether the provided value is a {@link string}.
|
|
596
|
+
* @param value The value to check.
|
|
597
|
+
*/
|
|
598
|
+
declare function isString(value: unknown): value is string;
|
|
599
|
+
/**
|
|
600
|
+
* Return the provided value if it is a string, otherwise return undefined.
|
|
601
|
+
* @param value The value to check.
|
|
602
|
+
*/
|
|
603
|
+
declare function asString(value: unknown): string | undefined;
|
|
604
|
+
/**
|
|
605
|
+
* Get whether the provided value is a {@link function}.
|
|
606
|
+
* @param value The value to check.
|
|
607
|
+
*/
|
|
608
|
+
declare function isFunction(value: unknown): value is Function;
|
|
609
|
+
/**
|
|
610
|
+
* Return the provided value if it is a function, otherwise return undefined.
|
|
611
|
+
* @param value The value to check.
|
|
612
|
+
*/
|
|
613
|
+
declare function asFunction(value: unknown): Function | undefined;
|
|
614
|
+
/**
|
|
615
|
+
* Get the number of parameters that the provided {@link Function} takes.
|
|
616
|
+
* @param value The {@link Function} to get the parameter count for.
|
|
617
|
+
*/
|
|
618
|
+
declare function getParameterCount(value: Function): number;
|
|
619
|
+
/**
|
|
620
|
+
* Get whether the provided value is a function with the provided parameter count.
|
|
621
|
+
* @param value The value to check.
|
|
622
|
+
* @param parameterCount The number of parameters the function must have.
|
|
623
|
+
*/
|
|
624
|
+
declare function isFunctionWithParameterCount(value: unknown, parameterCount: number): value is Function;
|
|
625
|
+
/**
|
|
626
|
+
* Return the provided value if it is a function with the provided {@link parameterCount}, otherwise
|
|
627
|
+
* return undefined.
|
|
628
|
+
* @param value The value to check.
|
|
629
|
+
*/
|
|
630
|
+
declare function asFunctionWithParameterCount(value: unknown, parameterCount: number): Function | undefined;
|
|
631
|
+
/**
|
|
632
|
+
* Get whether the provided value is an {@link Array}.
|
|
633
|
+
* @param value The value to check.
|
|
634
|
+
*/
|
|
635
|
+
declare function isArray(value: unknown): value is unknown[];
|
|
636
|
+
/**
|
|
637
|
+
* Return the provided value if it is an array, otherwise return undefined.
|
|
638
|
+
* @param value The value to check.
|
|
639
|
+
*/
|
|
640
|
+
declare function asArray(value: unknown): unknown[] | undefined;
|
|
641
|
+
/**
|
|
642
|
+
* Get whether the provided value is an {@link Object} or is null.
|
|
643
|
+
* @param value The value to check.
|
|
644
|
+
*/
|
|
645
|
+
declare function isObjectOrArrayOrNull(value: unknown): value is {} | unknown[] | null;
|
|
646
|
+
/**
|
|
647
|
+
* Return the provided value if it is an array, otherwise return undefined.
|
|
648
|
+
* @param value The value to check.
|
|
649
|
+
*/
|
|
650
|
+
declare function asObjectOrArrayOrNull(value: unknown): {} | unknown[] | null | undefined;
|
|
651
|
+
/**
|
|
652
|
+
* Get whether the provided value is an {@link Object}.
|
|
653
|
+
* @param value The value to check.
|
|
654
|
+
* @returns
|
|
655
|
+
*/
|
|
656
|
+
declare function isObject(value: unknown): value is {};
|
|
657
|
+
/**
|
|
658
|
+
* Return the provided value if it is an {@link Object}, otherwise return undefined.
|
|
659
|
+
* @param value The value to check.
|
|
660
|
+
*/
|
|
661
|
+
declare function asObject(value: unknown): {} | undefined;
|
|
662
|
+
/**
|
|
663
|
+
* Get an {@link Iterator} that can be used to iterate through the properties of the provided value.
|
|
664
|
+
* @param value The value to iterate over.
|
|
665
|
+
*/
|
|
666
|
+
declare function getPropertyNames(value: {}): Iterable$1<string>;
|
|
667
|
+
/**
|
|
668
|
+
* Get whether the provided value has a property with the provided key.
|
|
669
|
+
* @param value The value to check.
|
|
670
|
+
* @param propertyKey The key of the property to look for.
|
|
671
|
+
*/
|
|
672
|
+
declare function hasProperty<TValue, TPropertyKey extends PropertyKey>(value: TValue, propertyKey: TPropertyKey): value is TValue & Record<TPropertyKey, unknown>;
|
|
673
|
+
/**
|
|
674
|
+
* Get whether the value has a function with the provided name.
|
|
675
|
+
* @param value The value to check.
|
|
676
|
+
* @param functionName The name of the function to look for.
|
|
677
|
+
*/
|
|
678
|
+
declare function hasFunction<TValue, TPropertyKey extends PropertyKey>(value: TValue, functionName: TPropertyKey, parameterCount?: number): value is TValue & Record<TPropertyKey, Function>;
|
|
679
|
+
/**
|
|
680
|
+
* Get whether the provided value is a {@link JavascriptIterator}.
|
|
681
|
+
* @param value The value to check.
|
|
682
|
+
*/
|
|
683
|
+
declare function isJavascriptIterator<T>(value: unknown): value is JavascriptIterator<T>;
|
|
684
|
+
/**
|
|
685
|
+
* Get whether the provided value is a {@link JavascriptIterable}.
|
|
686
|
+
* @param value The value to check.
|
|
687
|
+
*/
|
|
688
|
+
declare function isJavascriptIterable<T>(value: unknown): value is JavascriptIterable<T>;
|
|
689
|
+
declare function isIterable<T>(value: unknown): value is Iterable$1<T>;
|
|
690
|
+
/**
|
|
691
|
+
* Get whether the provided value is a {@link JavascriptAsyncIterator}.
|
|
692
|
+
* @param value The value to check.
|
|
693
|
+
*/
|
|
694
|
+
declare function isJavascriptAsyncIterator<T>(value: unknown): value is JavascriptAsyncIterator<T>;
|
|
695
|
+
/**
|
|
696
|
+
* Get whether the provided value is a {@link JavascriptAsyncIterable}.
|
|
697
|
+
* @param value The value to check.
|
|
698
|
+
*/
|
|
699
|
+
declare function isJavascriptAsyncIterable<T>(value: unknown): value is JavascriptAsyncIterable<T>;
|
|
700
|
+
declare function isAsyncIterable<T>(value: unknown): value is AsyncIterable<T>;
|
|
701
|
+
/**
|
|
702
|
+
* Get the name of the provided {@link Type}.
|
|
703
|
+
* @param type The {@link Type} to get the name of.
|
|
704
|
+
*/
|
|
705
|
+
declare function getName(type: Type<unknown>): string;
|
|
706
|
+
declare function isPromiseLike<T>(value: unknown): value is PromiseLike<T>;
|
|
707
|
+
declare function isPromise<T>(value: unknown): value is Promise<T>;
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* A result object that adds extra behavior beyond the standard {@link Promise}.
|
|
711
|
+
*/
|
|
712
|
+
declare abstract class AsyncResult<T> implements Promise<T> {
|
|
713
|
+
static create<T>(actionOrPromise: (() => (T | Promise<T>)) | Promise<T>): AsyncResult<T>;
|
|
714
|
+
/**
|
|
715
|
+
* Get an {@link AsyncResult} that is already completed and doesn't do anything.
|
|
716
|
+
*/
|
|
717
|
+
static empty(): AsyncResult<void>;
|
|
718
|
+
/**
|
|
719
|
+
* Create a new {@link AsyncResult} that contains the provided value.
|
|
720
|
+
* @param value The value to wrap in a {@link AsyncResult}.
|
|
721
|
+
*/
|
|
722
|
+
static value<T>(value: T): AsyncResult<T>;
|
|
723
|
+
/**
|
|
724
|
+
* Create a new {@link AsyncResult} that contains the provided error.
|
|
725
|
+
* @param error The error to wrap in a {@link AsyncResult}.
|
|
726
|
+
*/
|
|
727
|
+
static error<T>(error: Error): AsyncResult<T>;
|
|
728
|
+
static yield(): AsyncResult<void>;
|
|
729
|
+
/**
|
|
730
|
+
* Get a {@link AsyncResult} that runs the provided function if this {@link AsyncResult} is successful.
|
|
731
|
+
* @param thenFunction The function to run if this {@link AsyncResult} is successful.
|
|
732
|
+
*/
|
|
733
|
+
abstract then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): AsyncResult<TResult1 | TResult2>;
|
|
734
|
+
/**
|
|
735
|
+
* Run the provided onValueFunction if this {@link AsyncResult} is successful. The value or error
|
|
736
|
+
* contained by this {@link AsyncResult} will be contained by the returned {@link AsyncResult}.
|
|
737
|
+
* @param onValueFunction The function to run if this {@link AsyncResult} is successful.
|
|
738
|
+
*/
|
|
739
|
+
abstract onValue(onValueFunction: (value: T) => (void | Promise<void>)): AsyncResult<T>;
|
|
740
|
+
/**
|
|
741
|
+
* Run the provided catchFunction if this {@link AsyncResult} contains an error.
|
|
742
|
+
* @param catchFunction The function to run if an error is caught.
|
|
743
|
+
*/
|
|
744
|
+
abstract catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): AsyncResult<T | TResult>;
|
|
745
|
+
/**
|
|
746
|
+
* Run the provided catchFunction if this {@link AsyncResult} contains an error of the provided type.
|
|
747
|
+
* @param errorType The type of error to catch.
|
|
748
|
+
* @param catchFunction The function to run if the error is caught.
|
|
749
|
+
*/
|
|
750
|
+
abstract catch<TError, TResult = never>(errorType: Type<TError>, onrejected: (reason: TError) => (TResult | PromiseLike<TResult>)): AsyncResult<T | TResult>;
|
|
751
|
+
/**
|
|
752
|
+
* Run the provided onErrorFunction if this {@link AsyncResult} contains an error.
|
|
753
|
+
* @param onErrorFunction The function to run if an error is found.
|
|
754
|
+
*/
|
|
755
|
+
abstract onError(onErrorFunction: (reason: unknown) => (void | PromiseLike<void>)): AsyncResult<T>;
|
|
756
|
+
/**
|
|
757
|
+
* Run the provided onErrorFunction if this {@link AsyncResult} contains an error of the provided
|
|
758
|
+
* type.
|
|
759
|
+
* @param errorType The type of error to respond to.
|
|
760
|
+
* @param onErrorFunction The function to run if the error is found.
|
|
761
|
+
*/
|
|
762
|
+
abstract onError<TError>(errorType: Type<TError>, onErrorFunction: (reason: TError) => (void | PromiseLike<void>)): AsyncResult<T>;
|
|
763
|
+
/**
|
|
764
|
+
* Run the provided convertErrorFunction if this {@link AsyncResult} contains an error. The value
|
|
765
|
+
* returned from the convertErrorFunction will be the error for the returned {@link AsyncResult}.
|
|
766
|
+
* @param convertErrorFunction The function that will return the new error.
|
|
767
|
+
*/
|
|
768
|
+
abstract convertError(convertErrorFunction: (reason: unknown) => (unknown | PromiseLike<unknown>)): AsyncResult<T>;
|
|
769
|
+
/**
|
|
770
|
+
* Run the provided convertErrorFunction if this {@link AsyncResult} contains an error of the
|
|
771
|
+
* provided type. The value returned from the convertErrorFunction will be the error for the
|
|
772
|
+
* returned {@link AsyncResult}.
|
|
773
|
+
* @param errorType The type of error to respond to.
|
|
774
|
+
* @param convertErrorFunction The function that will return the new error.
|
|
775
|
+
*/
|
|
776
|
+
abstract convertError<TError>(errorType: Type<TError>, convertErrorFunction: (reason: TError) => (unknown | PromiseLike<unknown>)): AsyncResult<T>;
|
|
777
|
+
abstract finally(onfinally?: (() => (void | Promise<void>)) | null): AsyncResult<T>;
|
|
778
|
+
readonly abstract [Symbol.toStringTag]: string;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
declare abstract class CharacterWriteStream {
|
|
782
|
+
/**
|
|
783
|
+
* Write the provided text to this {@link CharacterWriteStream}.
|
|
784
|
+
* @param text The text to write.
|
|
785
|
+
* @returns The number of characters that were written.
|
|
786
|
+
*/
|
|
787
|
+
abstract writeString(text: string): AsyncResult<number>;
|
|
788
|
+
/**
|
|
789
|
+
* Write the provided text (if provided) and then write a newline character sequence to this
|
|
790
|
+
* {@link CharacterWriteStream}.
|
|
791
|
+
* @param text The optional text to write before the newline character sequence.
|
|
792
|
+
* @returns The number of characters that were written.
|
|
793
|
+
*/
|
|
794
|
+
writeLine(text?: string): AsyncResult<number>;
|
|
795
|
+
static writeLine(writeStream: CharacterWriteStream, text?: string): AsyncResult<number>;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
export { isUndefined as $, AsyncResult as A, instanceOf as B, CharacterWriteStream as C, instanceOfType as D, EqualFunctions as E, isArray as F, isAsyncIterable as G, isBoolean as H, Iterable$1 as I, type JavascriptArray as J, isFunction as K, isFunctionWithParameterCount as L, isIterable as M, isJavascriptAsyncIterable as N, isJavascriptAsyncIterator as O, PromiseAsyncResult as P, isJavascriptIterable as Q, isJavascriptIterator as R, SyncResult as S, ToStringFunctions as T, isNull as U, isNumber as V, isObject as W, isObjectOrArrayOrNull as X, isPromise as Y, isPromiseLike as Z, isString as _, Comparable as a, isUndefinedOrNull as a0, Comparison as b, Iterator$1 as c, type JavascriptAsyncIterable as d, type JavascriptAsyncIterator as e, type JavascriptIterable as f, type JavascriptIterator as g, type JavascriptIteratorResult as h, JavascriptMap as i, JavascriptSet as j, type Type as k, as as l, asArray as m, asBoolean as n, asFunction as o, asFunctionWithParameterCount as p, asNull as q, asNumber as r, asObject as s, asObjectOrArrayOrNull as t, asString as u, getName as v, getParameterCount as w, getPropertyNames as x, hasFunction as y, hasProperty as z };
|