@shirudo/result 0.0.3 → 0.0.5

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/dist/index.d.mts CHANGED
@@ -50,11 +50,11 @@ declare abstract class Pipeable {
50
50
  type Ctor<T> = abstract new (...args: any[]) => T;
51
51
  type TypeGuard<E, A extends E> = (error: E) => error is A;
52
52
  /**
53
- * Matcher für Err-Values (liefert einen beliebigen Return-Type, z.B. string messages).
53
+ * Matcher for Err values (returns an arbitrary return type, e.g. string messages).
54
54
  *
55
- * - `.when(Ctor, handler)` matched via `instanceof`
56
- * - `.whenGuard(guard, handler)` matched via Type-Guard
57
- * - `.run()` ist nur erlaubt, wenn alle Error-Cases behandelt wurden (`E` wurde zu `never` reduziert)
55
+ * - `.when(Ctor, handler)` matches via `instanceof`
56
+ * - `.whenGuard(guard, handler)` matches via Type-Guard
57
+ * - `.run()` is only allowed if all error cases have been handled (`E` has been reduced to `never`)
58
58
  */
59
59
  declare class ErrorMatchBuilder<E, R$1> {
60
60
  #private;
@@ -68,11 +68,11 @@ type OkOfReturn$1<R$1> = R$1 extends Result<infer T, any> ? T : never;
68
68
  type ErrOfReturn$1<R$1> = R$1 extends Result<any, infer E> ? E : R$1;
69
69
  type ErrFactory = <E>(error: E) => Result<never, E>;
70
70
  /**
71
- * Matcher für `Result`-Errors, der immer wieder ein `Result` zurückgibt.
71
+ * Matcher for `Result` Errors, which returns a `Result` again.
72
72
  *
73
- * Handler dürfen:
74
- * - ein `Result` zurückgeben (wird direkt returned)
75
- * - einen Error-Wert zurückgeben (wird automatisch zu `Err(error)` gewrappt)
73
+ * Handlers may:
74
+ * - return a `Result` (is returned directly)
75
+ * - return an Error value (is automatically wrapped into `Err(error)`)
76
76
  */
77
77
  declare class ErrMatchBuilder<T, E, OutT, OutE> {
78
78
  #private;
@@ -86,55 +86,55 @@ declare class ErrMatchBuilder<T, E, OutT, OutE> {
86
86
  //#endregion
87
87
  //#region src/core/map.d.ts
88
88
  /**
89
- * Transformiert den Wert (Ok-Fall).
90
- * Entspricht Rust `map`.
89
+ * Transforms the value (Ok case).
90
+ * Corresponds to Rust `map`.
91
91
  */
92
92
  declare function map<T, E, U>(project: (value: T) => U): (source: Result<T, E>) => Result<U, E>;
93
93
  //#endregion
94
94
  //#region src/core/mapErr.d.ts
95
95
  /**
96
- * Transformiert den Fehler (Err-Fall).
97
- * Entspricht Rust `map_err`.
96
+ * Transforms the error (Err case).
97
+ * Corresponds to Rust `map_err`.
98
98
  */
99
99
  declare function mapErr<T, E, F>(project: (error: E) => F): (source: Result<T, E>) => Result<T, F>;
100
100
  //#endregion
101
101
  //#region src/core/mapBoth.d.ts
102
102
  /**
103
- * Transformiert sowohl den Ok-Wert als auch den Err-Fehler.
104
- * Entspricht FP `bimap` / `mapBoth`.
103
+ * Transforms both the Ok value and the Err error.
104
+ * Corresponds to FP `bimap` / `mapBoth`.
105
105
  */
106
106
  declare function mapBoth<T, E, U, F>(mapOk: (value: T) => U, mapErr: (error: E) => F): (source: Result<T, E>) => Result<U, F>;
107
107
  /**
108
- * Alias für `mapBoth`.
108
+ * Alias for `mapBoth`.
109
109
  */
110
110
  declare const bimap: typeof mapBoth;
111
111
  //#endregion
112
112
  //#region src/core/flatMap.d.ts
113
113
  /**
114
- * Verkettet eine weitere Operation, die ein Result zurückgibt.
115
- * Entspricht Rust `and_then` oder JS `flatMap`.
114
+ * Chains another operation that returns a Result.
115
+ * Corresponds to Rust `and_then` or JS `flatMap`.
116
116
  */
117
117
  declare function flatMap<T, E, U>(project: (value: T) => Result<U, E>): (source: Result<T, E>) => Result<U, E>;
118
118
  //#endregion
119
119
  //#region src/core/zip.d.ts
120
120
  /**
121
- * Kombiniert zwei Results zu einem Result eines Tupels.
122
- * Short-circuits beim ersten Err (links vor rechts).
121
+ * Combines two Results into a Result of a tuple.
122
+ * Short-circuits on the first Err (left before right).
123
123
  */
124
124
  declare function zip<A, AE, B, BE>(left: Result<A, AE>, right: Result<B, BE>): Result<[A, B], AE | BE>;
125
125
  declare function zip<A, AE, B, BE>(right: Result<B, BE>): (left: Result<A, AE>) => Result<[A, B], AE | BE>;
126
126
  /**
127
- * Kombiniert zwei Results und sammelt Fehler ein.
128
- * - Ok nur wenn beide Ok sind
129
- * - Err([errors]) wenn mindestens ein Err ist (links vor rechts)
127
+ * Combines two Results and collects errors.
128
+ * - Ok only if both are Ok
129
+ * - Err([errors]) if at least one is Err (left before right)
130
130
  */
131
131
  declare function combine<A, AE, B, BE>(left: Result<A, AE>, right: Result<B, BE>): Result<[A, B], Array<AE | BE>>;
132
132
  declare function combine<A, AE, B, BE>(right: Result<B, BE>): (left: Result<A, AE>) => Result<[A, B], Array<AE | BE>>;
133
133
  //#endregion
134
134
  //#region src/core/tap.d.ts
135
135
  /**
136
- * Führt einen Seiteneffekt aus (Logging, Debugging), ohne das Result zu ändern.
137
- * Entspricht Rust `inspect` / `inspect_err`.
136
+ * Executes a side effect (logging, debugging) without changing the Result.
137
+ * Corresponds to Rust `inspect` / `inspect_err`.
138
138
  */
139
139
  declare function tap<T, E>(observer: {
140
140
  ok?: (val: T) => void;
@@ -143,15 +143,15 @@ declare function tap<T, E>(observer: {
143
143
  //#endregion
144
144
  //#region src/core/filter.d.ts
145
145
  /**
146
- * Prüft eine Bedingung. Wenn falsch, wird das Result zu Err.
147
- * Entspricht Rust `filter` (teilweise).
146
+ * Checks a condition. If false, the Result becomes Err.
147
+ * Corresponds to Rust `filter` (partially).
148
148
  */
149
149
  declare function filter<T, E>(predicate: (val: T) => boolean, errorFn: () => E): (source: Result<T, E>) => Result<T, E>;
150
150
  //#endregion
151
151
  //#region src/core/match.d.ts
152
152
  /**
153
- * Löst das Result auf. Das Ende der Pipe.
154
- * Entspricht Rust `match`.
153
+ * Resolves the Result. The end of the pipe.
154
+ * Corresponds to Rust `match`.
155
155
  */
156
156
  declare function match<T, E, R$1>(handlers: {
157
157
  ok: (val: T) => R$1;
@@ -160,33 +160,33 @@ declare function match<T, E, R$1>(handlers: {
160
160
  //#endregion
161
161
  //#region src/core/recover.d.ts
162
162
  /**
163
- * Recover: wandelt Err in Ok(defaultValue) um.
164
- * Ergebnis ist garantiert Ok → Error-Typ wird `never`.
163
+ * Recover: converts Err to Ok(defaultValue).
164
+ * Result is guaranteed to be Ok → Error type becomes `never`.
165
165
  */
166
166
  declare function recover<T, E, F>(defaultValue: F): (source: Result<T, E>) => Result<T | F, never>;
167
167
  /**
168
- * Wie `recover`, aber berechnet den Default-Wert anhand des Errors.
168
+ * Like `recover`, but calculates the default value based on the error.
169
169
  */
170
170
  declare function recoverWith<T, E, F>(fn: (error: E) => F): (source: Result<T, E>) => Result<T | F, never>;
171
171
  //#endregion
172
172
  //#region src/core/swap.d.ts
173
173
  /**
174
- * Tauscht Ok und Err.
174
+ * Swaps Ok and Err.
175
175
  * Result<T, E> → Result<E, T>
176
176
  */
177
177
  declare function swap<T, E>(result: Result<T, E>): Result<E, T>;
178
178
  //#endregion
179
179
  //#region src/core/tryCatch.d.ts
180
180
  /**
181
- * Führt eine Funktion aus und fängt Exceptions ab.
182
- * Wandelt Exceptions in Result<E> um.
183
- * Entspricht Rust `Result::from` für fallible Operationen.
181
+ * Executes a function and catches exceptions.
182
+ * Converts exceptions into Result<E>.
183
+ * Corresponds to Rust `Result::from` for fallible operations.
184
184
  */
185
185
  declare function tryCatch<T, E = unknown>(fn: () => T, errorMapper?: (error: unknown) => E): (source: Result<any, any>) => Result<T, E>;
186
186
  //#endregion
187
187
  //#region src/core/tryMap.d.ts
188
188
  /**
189
- * Wie `map`, aber fängt Exceptions ab und wandelt sie in Err um.
189
+ * Like `map`, but catches exceptions and converts them to Err.
190
190
  */
191
191
  declare function tryMap<T, E, U, F = unknown>(project: (value: T) => U, errorMapper?: (error: unknown) => F): (source: Result<T, E>) => Result<U, E | F>;
192
192
  //#endregion
@@ -202,25 +202,25 @@ declare function collectFirstOk<const Results extends readonly Result<any, any>[
202
202
  //#endregion
203
203
  //#region src/core/mapAsync.d.ts
204
204
  /**
205
- * Async-Version von map.
205
+ * Async version of map.
206
206
  */
207
207
  declare function mapAsync<T, E, U>(project: (value: T) => Promise<U>): (source: Result<T, E>) => Promise<Result<U, E>>;
208
208
  //#endregion
209
209
  //#region src/core/mapErrAsync.d.ts
210
210
  /**
211
- * Async-Version von mapErr.
211
+ * Async version of mapErr.
212
212
  */
213
213
  declare function mapErrAsync<T, E, F>(project: (error: E) => Promise<F>): (source: Result<T, E>) => Promise<Result<T, F>>;
214
214
  //#endregion
215
215
  //#region src/core/flatMapAsync.d.ts
216
216
  /**
217
- * Async-Version von flatMap.
217
+ * Async version of flatMap.
218
218
  */
219
219
  declare function flatMapAsync<T, E, U>(project: (value: T) => Promise<Result<U, E>>): (source: Result<T, E>) => Promise<Result<U, E>>;
220
220
  //#endregion
221
221
  //#region src/core/tapAsync.d.ts
222
222
  /**
223
- * Async-Version von tap.
223
+ * Async version of tap.
224
224
  */
225
225
  declare function tapAsync<T, E>(observer: {
226
226
  ok?: (val: T) => Promise<void>;
@@ -229,13 +229,13 @@ declare function tapAsync<T, E>(observer: {
229
229
  //#endregion
230
230
  //#region src/core/filterAsync.d.ts
231
231
  /**
232
- * Async-Version von filter.
232
+ * Async version of filter.
233
233
  */
234
234
  declare function filterAsync<T, E>(predicate: (val: T) => Promise<boolean>, errorFn: () => Promise<E>): (source: Result<T, E>) => Promise<Result<T, E>>;
235
235
  //#endregion
236
236
  //#region src/core/matchAsync.d.ts
237
237
  /**
238
- * Async-Version von match.
238
+ * Async version of match.
239
239
  */
240
240
  declare function matchAsync<T, E, R$1>(handlers: {
241
241
  ok: (val: T) => Promise<R$1>;
@@ -244,13 +244,13 @@ declare function matchAsync<T, E, R$1>(handlers: {
244
244
  //#endregion
245
245
  //#region src/core/tryCatchAsync.d.ts
246
246
  /**
247
- * Async-Version von tryCatch.
247
+ * Async version of tryCatch.
248
248
  */
249
249
  declare function tryCatchAsync<T, E = unknown>(fn: () => Promise<T>, errorMapper?: (error: unknown) => E): (source: Result<any, any>) => Promise<Result<T, E>>;
250
250
  //#endregion
251
251
  //#region src/core/tryMapAsync.d.ts
252
252
  /**
253
- * Async-Version von tryMap.
253
+ * Async version of tryMap.
254
254
  */
255
255
  declare function tryMapAsync<T, E, U, F = unknown>(project: (value: T) => Promise<U>, errorMapper?: (error: unknown) => F): (source: Result<T, E>) => Promise<Result<U, E | F>>;
256
256
  //#endregion
@@ -289,21 +289,21 @@ declare abstract class ResultBase extends Pipeable {
289
289
  */
290
290
  [Symbol.iterator](): Generator<unknown, OkValue<this>, unknown>;
291
291
  /**
292
- * Matcht auf den Err-Wert via `.when(...)` Kette.
292
+ * Matches on the Err value via `.when(...)` chain.
293
293
  *
294
- * Hinweis: aus Type-Safety-Gründen ist `.match()` nur auf einem bereits zu `Err` verengten Result aufrufbar,
295
- * z.B. innerhalb von `if (result.isErr()) { ... }`.
294
+ * Note: for type safety reasons, `.match()` can only be called on a Result already narrowed to `Err`,
295
+ * e.g. inside `if (result.isErr()) { ... }`.
296
296
  */
297
297
  match<T, E>(this: Result<T, E>): ErrorMatchBuilder<E, never>;
298
298
  /**
299
- * Matcht auf den Err-Wert, aber normalisiert jeden Branch zu einem `Result`:
300
- * - Handler dürfen ein `Result` zurückgeben (wird direkt returned)
301
- * - oder einen Error-Wert (wird zu `Err(error)` gewrappt)
299
+ * Matches on the Err value, but normalizes every branch to a `Result`:
300
+ * - Handlers may return a `Result` (is returned directly)
301
+ * - or an Error value (is wrapped into `Err(error)`)
302
302
  */
303
303
  matchErr<T, E>(this: Result<T, E>): ErrMatchBuilder<T, E, never, never>;
304
304
  /**
305
- * Serialisiert das Result in ein einfaches Objekt-Format.
306
- * Behält die ursprünglichen Typen bei.
305
+ * Serializes the Result into a simple object format.
306
+ * Preserves the original types.
307
307
  */
308
308
  serialize<T, E>(this: Result<T, E>): {
309
309
  isSuccess: boolean;
@@ -311,8 +311,8 @@ declare abstract class ResultBase extends Pipeable {
311
311
  error?: E;
312
312
  };
313
313
  /**
314
- * Serialisiert das Result in ein user-friendly Format.
315
- * Konvertiert Errors zu lesbaren Strings.
314
+ * Serializes the Result into a user-friendly format.
315
+ * Converts Errors to readable strings.
316
316
  */
317
317
  toUserFriendly<T, E>(this: Result<T, E>): {
318
318
  isSuccess: boolean;
@@ -372,6 +372,52 @@ declare function task<const Y, const R$1>(makeGenerator: () => AnyGenerator<Y, R
372
372
  declare function task<const Y, const R$1, EThrown>(makeGenerator: () => AnyGenerator<Y, R$1, unknown>, onThrow: OnThrow<EThrown>): Promise<Result<OkOfReturn<R$1>, ErrorOfYield<Y> | ErrOfReturn<R$1> | EThrown>>;
373
373
  declare const gen: typeof task;
374
374
  //#endregion
375
+ //#region src/errors.d.ts
376
+ declare const ERR_INVALID_STATE: "ERR_INVALID_STATE";
377
+ declare const ERR_TASK_YIELD_NOT_RESULT: "ERR_TASK_YIELD_NOT_RESULT";
378
+ declare const ERR_MATCH_ON_OK: "ERR_MATCH_ON_OK";
379
+ declare const ERR_UNWRAP_ON_ERR: "ERR_UNWRAP_ON_ERR";
380
+ declare const ERR_UNWRAP_ERR_ON_OK: "ERR_UNWRAP_ERR_ON_OK";
381
+ declare const ERR_EXPECT_OK: "ERR_EXPECT_OK";
382
+ declare const ERR_EXPECT_ERR: "ERR_EXPECT_ERR";
383
+ type ResultErrorCode = typeof ERR_INVALID_STATE | typeof ERR_TASK_YIELD_NOT_RESULT | typeof ERR_MATCH_ON_OK | typeof ERR_UNWRAP_ON_ERR | typeof ERR_UNWRAP_ERR_ON_OK | typeof ERR_EXPECT_OK | typeof ERR_EXPECT_ERR;
384
+ declare class ResultError extends Error {
385
+ readonly code: ResultErrorCode;
386
+ readonly context?: string;
387
+ constructor(message: string, code: ResultErrorCode, context?: string);
388
+ }
389
+ declare class ResultTypeError extends TypeError {
390
+ readonly code: ResultErrorCode;
391
+ readonly context?: string;
392
+ constructor(message: string, code: ResultErrorCode, context?: string);
393
+ }
394
+ declare class InvalidResultStateError extends ResultError {
395
+ constructor(context?: string);
396
+ }
397
+ declare class TaskYieldNotResultError extends ResultTypeError {
398
+ readonly yieldedValue: unknown;
399
+ constructor(yieldedValue: unknown);
400
+ }
401
+ declare class MatchOnOkError extends ResultTypeError {
402
+ constructor();
403
+ }
404
+ declare class UnwrapOnErrError extends ResultTypeError {
405
+ readonly errorValue: unknown;
406
+ constructor(errorValue: unknown);
407
+ }
408
+ declare class UnwrapErrOnOkError extends ResultTypeError {
409
+ readonly okValue: unknown;
410
+ constructor(okValue: unknown);
411
+ }
412
+ declare class ExpectOkError extends ResultError {
413
+ readonly expectedMessage: string;
414
+ constructor(expectedMessage: string);
415
+ }
416
+ declare class ExpectErrError extends ResultError {
417
+ readonly expectedMessage: string;
418
+ constructor(expectedMessage: string);
419
+ }
420
+ //#endregion
375
421
  //#region src/core/fold.d.ts
376
422
  /**
377
423
  * Folds the Result into a single value by applying one of two functions.
@@ -398,104 +444,104 @@ declare function foldAsync<T, E, R$1>(handlers: {
398
444
  //#endregion
399
445
  //#region src/core/unwrap.d.ts
400
446
  /**
401
- * Gibt den Wert zurück oder wirft einen Error.
402
- * Entspricht Rust `unwrap`.
447
+ * Returns the value or throws an Error.
448
+ * Corresponds to Rust `unwrap`.
403
449
  */
404
450
  declare function unwrap<T, E>(result: Result<T, E>): T;
405
451
  //#endregion
406
452
  //#region src/core/unwrapOr.d.ts
407
453
  /**
408
- * Gibt den Wert zurück oder einen Default-Wert.
409
- * Pure function Alternative zur Instanz-Methode.
454
+ * Returns the value or a default value.
455
+ * Pure function alternative to the instance method.
410
456
  */
411
457
  declare function unwrapOr<T, E>(result: Result<T, E>, defaultValue: T): T;
412
458
  //#endregion
413
459
  //#region src/core/unwrapOrElse.d.ts
414
460
  /**
415
- * Gibt den Wert zurück oder berechnet einen Default-Wert mit einer Funktion.
416
- * Entspricht Rust `unwrap_or_else`.
461
+ * Returns the value or calculates a default value using a function.
462
+ * Corresponds to Rust `unwrap_or_else`.
417
463
  */
418
464
  declare function unwrapOrElse<T, E>(result: Result<T, E>, fn: (error: E) => T): T;
419
465
  //#endregion
420
466
  //#region src/core/unwrapOrDefault.d.ts
421
467
  /**
422
- * Alias für `unwrapOr`.
423
- * Entspricht Rust `unwrap_or_default` (mit explizitem Default-Wert).
468
+ * Alias for `unwrapOr`.
469
+ * Corresponds to Rust `unwrap_or_default` (with explicit default value).
424
470
  */
425
471
  declare function unwrapOrDefault<T, E>(result: Result<T, E>, defaultValue: T): T;
426
472
  //#endregion
427
473
  //#region src/core/unwrapOrThrow.d.ts
428
474
  /**
429
- * Gibt den Wert zurück oder wirft den originalen Err-Wert (nicht gewrappt).
430
- * Nützlich um `Error`-Instanzen inkl. Stacktrace zu erhalten.
475
+ * Returns the value or throws the original Err value (not wrapped).
476
+ * Useful to preserve `Error` instances including stack traces.
431
477
  */
432
478
  declare function unwrapOrThrow<T, E>(result: Result<T, E>): T;
433
479
  //#endregion
434
480
  //#region src/core/unwrapErr.d.ts
435
481
  /**
436
- * Gibt den Fehler zurück oder wirft einen Error.
437
- * Entspricht Rust `unwrap_err`.
482
+ * Returns the error or throws an Error.
483
+ * Corresponds to Rust `unwrap_err`.
438
484
  */
439
485
  declare function unwrapErr<T, E>(result: Result<T, E>): E;
440
486
  //#endregion
441
487
  //#region src/core/expectResult.d.ts
442
488
  /**
443
- * Gibt den Wert zurück oder wirft einen Error mit custom Nachricht.
444
- * Entspricht Rust `expect`.
489
+ * Returns the value or throws an Error with a custom message.
490
+ * Corresponds to Rust `expect`.
445
491
  */
446
492
  declare function expectResult<T, E>(result: Result<T, E>, message: string): T;
447
493
  //#endregion
448
494
  //#region src/core/expectErr.d.ts
449
495
  /**
450
- * Gibt den Fehler zurück oder wirft einen Error mit custom Nachricht.
451
- * Entspricht Rust `expect_err`.
496
+ * Returns the error or throws an Error with a custom message.
497
+ * Corresponds to Rust `expect_err`.
452
498
  */
453
499
  declare function expectErr<T, E>(result: Result<T, E>, message: string): E;
454
500
  //#endregion
455
501
  //#region src/core/and.d.ts
456
502
  /**
457
- * Kombiniert zwei Results. Gibt den zweiten zurück nur wenn erster Ok ist.
458
- * Entspricht Rust `and`.
503
+ * Combines two Results. Returns the second one only if the first is Ok.
504
+ * Corresponds to Rust `and`.
459
505
  */
460
506
  declare function and<T, E, U>(result: Result<T, E>, other: Result<U, E>): Result<U, E>;
461
507
  //#endregion
462
508
  //#region src/core/or.d.ts
463
509
  /**
464
- * Fallback zu einem anderen Result wenn erster Err ist.
465
- * Entspricht Rust `or`.
510
+ * Fallback to another Result if the first is Err.
511
+ * Corresponds to Rust `or`.
466
512
  */
467
513
  declare function or<T, E, F>(result: Result<T, E>, other: Result<T, F>): Result<T, F>;
468
514
  //#endregion
469
515
  //#region src/core/orElse.d.ts
470
516
  /**
471
- * Fallback mit einer Funktion die ein Result zurückgibt.
472
- * Entspricht Rust `or_else`.
517
+ * Fallback with a function that returns a Result.
518
+ * Corresponds to Rust `or_else`.
473
519
  */
474
520
  declare function orElse<T, E, F>(result: Result<T, E>, fn: (error: E) => Result<T, F>): Result<T, F>;
475
521
  //#endregion
476
522
  //#region src/core/mapOr.d.ts
477
523
  /**
478
- * Transformiert den Wert oder gibt einen Default-Wert zurück.
479
- * Entspricht Rust `map_or`.
524
+ * Transforms the value or returns a default value.
525
+ * Corresponds to Rust `map_or`.
480
526
  */
481
527
  declare function mapOr<T, E, U>(result: Result<T, E>, defaultValue: U, fn: (value: T) => U): U;
482
528
  //#endregion
483
529
  //#region src/core/mapOrElse.d.ts
484
530
  /**
485
- * Transformiert den Wert oder berechnet einen Default-Wert mit einer Funktion.
486
- * Entspricht Rust `map_or_else`.
531
+ * Transforms the value or calculates a default value using a function.
532
+ * Corresponds to Rust `map_or_else`.
487
533
  */
488
534
  declare function mapOrElse<T, E, U>(result: Result<T, E>, defaultFn: (error: E) => U, fn: (value: T) => U): U;
489
535
  //#endregion
490
536
  //#region src/core/sequence.d.ts
491
537
  /**
492
- * Kombiniert eine Liste von Results zu einem Result einer Liste.
493
- * Short-circuits beim ersten Err.
494
- * Analog zu Rust `collect::<Result<Vec<_>, _>>()`.
538
+ * Combines a list of Results into a single Result of a list.
539
+ * Short-circuits on the first Err.
540
+ * Analogous to Rust `collect::<Result<Vec<_>, _>>()`.
495
541
  */
496
542
  declare function sequence<T, E>(results: readonly Result<T, E>[]): Result<T[], E>;
497
543
  /**
498
- * Alias für `sequence`.
544
+ * Alias for `sequence`.
499
545
  */
500
546
  declare function all<T, E>(results: readonly Result<T, E>[]): Result<T[], E>;
501
547
  //#endregion
@@ -503,8 +549,8 @@ declare function all<T, E>(results: readonly Result<T, E>[]): Result<T[], E>;
503
549
  type OkValueOf$1<R$1> = R$1 extends Result<infer T, any> ? T : never;
504
550
  type ErrValueOf$1<R$1> = R$1 extends Result<any, infer E> ? E : never;
505
551
  /**
506
- * Wie `sequence`, aber für Records/Objekte.
507
- * Short-circuits beim ersten Err.
552
+ * Like `sequence`, but for Records/Objects.
553
+ * Short-circuits on the first Err.
508
554
  */
509
555
  declare function sequenceRecord<const R$1 extends Record<string, Result<any, any>>>(record: R$1): Result<{ [K in keyof R$1]: OkValueOf$1<R$1[K]> }, ErrValueOf$1<R$1[keyof R$1]>>;
510
556
  //#endregion
@@ -514,11 +560,11 @@ type ResolvedResult$1<I> = I extends (() => infer R) ? Awaited<R> : I extends Pr
514
560
  type OkValueOfInput$1<I> = ResolvedResult$1<I> extends Result<infer T, any> ? T : never;
515
561
  type ErrValueOfInput$1<I> = ResolvedResult$1<I> extends Result<any, infer E> ? E : never;
516
562
  /**
517
- * Async-Version von collectFirstOk.
563
+ * Async version of collectFirstOk.
518
564
  *
519
- * - Nimmt entweder bereits gestartete Promises oder "Thunks" (`() => Awaitable<Result<...>>`).
520
- * - Verarbeitet die Inputs strikt sequentiell (wie `for ... of` + `await`).
521
- * - Gibt das erste `Ok` zurück und sammelt alle Errors wenn kein `Ok` gefunden wird.
565
+ * - Takes either already started Promises or "Thunks" (`() => Awaitable<Result<...>>`).
566
+ * - Processes inputs strictly sequentially (like `for ... of` + `await`).
567
+ * - Returns the first `Ok` and collects all errors if no `Ok` is found.
522
568
  */
523
569
  declare function collectFirstOkAsync<const Inputs extends readonly CollectFirstOkAsyncInput$1[]>(inputs: Inputs): Promise<Result<OkValueOfInput$1<Inputs[number]>, ErrValueOfInput$1<Inputs[number]>[]>>;
524
570
  //#endregion
@@ -528,22 +574,22 @@ type ResolvedResult<I> = I extends (() => infer R) ? Awaited<R> : I extends Prom
528
574
  type OkValueOfInput<I> = ResolvedResult<I> extends Result<infer T, any> ? T : never;
529
575
  type ErrValueOfInput<I> = ResolvedResult<I> extends Result<any, infer E> ? E : never;
530
576
  /**
531
- * Parallel-Variante von `collectFirstOkAsync`.
577
+ * Parallel version of `collectFirstOkAsync`.
532
578
  *
533
- * - Startet alle Inputs sofort (Promises oder Thunks).
534
- * - Gibt das erste `Ok` zurück, sobald es verfügbar ist.
535
- * - Wenn kein `Ok` gefunden wird, gibt ein `Err` mit allen Error-Werten (in Input-Reihenfolge) zurück.
536
- * - Rejections werden als `ErrValue` behandelt (`caught as ErrValue`).
537
- * - Wenn mehrere Inputs ein `Ok` liefern, gewinnt das zuerst abgeschlossene Ergebnis.
538
- * Bei gleichzeitiger Completion gewinnt das zuerst beobachtete Ergebnis.
539
- * - Wenn kein `Ok` kommt und mindestens ein Input nie settled, bleibt das Promise offen.
579
+ * - Starts all inputs immediately (Promises or Thunks).
580
+ * - Returns the first `Ok` as soon as it is available.
581
+ * - If no `Ok` is found, returns an `Err` with all error values (in input order).
582
+ * - Rejections are treated as `ErrValue` (`caught as ErrValue`).
583
+ * - If multiple inputs provide an `Ok`, the one that completes first wins.
584
+ * In case of simultaneous completion, the first observed result wins.
585
+ * - If no `Ok` arrives and at least one input never settles, the Promise remains pending.
540
586
  */
541
587
  declare function collectFirstOkParallelAsync<const Inputs extends readonly CollectFirstOkAsyncInput[]>(inputs: Inputs): Promise<Result<OkValueOfInput<Inputs[number]>, ErrValueOfInput<Inputs[number]>[]>>;
542
588
  //#endregion
543
589
  //#region src/core/collectAllErrors.d.ts
544
590
  /**
545
- * Kombiniert eine Liste von Results.
546
- * Gibt Ok(values) nur zurück wenn alle Ok sind, sonst Err([errors]).
591
+ * Combines a list of Results.
592
+ * Return Ok(values) only if all are Ok, otherwise Err([errors]).
547
593
  */
548
594
  declare function collectAllErrors<T, E>(results: readonly Result<T, E>[]): Result<T[], E[]>;
549
595
  //#endregion
@@ -551,57 +597,57 @@ declare function collectAllErrors<T, E>(results: readonly Result<T, E>[]): Resul
551
597
  type OkValueOf<R$1> = R$1 extends Result<infer T, any> ? T : never;
552
598
  type ErrValueOf<R$1> = R$1 extends Result<any, infer E> ? E : never;
553
599
  /**
554
- * Partitioniert Results in Ok-Werte und Err-Fehler.
600
+ * Partitions Results into Ok values and Err errors.
555
601
  */
556
602
  declare function partition<const Results extends readonly Result<any, any>[]>(results: Results): [oks: Array<OkValueOf<Results[number]>>, errs: Array<ErrValueOf<Results[number]>>];
557
603
  //#endregion
558
604
  //#region src/core/flatten.d.ts
559
605
  /**
560
- * Flacht ein nested Result ab.
606
+ * Flattens a nested Result.
561
607
  * Result<Result<T, E>, E> → Result<T, E>
562
- * Entspricht Rust `flatten`.
608
+ * Corresponds to Rust `flatten`.
563
609
  */
564
610
  declare function flatten<T, E>(result: Result<Result<T, E>, E>): Result<T, E>;
565
611
  //#endregion
566
612
  //#region src/core/toPromise.d.ts
567
613
  /**
568
- * Konvertiert ein Result zu einem Promise.
614
+ * Converts a Result to a Promise.
569
615
  * Ok → resolve(value), Err → reject(error)
570
616
  */
571
617
  declare function toPromise<T, E>(result: Result<T, E>): Promise<T>;
572
618
  //#endregion
573
619
  //#region src/core/toNullable.d.ts
574
620
  /**
575
- * Konvertiert ein Result zu `T | null`.
621
+ * Converts a Result to `T | null`.
576
622
  * Ok → value, Err → null
577
623
  */
578
624
  declare function toNullable<T, E>(result: Result<T, E>): T | null;
579
625
  //#endregion
580
626
  //#region src/core/isOk.d.ts
581
627
  /**
582
- * Prüft ob ein Result Ok ist.
583
- * Pure function Alternative zur Instanz-Methode.
628
+ * Checks if a Result is Ok.
629
+ * Pure function alternative to the instance method.
584
630
  */
585
631
  declare function isOk<T, E>(result: Result<T, E>): result is Ok<T, E>;
586
632
  //#endregion
587
633
  //#region src/core/isErr.d.ts
588
634
  /**
589
- * Prüft ob ein Result Err ist.
590
- * Pure function Alternative zur Instanz-Methode.
635
+ * Checks if a Result is Err.
636
+ * Pure function alternative to the instance method.
591
637
  */
592
638
  declare function isErr<T, E>(result: Result<T, E>): result is Err<T, E>;
593
639
  //#endregion
594
640
  //#region src/core/contains.d.ts
595
641
  /**
596
- * Prüft ob das Result einen bestimmten Wert enthält.
597
- * Entspricht Rust `contains`.
642
+ * Checks if the Result contains a specific value.
643
+ * Corresponds to Rust `contains`.
598
644
  */
599
645
  declare function contains<T, E>(result: Result<T, E>, value: T): boolean;
600
646
  //#endregion
601
647
  //#region src/core/containsErr.d.ts
602
648
  /**
603
- * Prüft ob das Result einen bestimmten Fehler enthält.
604
- * Analog zu `contains` für den Err-Fall.
649
+ * Checks if the Result contains a specific error.
650
+ * Analogous to `contains` for the Err case.
605
651
  */
606
652
  declare function containsErr<T, E>(result: Result<T, E>, error: E): boolean;
607
653
  //#endregion
@@ -612,5 +658,5 @@ declare function containsErr<T, E>(result: Result<T, E>, error: E): boolean;
612
658
  */
613
659
  declare function isResult(value: unknown): value is Result<any, any>;
614
660
  //#endregion
615
- export { AsyncOperatorFunction, type Awaitable, Err, Ok, OperatorFunction, Result, ResultType, all, and, bimap, collectAllErrors, collectFirstOk, collectFirstOkAsync, collectFirstOkParallelAsync, combine, contains, containsErr, err, expectErr, expectResult, filter, filterAsync, flatMap, flatMapAsync, flatten, fold, foldAsync, fromNullable, fromPromise, gen, isErr, isOk, isResult, map, mapAsync, mapBoth, mapErr, mapErrAsync, mapOr, mapOrElse, match, matchAsync, ok, okIf, okIfLazy, or, orElse, partition, recover, recoverWith, sequence, sequenceRecord, swap, tap, tapAsync, task, toNullable, toPromise, tryCatch, tryCatchAsync, tryFn, tryMap, tryMapAsync, unwrap, unwrapErr, unwrapOr, unwrapOrDefault, unwrapOrElse, unwrapOrThrow, zip };
661
+ export { AsyncOperatorFunction, type Awaitable, ERR_EXPECT_ERR, ERR_EXPECT_OK, ERR_INVALID_STATE, ERR_MATCH_ON_OK, ERR_TASK_YIELD_NOT_RESULT, ERR_UNWRAP_ERR_ON_OK, ERR_UNWRAP_ON_ERR, Err, ExpectErrError, ExpectOkError, InvalidResultStateError, MatchOnOkError, Ok, OperatorFunction, Result, ResultError, ResultErrorCode, ResultType, ResultTypeError, TaskYieldNotResultError, UnwrapErrOnOkError, UnwrapOnErrError, all, and, bimap, collectAllErrors, collectFirstOk, collectFirstOkAsync, collectFirstOkParallelAsync, combine, contains, containsErr, err, expectErr, expectResult, filter, filterAsync, flatMap, flatMapAsync, flatten, fold, foldAsync, fromNullable, fromPromise, gen, isErr, isOk, isResult, map, mapAsync, mapBoth, mapErr, mapErrAsync, mapOr, mapOrElse, match, matchAsync, ok, okIf, okIfLazy, or, orElse, partition, recover, recoverWith, sequence, sequenceRecord, swap, tap, tapAsync, task, toNullable, toPromise, tryCatch, tryCatchAsync, tryFn, tryMap, tryMapAsync, unwrap, unwrapErr, unwrapOr, unwrapOrDefault, unwrapOrElse, unwrapOrThrow, zip };
616
662
  //# sourceMappingURL=index.d.mts.map