@exodus/xqa 5.5.0 → 6.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.
@@ -0,0 +1,479 @@
1
+ export interface ErrorConfig {
2
+ withStackTrace: boolean;
3
+ }
4
+ export declare class ResultAsync<T, E> implements PromiseLike<Result<T, E>> {
5
+ private _promise;
6
+ constructor(res: Promise<Result<T, E>>);
7
+ static fromSafePromise<T, E = never>(promise: PromiseLike<T>): ResultAsync<T, E>;
8
+ static fromPromise<T, E>(promise: PromiseLike<T>, errorFn: (e: unknown) => E): ResultAsync<T, E>;
9
+ static fromThrowable<A extends readonly any[], R, E>(fn: (...args: A) => Promise<R>, errorFn?: (err: unknown) => E): (...args: A) => ResultAsync<R, E>;
10
+ static combine<T extends readonly [
11
+ ResultAsync<unknown, unknown>,
12
+ ...ResultAsync<unknown, unknown>[]
13
+ ]>(asyncResultList: T): CombineResultAsyncs<T>;
14
+ static combine<T extends readonly ResultAsync<unknown, unknown>[]>(asyncResultList: T): CombineResultAsyncs<T>;
15
+ static combineWithAllErrors<T extends readonly [
16
+ ResultAsync<unknown, unknown>,
17
+ ...ResultAsync<unknown, unknown>[]
18
+ ]>(asyncResultList: T): CombineResultsWithAllErrorsArrayAsync<T>;
19
+ static combineWithAllErrors<T extends readonly ResultAsync<unknown, unknown>[]>(asyncResultList: T): CombineResultsWithAllErrorsArrayAsync<T>;
20
+ map<A>(f: (t: T) => A | Promise<A>): ResultAsync<A, E>;
21
+ andThrough<F>(f: (t: T) => Result<unknown, F> | ResultAsync<unknown, F>): ResultAsync<T, E | F>;
22
+ andTee(f: (t: T) => unknown): ResultAsync<T, E>;
23
+ orTee(f: (t: E) => unknown): ResultAsync<T, E>;
24
+ mapErr<U>(f: (e: E) => U | Promise<U>): ResultAsync<T, U>;
25
+ andThen<R extends Result<unknown, unknown>>(f: (t: T) => R): ResultAsync<InferOkTypes<R>, InferErrTypes<R> | E>;
26
+ andThen<R extends ResultAsync<unknown, unknown>>(f: (t: T) => R): ResultAsync<InferAsyncOkTypes<R>, InferAsyncErrTypes<R> | E>;
27
+ andThen<U, F>(f: (t: T) => Result<U, F> | ResultAsync<U, F>): ResultAsync<U, E | F>;
28
+ orElse<R extends Result<unknown, unknown>>(f: (e: E) => R): ResultAsync<InferOkTypes<R> | T, InferErrTypes<R>>;
29
+ orElse<R extends ResultAsync<unknown, unknown>>(f: (e: E) => R): ResultAsync<InferAsyncOkTypes<R> | T, InferAsyncErrTypes<R>>;
30
+ orElse<U, A>(f: (e: E) => Result<U, A> | ResultAsync<U, A>): ResultAsync<U | T, A>;
31
+ match<A, B = A>(ok: (t: T) => A, _err: (e: E) => B): Promise<A | B>;
32
+ unwrapOr<A>(t: A): Promise<T | A>;
33
+ /**
34
+ * @deprecated will be removed in 9.0.0.
35
+ *
36
+ * You can use `safeTry` without this method.
37
+ * @example
38
+ * ```typescript
39
+ * safeTry(async function* () {
40
+ * const okValue = yield* yourResult
41
+ * })
42
+ * ```
43
+ * Emulates Rust's `?` operator in `safeTry`'s body. See also `safeTry`.
44
+ */
45
+ safeUnwrap(): AsyncGenerator<Err<never, E>, T>;
46
+ then<A, B>(successCallback?: (res: Result<T, E>) => A | PromiseLike<A>, failureCallback?: (reason: unknown) => B | PromiseLike<B>): PromiseLike<A | B>;
47
+ [Symbol.asyncIterator](): AsyncGenerator<Err<never, E>, T>;
48
+ }
49
+ export declare function okAsync<T, E = never>(value: T): ResultAsync<T, E>;
50
+ export declare function okAsync<T extends void = void, E = never>(value: void): ResultAsync<void, E>;
51
+ export declare function errAsync<T = never, E = unknown>(err: E): ResultAsync<T, E>;
52
+ export declare function errAsync<T = never, E extends void = void>(err: void): ResultAsync<T, void>;
53
+ export declare type CombineResultAsyncs<T extends readonly ResultAsync<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? TraverseAsync<UnwrapAsync<T>> : ResultAsync<ExtractOkAsyncTypes<T>, ExtractErrAsyncTypes<T>[number]>;
54
+ export declare type CombineResultsWithAllErrorsArrayAsync<T extends readonly ResultAsync<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? TraverseWithAllErrorsAsync<UnwrapAsync<T>> : ResultAsync<ExtractOkAsyncTypes<T>, ExtractErrAsyncTypes<T>[number][]>;
55
+ export declare type UnwrapAsync<T> = IsLiteralArray<T> extends 1 ? Writable<T> extends [
56
+ infer H,
57
+ ...infer Rest
58
+ ] ? H extends PromiseLike<infer HI> ? HI extends Result<unknown, unknown> ? [
59
+ Dedup<HI>,
60
+ ...UnwrapAsync<Rest>
61
+ ] : never : never : [
62
+ ] : T extends Array<infer A> ? A extends PromiseLike<infer HI> ? HI extends Result<infer L, infer R> ? Ok<L, R>[] : never : never : never;
63
+ export declare type TraverseAsync<T, Depth extends number = 5> = IsLiteralArray<T> extends 1 ? Combine<T, Depth> extends [
64
+ infer Oks,
65
+ infer Errs
66
+ ] ? ResultAsync<EmptyArrayToNever<Oks>, MembersToUnion<Errs>> : never : T extends Array<infer I> ? Combine<MemberListOf<I>, Depth> extends [
67
+ infer Oks,
68
+ infer Errs
69
+ ] ? Oks extends unknown[] ? Errs extends unknown[] ? ResultAsync<EmptyArrayToNever<Oks[number][]>, MembersToUnion<Errs[number][]>> : ResultAsync<EmptyArrayToNever<Oks[number][]>, Errs> : Errs extends unknown[] ? ResultAsync<Oks, MembersToUnion<Errs[number][]>> : ResultAsync<Oks, Errs> : never : never;
70
+ export declare type TraverseWithAllErrorsAsync<T, Depth extends number = 5> = TraverseAsync<T, Depth> extends ResultAsync<infer Oks, infer Errs> ? ResultAsync<Oks, Errs[]> : never;
71
+ export declare type Writable<T> = T extends ReadonlyArray<unknown> ? [
72
+ ...T
73
+ ] : T;
74
+ export declare type ExtractOkTypes<T extends readonly Result<unknown, unknown>[]> = {
75
+ [idx in keyof T]: T[idx] extends Result<infer U, unknown> ? U : never;
76
+ };
77
+ export declare type ExtractOkAsyncTypes<T extends readonly ResultAsync<unknown, unknown>[]> = {
78
+ [idx in keyof T]: T[idx] extends ResultAsync<infer U, unknown> ? U : never;
79
+ };
80
+ export declare type ExtractErrTypes<T extends readonly Result<unknown, unknown>[]> = {
81
+ [idx in keyof T]: T[idx] extends Result<unknown, infer E> ? E : never;
82
+ };
83
+ export declare type ExtractErrAsyncTypes<T extends readonly ResultAsync<unknown, unknown>[]> = {
84
+ [idx in keyof T]: T[idx] extends ResultAsync<unknown, infer E> ? E : never;
85
+ };
86
+ export declare type InferOkTypes<R> = R extends Result<infer T, unknown> ? T : never;
87
+ export declare type InferErrTypes<R> = R extends Result<unknown, infer E> ? E : never;
88
+ export declare type InferAsyncOkTypes<R> = R extends ResultAsync<infer T, unknown> ? T : never;
89
+ export declare type InferAsyncErrTypes<R> = R extends ResultAsync<unknown, infer E> ? E : never;
90
+ export declare namespace Result {
91
+ /**
92
+ * Wraps a function with a try catch, creating a new function with the same
93
+ * arguments but returning `Ok` if successful, `Err` if the function throws
94
+ *
95
+ * @param fn function to wrap with ok on success or err on failure
96
+ * @param errorFn when an error is thrown, this will wrap the error result if provided
97
+ */
98
+ function fromThrowable<Fn extends (...args: readonly any[]) => any, E>(fn: Fn, errorFn?: (e: unknown) => E): (...args: Parameters<Fn>) => Result<ReturnType<Fn>, E>;
99
+ function combine<T extends readonly [
100
+ Result<unknown, unknown>,
101
+ ...Result<unknown, unknown>[]
102
+ ]>(resultList: T): CombineResults<T>;
103
+ function combine<T extends readonly Result<unknown, unknown>[]>(resultList: T): CombineResults<T>;
104
+ function combineWithAllErrors<T extends readonly [
105
+ Result<unknown, unknown>,
106
+ ...Result<unknown, unknown>[]
107
+ ]>(resultList: T): CombineResultsWithAllErrorsArray<T>;
108
+ function combineWithAllErrors<T extends readonly Result<unknown, unknown>[]>(resultList: T): CombineResultsWithAllErrorsArray<T>;
109
+ }
110
+ export declare type Result<T, E> = Ok<T, E> | Err<T, E>;
111
+ export declare function ok<T, E = never>(value: T): Ok<T, E>;
112
+ export declare function ok<T extends void = void, E = never>(value: void): Ok<void, E>;
113
+ export declare function err<T = never, E extends string = string>(err: E): Err<T, E>;
114
+ export declare function err<T = never, E = unknown>(err: E): Err<T, E>;
115
+ export declare function err<T = never, E extends void = void>(err: void): Err<T, void>;
116
+ export interface IResult<T, E> {
117
+ /**
118
+ * Used to check if a `Result` is an `OK`
119
+ *
120
+ * @returns `true` if the result is an `OK` variant of Result
121
+ */
122
+ isOk(): this is Ok<T, E>;
123
+ /**
124
+ * Used to check if a `Result` is an `Err`
125
+ *
126
+ * @returns `true` if the result is an `Err` variant of Result
127
+ */
128
+ isErr(): this is Err<T, E>;
129
+ /**
130
+ * Maps a `Result<T, E>` to `Result<U, E>`
131
+ * by applying a function to a contained `Ok` value, leaving an `Err` value
132
+ * untouched.
133
+ *
134
+ * @param f The function to apply an `OK` value
135
+ * @returns the result of applying `f` or an `Err` untouched
136
+ */
137
+ map<A>(f: (t: T) => A): Result<A, E>;
138
+ /**
139
+ * Maps a `Result<T, E>` to `Result<T, F>` by applying a function to a
140
+ * contained `Err` value, leaving an `Ok` value untouched.
141
+ *
142
+ * This function can be used to pass through a successful result while
143
+ * handling an error.
144
+ *
145
+ * @param f a function to apply to the error `Err` value
146
+ */
147
+ mapErr<U>(f: (e: E) => U): Result<T, U>;
148
+ /**
149
+ * Similar to `map` Except you must return a new `Result`.
150
+ *
151
+ * This is useful for when you need to do a subsequent computation using the
152
+ * inner `T` value, but that computation might fail.
153
+ * Additionally, `andThen` is really useful as a tool to flatten a
154
+ * `Result<Result<A, E2>, E1>` into a `Result<A, E2>` (see example below).
155
+ *
156
+ * @param f The function to apply to the current value
157
+ */
158
+ andThen<R extends Result<unknown, unknown>>(f: (t: T) => R): Result<InferOkTypes<R>, InferErrTypes<R> | E>;
159
+ andThen<U, F>(f: (t: T) => Result<U, F>): Result<U, E | F>;
160
+ /**
161
+ * This "tee"s the current value to an passed-in computation such as side
162
+ * effect functions but still returns the same current value as the result.
163
+ *
164
+ * This is useful when you want to pass the current result to your side-track
165
+ * work such as logging but want to continue main-track work after that.
166
+ * This method does not care about the result of the passed in computation.
167
+ *
168
+ * @param f The function to apply to the current value
169
+ */
170
+ andTee(f: (t: T) => unknown): Result<T, E>;
171
+ /**
172
+ * This "tee"s the current `Err` value to an passed-in computation such as side
173
+ * effect functions but still returns the same `Err` value as the result.
174
+ *
175
+ * This is useful when you want to pass the current `Err` value to your side-track
176
+ * work such as logging but want to continue error-track work after that.
177
+ * This method does not care about the result of the passed in computation.
178
+ *
179
+ * @param f The function to apply to the current `Err` value
180
+ */
181
+ orTee(f: (t: E) => unknown): Result<T, E>;
182
+ /**
183
+ * Similar to `andTee` except error result of the computation will be passed
184
+ * to the downstream in case of an error.
185
+ *
186
+ * This version is useful when you want to make side-effects but in case of an
187
+ * error, you want to pass the error to the downstream.
188
+ *
189
+ * @param f The function to apply to the current value
190
+ */
191
+ andThrough<R extends Result<unknown, unknown>>(f: (t: T) => R): Result<T, InferErrTypes<R> | E>;
192
+ andThrough<F>(f: (t: T) => Result<unknown, F>): Result<T, E | F>;
193
+ /**
194
+ * Takes an `Err` value and maps it to a `Result<T, SomeNewType>`.
195
+ *
196
+ * This is useful for error recovery.
197
+ *
198
+ *
199
+ * @param f A function to apply to an `Err` value, leaving `Ok` values
200
+ * untouched.
201
+ */
202
+ orElse<R extends Result<unknown, unknown>>(f: (e: E) => R): Result<InferOkTypes<R> | T, InferErrTypes<R>>;
203
+ orElse<U, A>(f: (e: E) => Result<U, A>): Result<U | T, A>;
204
+ /**
205
+ * Similar to `map` Except you must return a new `Result`.
206
+ *
207
+ * This is useful for when you need to do a subsequent async computation using
208
+ * the inner `T` value, but that computation might fail. Must return a ResultAsync
209
+ *
210
+ * @param f The function that returns a `ResultAsync` to apply to the current
211
+ * value
212
+ */
213
+ asyncAndThen<U, F>(f: (t: T) => ResultAsync<U, F>): ResultAsync<U, E | F>;
214
+ /**
215
+ * Maps a `Result<T, E>` to `ResultAsync<U, E>`
216
+ * by applying an async function to a contained `Ok` value, leaving an `Err`
217
+ * value untouched.
218
+ *
219
+ * @param f An async function to apply an `OK` value
220
+ */
221
+ asyncMap<U>(f: (t: T) => Promise<U>): ResultAsync<U, E>;
222
+ /**
223
+ * Unwrap the `Ok` value, or return the default if there is an `Err`
224
+ *
225
+ * @param v the default value to return if there is an `Err`
226
+ */
227
+ unwrapOr<A>(v: A): T | A;
228
+ /**
229
+ *
230
+ * Given 2 functions (one for the `Ok` variant and one for the `Err` variant)
231
+ * execute the function that matches the `Result` variant.
232
+ *
233
+ * Match callbacks do not necessitate to return a `Result`, however you can
234
+ * return a `Result` if you want to.
235
+ *
236
+ * `match` is like chaining `map` and `mapErr`, with the distinction that
237
+ * with `match` both functions must have the same return type.
238
+ *
239
+ * @param ok
240
+ * @param err
241
+ */
242
+ match<A, B = A>(ok: (t: T) => A, err: (e: E) => B): A | B;
243
+ /**
244
+ * @deprecated will be removed in 9.0.0.
245
+ *
246
+ * You can use `safeTry` without this method.
247
+ * @example
248
+ * ```typescript
249
+ * safeTry(function* () {
250
+ * const okValue = yield* yourResult
251
+ * })
252
+ * ```
253
+ * Emulates Rust's `?` operator in `safeTry`'s body. See also `safeTry`.
254
+ */
255
+ safeUnwrap(): Generator<Err<never, E>, T>;
256
+ /**
257
+ * **This method is unsafe, and should only be used in a test environments**
258
+ *
259
+ * Takes a `Result<T, E>` and returns a `T` when the result is an `Ok`, otherwise it throws a custom object.
260
+ *
261
+ * @param config
262
+ */
263
+ _unsafeUnwrap(config?: ErrorConfig): T;
264
+ /**
265
+ * **This method is unsafe, and should only be used in a test environments**
266
+ *
267
+ * takes a `Result<T, E>` and returns a `E` when the result is an `Err`,
268
+ * otherwise it throws a custom object.
269
+ *
270
+ * @param config
271
+ */
272
+ _unsafeUnwrapErr(config?: ErrorConfig): E;
273
+ }
274
+ declare class Ok<T, E> implements IResult<T, E> {
275
+ readonly value: T;
276
+ constructor(value: T);
277
+ isOk(): this is Ok<T, E>;
278
+ isErr(): this is Err<T, E>;
279
+ map<A>(f: (t: T) => A): Result<A, E>;
280
+ mapErr<U>(_f: (e: E) => U): Result<T, U>;
281
+ andThen<R extends Result<unknown, unknown>>(f: (t: T) => R): Result<InferOkTypes<R>, InferErrTypes<R> | E>;
282
+ andThen<U, F>(f: (t: T) => Result<U, F>): Result<U, E | F>;
283
+ andThrough<R extends Result<unknown, unknown>>(f: (t: T) => R): Result<T, InferErrTypes<R> | E>;
284
+ andThrough<F>(f: (t: T) => Result<unknown, F>): Result<T, E | F>;
285
+ andTee(f: (t: T) => unknown): Result<T, E>;
286
+ orTee(_f: (t: E) => unknown): Result<T, E>;
287
+ orElse<R extends Result<unknown, unknown>>(_f: (e: E) => R): Result<InferOkTypes<R> | T, InferErrTypes<R>>;
288
+ orElse<U, A>(_f: (e: E) => Result<U, A>): Result<U | T, A>;
289
+ asyncAndThen<U, F>(f: (t: T) => ResultAsync<U, F>): ResultAsync<U, E | F>;
290
+ asyncAndThrough<R extends ResultAsync<unknown, unknown>>(f: (t: T) => R): ResultAsync<T, InferAsyncErrTypes<R> | E>;
291
+ asyncAndThrough<F>(f: (t: T) => ResultAsync<unknown, F>): ResultAsync<T, E | F>;
292
+ asyncMap<U>(f: (t: T) => Promise<U>): ResultAsync<U, E>;
293
+ unwrapOr<A>(_v: A): T | A;
294
+ match<A, B = A>(ok: (t: T) => A, _err: (e: E) => B): A | B;
295
+ safeUnwrap(): Generator<Err<never, E>, T>;
296
+ _unsafeUnwrap(_?: ErrorConfig): T;
297
+ _unsafeUnwrapErr(config?: ErrorConfig): E;
298
+ [Symbol.iterator](): Generator<Err<never, E>, T>;
299
+ }
300
+ declare class Err<T, E> implements IResult<T, E> {
301
+ readonly error: E;
302
+ constructor(error: E);
303
+ isOk(): this is Ok<T, E>;
304
+ isErr(): this is Err<T, E>;
305
+ map<A>(_f: (t: T) => A): Result<A, E>;
306
+ mapErr<U>(f: (e: E) => U): Result<T, U>;
307
+ andThrough<F>(_f: (t: T) => Result<unknown, F>): Result<T, E | F>;
308
+ andTee(_f: (t: T) => unknown): Result<T, E>;
309
+ orTee(f: (t: E) => unknown): Result<T, E>;
310
+ andThen<R extends Result<unknown, unknown>>(_f: (t: T) => R): Result<InferOkTypes<R>, InferErrTypes<R> | E>;
311
+ andThen<U, F>(_f: (t: T) => Result<U, F>): Result<U, E | F>;
312
+ orElse<R extends Result<unknown, unknown>>(f: (e: E) => R): Result<InferOkTypes<R> | T, InferErrTypes<R>>;
313
+ orElse<U, A>(f: (e: E) => Result<U, A>): Result<U | T, A>;
314
+ asyncAndThen<U, F>(_f: (t: T) => ResultAsync<U, F>): ResultAsync<U, E | F>;
315
+ asyncAndThrough<F>(_f: (t: T) => ResultAsync<unknown, F>): ResultAsync<T, E | F>;
316
+ asyncMap<U>(_f: (t: T) => Promise<U>): ResultAsync<U, E>;
317
+ unwrapOr<A>(v: A): T | A;
318
+ match<A, B = A>(_ok: (t: T) => A, err: (e: E) => B): A | B;
319
+ safeUnwrap(): Generator<Err<never, E>, T>;
320
+ _unsafeUnwrap(config?: ErrorConfig): T;
321
+ _unsafeUnwrapErr(_?: ErrorConfig): E;
322
+ [Symbol.iterator](): Generator<Err<never, E>, T>;
323
+ }
324
+ export declare const fromThrowable: typeof Result.fromThrowable;
325
+ export declare type Prev = [
326
+ never,
327
+ 0,
328
+ 1,
329
+ 2,
330
+ 3,
331
+ 4,
332
+ 5,
333
+ 6,
334
+ 7,
335
+ 8,
336
+ 9,
337
+ 10,
338
+ 11,
339
+ 12,
340
+ 13,
341
+ 14,
342
+ 15,
343
+ 16,
344
+ 17,
345
+ 18,
346
+ 19,
347
+ 20,
348
+ 21,
349
+ 22,
350
+ 23,
351
+ 24,
352
+ 25,
353
+ 26,
354
+ 27,
355
+ 28,
356
+ 29,
357
+ 30,
358
+ 31,
359
+ 32,
360
+ 33,
361
+ 34,
362
+ 35,
363
+ 36,
364
+ 37,
365
+ 38,
366
+ 39,
367
+ 40,
368
+ 41,
369
+ 42,
370
+ 43,
371
+ 44,
372
+ 45,
373
+ 46,
374
+ 47,
375
+ 48,
376
+ 49,
377
+ ...0[]
378
+ ];
379
+ export declare type CollectResults<T, Collected extends unknown[] = [
380
+ ], Depth extends number = 50> = [
381
+ Depth
382
+ ] extends [
383
+ never
384
+ ] ? [
385
+ ] : T extends [
386
+ infer H,
387
+ ...infer Rest
388
+ ] ? H extends Result<infer L, infer R> ? CollectResults<Rest, [
389
+ ...Collected,
390
+ [
391
+ L,
392
+ R
393
+ ]
394
+ ], Prev[Depth]> : never : Collected;
395
+ export declare type Transpose<A, Transposed extends unknown[][] = [
396
+ ], Depth extends number = 10> = A extends [
397
+ infer T,
398
+ ...infer Rest
399
+ ] ? T extends [
400
+ infer L,
401
+ infer R
402
+ ] ? Transposed extends [
403
+ infer PL,
404
+ infer PR
405
+ ] ? PL extends unknown[] ? PR extends unknown[] ? Transpose<Rest, [
406
+ [
407
+ ...PL,
408
+ L
409
+ ],
410
+ [
411
+ ...PR,
412
+ R
413
+ ]
414
+ ], Prev[Depth]> : never : never : Transpose<Rest, [
415
+ [
416
+ L
417
+ ],
418
+ [
419
+ R
420
+ ]
421
+ ], Prev[Depth]> : Transposed : Transposed;
422
+ export declare type Combine<T, Depth extends number = 5> = Transpose<CollectResults<T>, [
423
+ ], Depth> extends [
424
+ infer L,
425
+ infer R
426
+ ] ? [
427
+ UnknownMembersToNever<L>,
428
+ UnknownMembersToNever<R>
429
+ ] : Transpose<CollectResults<T>, [
430
+ ], Depth> extends [
431
+ ] ? [
432
+ [
433
+ ],
434
+ [
435
+ ]
436
+ ] : never;
437
+ export declare type Dedup<T> = T extends Result<infer RL, infer RR> ? [
438
+ unknown
439
+ ] extends [
440
+ RL
441
+ ] ? Err<RL, RR> : Ok<RL, RR> : T;
442
+ export declare type MemberListOf<T> = ((T extends unknown ? (t: T) => T : never) extends infer U ? (U extends unknown ? (u: U) => unknown : never) extends (v: infer V) => unknown ? V : never : never) extends (_: unknown) => infer W ? [
443
+ ...MemberListOf<Exclude<T, W>>,
444
+ W
445
+ ] : [
446
+ ];
447
+ export declare type EmptyArrayToNever<T, NeverArrayToNever extends number = 0> = T extends [
448
+ ] ? never : NeverArrayToNever extends 1 ? T extends [
449
+ never,
450
+ ...infer Rest
451
+ ] ? [
452
+ EmptyArrayToNever<Rest>
453
+ ] extends [
454
+ never
455
+ ] ? never : T : T : T;
456
+ export declare type UnknownMembersToNever<T> = T extends [
457
+ infer H,
458
+ ...infer R
459
+ ] ? [
460
+ [
461
+ unknown
462
+ ] extends [
463
+ H
464
+ ] ? never : H,
465
+ ...UnknownMembersToNever<R>
466
+ ] : T;
467
+ export declare type MembersToUnion<T> = T extends unknown[] ? T[number] : never;
468
+ export declare type IsLiteralArray<T> = T extends {
469
+ length: infer L;
470
+ } ? L extends number ? number extends L ? 0 : 1 : 0 : 0;
471
+ export declare type Traverse<T, Depth extends number = 5> = Combine<T, Depth> extends [
472
+ infer Oks,
473
+ infer Errs
474
+ ] ? Result<EmptyArrayToNever<Oks, 1>, MembersToUnion<Errs>> : never;
475
+ export declare type TraverseWithAllErrors<T, Depth extends number = 5> = Traverse<T, Depth> extends Result<infer Oks, infer Errs> ? Result<Oks, Errs[]> : never;
476
+ export declare type CombineResults<T extends readonly Result<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? Traverse<T> : Result<ExtractOkTypes<T>, ExtractErrTypes<T>[number]>;
477
+ export declare type CombineResultsWithAllErrorsArray<T extends readonly Result<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? TraverseWithAllErrors<T> : Result<ExtractOkTypes<T>, ExtractErrTypes<T>[number][]>;
478
+
479
+ export {};