@shirudo/result 0.0.1 → 0.0.2

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
@@ -1,371 +1,285 @@
1
- //#region src/pipeable.d.ts
1
+ //#region src/core/pipeable.d.ts
2
2
  type UnaryFunction<Input, Output> = (input: Input) => Output;
3
3
  type Awaitable<T> = T | Promise<T>;
4
4
  declare abstract class Pipeable {
5
- pipe(): this;
6
- pipe<B>(ab: UnaryFunction<this, B>): B;
7
- pipe<B, C>(ab: UnaryFunction<this, B>, bc: UnaryFunction<B, C>): C;
8
- pipe<B, C, D>(ab: UnaryFunction<this, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>): D;
9
- pipe<A, B, C, D, E>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>): E;
10
- pipe<A, B, C, D, E, F>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>): F;
11
- pipe<A, B, C, D, E, F, G>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>): G;
12
- pipe<A, B, C, D, E, F, G, H>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>): H;
13
- pipe<A, B, C, D, E, F, G, H, I>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>): I;
14
- pipe<A, B, C, D, E, F, G, H, I, J>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>, ij: UnaryFunction<I, J>): J;
15
- pipe<A, B, C, D, E, F, G, H, I, J, K$1>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>, ij: UnaryFunction<I, J>, jk: UnaryFunction<J, K$1>): K$1;
16
- pipe<A, B, C, D, E, F, G, H, I, J, K$1, L>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>, ij: UnaryFunction<I, J>, jk: UnaryFunction<J, K$1>, kl: UnaryFunction<K$1, L>): L;
17
- pipe<A, B, C, D, E, F, G, H, I, J, K$1, L, M>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>, ij: UnaryFunction<I, J>, jk: UnaryFunction<J, K$1>, kl: UnaryFunction<K$1, L>, lm: UnaryFunction<L, M>): M;
18
- pipe<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>, ij: UnaryFunction<I, J>, jk: UnaryFunction<J, K$1>, kl: UnaryFunction<K$1, L>, lm: UnaryFunction<L, M>, mn: UnaryFunction<M, N>): N;
19
- pipe<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>, ij: UnaryFunction<I, J>, jk: UnaryFunction<J, K$1>, kl: UnaryFunction<K$1, L>, lm: UnaryFunction<L, M>, mn: UnaryFunction<M, N>, no: UnaryFunction<N, O>): O;
20
- pipe<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O, P>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>, ij: UnaryFunction<I, J>, jk: UnaryFunction<J, K$1>, kl: UnaryFunction<K$1, L>, lm: UnaryFunction<L, M>, mn: UnaryFunction<M, N>, no: UnaryFunction<N, O>, op: UnaryFunction<O, P>): P;
21
- pipe<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O, P, Q>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>, ij: UnaryFunction<I, J>, jk: UnaryFunction<J, K$1>, kl: UnaryFunction<K$1, L>, lm: UnaryFunction<L, M>, mn: UnaryFunction<M, N>, no: UnaryFunction<N, O>, op: UnaryFunction<O, P>, pq: UnaryFunction<P, Q>): Q;
22
- pipe<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O, P, Q, R$1>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>, ij: UnaryFunction<I, J>, jk: UnaryFunction<J, K$1>, kl: UnaryFunction<K$1, L>, lm: UnaryFunction<L, M>, mn: UnaryFunction<M, N>, no: UnaryFunction<N, O>, op: UnaryFunction<O, P>, pq: UnaryFunction<P, Q>, qr: UnaryFunction<Q, R$1>): R$1;
23
- pipe<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O, P, Q, R$1, S>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>, ij: UnaryFunction<I, J>, jk: UnaryFunction<J, K$1>, kl: UnaryFunction<K$1, L>, lm: UnaryFunction<L, M>, mn: UnaryFunction<M, N>, no: UnaryFunction<N, O>, op: UnaryFunction<O, P>, pq: UnaryFunction<P, Q>, qr: UnaryFunction<Q, R$1>, rs: UnaryFunction<R$1, S>): S;
24
- pipe<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O, P, Q, R$1, S, T>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>, ij: UnaryFunction<I, J>, jk: UnaryFunction<J, K$1>, kl: UnaryFunction<K$1, L>, lm: UnaryFunction<L, M>, mn: UnaryFunction<M, N>, no: UnaryFunction<N, O>, op: UnaryFunction<O, P>, pq: UnaryFunction<P, Q>, qr: UnaryFunction<Q, R$1>, rs: UnaryFunction<R$1, S>, st: UnaryFunction<S, T>): T;
25
- pipe<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O, P, Q, R$1, S, T, U>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>, ij: UnaryFunction<I, J>, jk: UnaryFunction<J, K$1>, kl: UnaryFunction<K$1, L>, lm: UnaryFunction<L, M>, mn: UnaryFunction<M, N>, no: UnaryFunction<N, O>, op: UnaryFunction<O, P>, pq: UnaryFunction<P, Q>, qr: UnaryFunction<Q, R$1>, rs: UnaryFunction<R$1, S>, st: UnaryFunction<S, T>, tu: UnaryFunction<T, U>): U;
5
+ pipe<A>(this: A): A;
6
+ pipe<A, B>(this: A, ab: UnaryFunction<A, B>): B;
7
+ pipe<A, B, C>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<B, C>): C;
8
+ pipe<A, B, C, D>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>): D;
9
+ pipe<A, B, C, D, E>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>): E;
10
+ pipe<A, B, C, D, E, F>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>): F;
11
+ pipe<A, B, C, D, E, F, G>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>): G;
12
+ pipe<A, B, C, D, E, F, G, H>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>): H;
13
+ pipe<A, B, C, D, E, F, G, H, I>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>): I;
14
+ pipe<A, B, C, D, E, F, G, H, I, J>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>, ij: UnaryFunction<I, J>): J;
15
+ pipe<A, B, C, D, E, F, G, H, I, J, K$1>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>, ij: UnaryFunction<I, J>, jk: UnaryFunction<J, K$1>): K$1;
16
+ pipe<A, B, C, D, E, F, G, H, I, J, K$1, L>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>, ij: UnaryFunction<I, J>, jk: UnaryFunction<J, K$1>, kl: UnaryFunction<K$1, L>): L;
17
+ pipe<A, B, C, D, E, F, G, H, I, J, K$1, L, M>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>, ij: UnaryFunction<I, J>, jk: UnaryFunction<J, K$1>, kl: UnaryFunction<K$1, L>, lm: UnaryFunction<L, M>): M;
18
+ pipe<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>, ij: UnaryFunction<I, J>, jk: UnaryFunction<J, K$1>, kl: UnaryFunction<K$1, L>, lm: UnaryFunction<L, M>, mn: UnaryFunction<M, N>): N;
19
+ pipe<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>, ij: UnaryFunction<I, J>, jk: UnaryFunction<J, K$1>, kl: UnaryFunction<K$1, L>, lm: UnaryFunction<L, M>, mn: UnaryFunction<M, N>, no: UnaryFunction<N, O>): O;
20
+ pipe<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O, P>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>, ij: UnaryFunction<I, J>, jk: UnaryFunction<J, K$1>, kl: UnaryFunction<K$1, L>, lm: UnaryFunction<L, M>, mn: UnaryFunction<M, N>, no: UnaryFunction<N, O>, op: UnaryFunction<O, P>): P;
21
+ pipe<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O, P, Q>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>, ij: UnaryFunction<I, J>, jk: UnaryFunction<J, K$1>, kl: UnaryFunction<K$1, L>, lm: UnaryFunction<L, M>, mn: UnaryFunction<M, N>, no: UnaryFunction<N, O>, op: UnaryFunction<O, P>, pq: UnaryFunction<P, Q>): Q;
22
+ pipe<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O, P, Q, R$1>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>, ij: UnaryFunction<I, J>, jk: UnaryFunction<J, K$1>, kl: UnaryFunction<K$1, L>, lm: UnaryFunction<L, M>, mn: UnaryFunction<M, N>, no: UnaryFunction<N, O>, op: UnaryFunction<O, P>, pq: UnaryFunction<P, Q>, qr: UnaryFunction<Q, R$1>): R$1;
23
+ pipe<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O, P, Q, R$1, S>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>, ij: UnaryFunction<I, J>, jk: UnaryFunction<J, K$1>, kl: UnaryFunction<K$1, L>, lm: UnaryFunction<L, M>, mn: UnaryFunction<M, N>, no: UnaryFunction<N, O>, op: UnaryFunction<O, P>, pq: UnaryFunction<P, Q>, qr: UnaryFunction<Q, R$1>, rs: UnaryFunction<R$1, S>): S;
24
+ pipe<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O, P, Q, R$1, S, T>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>, ij: UnaryFunction<I, J>, jk: UnaryFunction<J, K$1>, kl: UnaryFunction<K$1, L>, lm: UnaryFunction<L, M>, mn: UnaryFunction<M, N>, no: UnaryFunction<N, O>, op: UnaryFunction<O, P>, pq: UnaryFunction<P, Q>, qr: UnaryFunction<Q, R$1>, rs: UnaryFunction<R$1, S>, st: UnaryFunction<S, T>): T;
25
+ pipe<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O, P, Q, R$1, S, T, U>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<B, C>, cd: UnaryFunction<C, D>, de: UnaryFunction<D, E>, ef: UnaryFunction<E, F>, fg: UnaryFunction<F, G>, gh: UnaryFunction<G, H>, hi: UnaryFunction<H, I>, ij: UnaryFunction<I, J>, jk: UnaryFunction<J, K$1>, kl: UnaryFunction<K$1, L>, lm: UnaryFunction<L, M>, mn: UnaryFunction<M, N>, no: UnaryFunction<N, O>, op: UnaryFunction<O, P>, pq: UnaryFunction<P, Q>, qr: UnaryFunction<Q, R$1>, rs: UnaryFunction<R$1, S>, st: UnaryFunction<S, T>, tu: UnaryFunction<T, U>): U;
26
26
  pipeAsync<A>(this: A): Promise<A>;
27
- pipeAsync<A, B>(this: A, ab: UnaryFunction<this, B>): Promise<Awaited<B>>;
28
- pipeAsync<A, B, C>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<Awaited<B>, C>): Promise<Awaited<C>>;
29
- pipeAsync<A, B, C, D>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>): Promise<Awaited<D>>;
30
- pipeAsync<A, B, C, D, E>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>): Promise<Awaited<E>>;
31
- pipeAsync<A, B, C, D, E, F>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>): Promise<Awaited<F>>;
32
- pipeAsync<A, B, C, D, E, F, G>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>): Promise<Awaited<G>>;
33
- pipeAsync<A, B, C, D, E, F, G, H>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>): Promise<Awaited<H>>;
34
- pipeAsync<A, B, C, D, E, F, G, H, I>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>): Promise<Awaited<I>>;
35
- pipeAsync<A, B, C, D, E, F, G, H, I, J>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>, ij: UnaryFunction<Awaited<I>, J>): Promise<Awaited<J>>;
36
- pipeAsync<A, B, C, D, E, F, G, H, I, J, K$1>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>, ij: UnaryFunction<Awaited<I>, J>, jk: UnaryFunction<Awaited<J>, K$1>): Promise<Awaited<K$1>>;
37
- pipeAsync<A, B, C, D, E, F, G, H, I, J, K$1, L>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>, ij: UnaryFunction<Awaited<I>, J>, jk: UnaryFunction<Awaited<J>, K$1>, kl: UnaryFunction<Awaited<K$1>, L>): Promise<Awaited<L>>;
38
- pipeAsync<A, B, C, D, E, F, G, H, I, J, K$1, L, M>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>, ij: UnaryFunction<Awaited<I>, J>, jk: UnaryFunction<Awaited<J>, K$1>, kl: UnaryFunction<Awaited<K$1>, L>, lm: UnaryFunction<Awaited<L>, M>): Promise<Awaited<M>>;
39
- pipeAsync<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>, ij: UnaryFunction<Awaited<I>, J>, jk: UnaryFunction<Awaited<J>, K$1>, kl: UnaryFunction<Awaited<K$1>, L>, lm: UnaryFunction<Awaited<L>, M>, mn: UnaryFunction<Awaited<M>, N>): Promise<Awaited<N>>;
40
- pipeAsync<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>, ij: UnaryFunction<Awaited<I>, J>, jk: UnaryFunction<Awaited<J>, K$1>, kl: UnaryFunction<Awaited<K$1>, L>, lm: UnaryFunction<Awaited<L>, M>, mn: UnaryFunction<Awaited<M>, N>, no: UnaryFunction<Awaited<N>, O>): Promise<Awaited<O>>;
41
- pipeAsync<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O, P>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>, ij: UnaryFunction<Awaited<I>, J>, jk: UnaryFunction<Awaited<J>, K$1>, kl: UnaryFunction<Awaited<K$1>, L>, lm: UnaryFunction<Awaited<L>, M>, mn: UnaryFunction<Awaited<M>, N>, no: UnaryFunction<Awaited<N>, O>, op: UnaryFunction<Awaited<O>, P>): Promise<Awaited<P>>;
42
- pipeAsync<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O, P, Q>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>, ij: UnaryFunction<Awaited<I>, J>, jk: UnaryFunction<Awaited<J>, K$1>, kl: UnaryFunction<Awaited<K$1>, L>, lm: UnaryFunction<Awaited<L>, M>, mn: UnaryFunction<Awaited<M>, N>, no: UnaryFunction<Awaited<N>, O>, op: UnaryFunction<Awaited<O>, P>, pq: UnaryFunction<Awaited<P>, Q>): Promise<Awaited<Q>>;
43
- pipeAsync<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O, P, Q, R$1>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>, ij: UnaryFunction<Awaited<I>, J>, jk: UnaryFunction<Awaited<J>, K$1>, kl: UnaryFunction<Awaited<K$1>, L>, lm: UnaryFunction<Awaited<L>, M>, mn: UnaryFunction<Awaited<M>, N>, no: UnaryFunction<Awaited<N>, O>, op: UnaryFunction<Awaited<O>, P>, pq: UnaryFunction<Awaited<P>, Q>, qr: UnaryFunction<Awaited<Q>, R$1>): Promise<Awaited<R$1>>;
44
- pipeAsync<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O, P, Q, R$1, S>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>, ij: UnaryFunction<Awaited<I>, J>, jk: UnaryFunction<Awaited<J>, K$1>, kl: UnaryFunction<Awaited<K$1>, L>, lm: UnaryFunction<Awaited<L>, M>, mn: UnaryFunction<Awaited<M>, N>, no: UnaryFunction<Awaited<N>, O>, op: UnaryFunction<Awaited<O>, P>, pq: UnaryFunction<Awaited<P>, Q>, qr: UnaryFunction<Awaited<Q>, R$1>, rs: UnaryFunction<Awaited<R$1>, S>): Promise<Awaited<S>>;
45
- pipeAsync<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O, P, Q, R$1, S, T>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>, ij: UnaryFunction<Awaited<I>, J>, jk: UnaryFunction<Awaited<J>, K$1>, kl: UnaryFunction<Awaited<K$1>, L>, lm: UnaryFunction<Awaited<L>, M>, mn: UnaryFunction<Awaited<M>, N>, no: UnaryFunction<Awaited<N>, O>, op: UnaryFunction<Awaited<O>, P>, pq: UnaryFunction<Awaited<P>, Q>, qr: UnaryFunction<Awaited<Q>, R$1>, rs: UnaryFunction<Awaited<R$1>, S>, st: UnaryFunction<Awaited<S>, T>): Promise<Awaited<T>>;
46
- pipeAsync<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O, P, Q, R$1, S, T, U>(this: A, ab: UnaryFunction<this, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>, ij: UnaryFunction<Awaited<I>, J>, jk: UnaryFunction<Awaited<J>, K$1>, kl: UnaryFunction<Awaited<K$1>, L>, lm: UnaryFunction<Awaited<L>, M>, mn: UnaryFunction<Awaited<M>, N>, no: UnaryFunction<Awaited<N>, O>, op: UnaryFunction<Awaited<O>, P>, pq: UnaryFunction<Awaited<P>, Q>, qr: UnaryFunction<Awaited<Q>, R$1>, rs: UnaryFunction<Awaited<R$1>, S>, st: UnaryFunction<Awaited<S>, T>, tu: UnaryFunction<Awaited<T>, U>): Promise<Awaited<U>>;
27
+ pipeAsync<A, B>(this: A, ab: UnaryFunction<A, B>): Promise<Awaited<B>>;
28
+ pipeAsync<A, B, C>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<Awaited<B>, C>): Promise<Awaited<C>>;
29
+ pipeAsync<A, B, C, D>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>): Promise<Awaited<D>>;
30
+ pipeAsync<A, B, C, D, E>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>): Promise<Awaited<E>>;
31
+ pipeAsync<A, B, C, D, E, F>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>): Promise<Awaited<F>>;
32
+ pipeAsync<A, B, C, D, E, F, G>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>): Promise<Awaited<G>>;
33
+ pipeAsync<A, B, C, D, E, F, G, H>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>): Promise<Awaited<H>>;
34
+ pipeAsync<A, B, C, D, E, F, G, H, I>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>): Promise<Awaited<I>>;
35
+ pipeAsync<A, B, C, D, E, F, G, H, I, J>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>, ij: UnaryFunction<Awaited<I>, J>): Promise<Awaited<J>>;
36
+ pipeAsync<A, B, C, D, E, F, G, H, I, J, K$1>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>, ij: UnaryFunction<Awaited<I>, J>, jk: UnaryFunction<Awaited<J>, K$1>): Promise<Awaited<K$1>>;
37
+ pipeAsync<A, B, C, D, E, F, G, H, I, J, K$1, L>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>, ij: UnaryFunction<Awaited<I>, J>, jk: UnaryFunction<Awaited<J>, K$1>, kl: UnaryFunction<Awaited<K$1>, L>): Promise<Awaited<L>>;
38
+ pipeAsync<A, B, C, D, E, F, G, H, I, J, K$1, L, M>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>, ij: UnaryFunction<Awaited<I>, J>, jk: UnaryFunction<Awaited<J>, K$1>, kl: UnaryFunction<Awaited<K$1>, L>, lm: UnaryFunction<Awaited<L>, M>): Promise<Awaited<M>>;
39
+ pipeAsync<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>, ij: UnaryFunction<Awaited<I>, J>, jk: UnaryFunction<Awaited<J>, K$1>, kl: UnaryFunction<Awaited<K$1>, L>, lm: UnaryFunction<Awaited<L>, M>, mn: UnaryFunction<Awaited<M>, N>): Promise<Awaited<N>>;
40
+ pipeAsync<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>, ij: UnaryFunction<Awaited<I>, J>, jk: UnaryFunction<Awaited<J>, K$1>, kl: UnaryFunction<Awaited<K$1>, L>, lm: UnaryFunction<Awaited<L>, M>, mn: UnaryFunction<Awaited<M>, N>, no: UnaryFunction<Awaited<N>, O>): Promise<Awaited<O>>;
41
+ pipeAsync<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O, P>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>, ij: UnaryFunction<Awaited<I>, J>, jk: UnaryFunction<Awaited<J>, K$1>, kl: UnaryFunction<Awaited<K$1>, L>, lm: UnaryFunction<Awaited<L>, M>, mn: UnaryFunction<Awaited<M>, N>, no: UnaryFunction<Awaited<N>, O>, op: UnaryFunction<Awaited<O>, P>): Promise<Awaited<P>>;
42
+ pipeAsync<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O, P, Q>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>, ij: UnaryFunction<Awaited<I>, J>, jk: UnaryFunction<Awaited<J>, K$1>, kl: UnaryFunction<Awaited<K$1>, L>, lm: UnaryFunction<Awaited<L>, M>, mn: UnaryFunction<Awaited<M>, N>, no: UnaryFunction<Awaited<N>, O>, op: UnaryFunction<Awaited<O>, P>, pq: UnaryFunction<Awaited<P>, Q>): Promise<Awaited<Q>>;
43
+ pipeAsync<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O, P, Q, R$1>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>, ij: UnaryFunction<Awaited<I>, J>, jk: UnaryFunction<Awaited<J>, K$1>, kl: UnaryFunction<Awaited<K$1>, L>, lm: UnaryFunction<Awaited<L>, M>, mn: UnaryFunction<Awaited<M>, N>, no: UnaryFunction<Awaited<N>, O>, op: UnaryFunction<Awaited<O>, P>, pq: UnaryFunction<Awaited<P>, Q>, qr: UnaryFunction<Awaited<Q>, R$1>): Promise<Awaited<R$1>>;
44
+ pipeAsync<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O, P, Q, R$1, S>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>, ij: UnaryFunction<Awaited<I>, J>, jk: UnaryFunction<Awaited<J>, K$1>, kl: UnaryFunction<Awaited<K$1>, L>, lm: UnaryFunction<Awaited<L>, M>, mn: UnaryFunction<Awaited<M>, N>, no: UnaryFunction<Awaited<N>, O>, op: UnaryFunction<Awaited<O>, P>, pq: UnaryFunction<Awaited<P>, Q>, qr: UnaryFunction<Awaited<Q>, R$1>, rs: UnaryFunction<Awaited<R$1>, S>): Promise<Awaited<S>>;
45
+ pipeAsync<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O, P, Q, R$1, S, T>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>, ij: UnaryFunction<Awaited<I>, J>, jk: UnaryFunction<Awaited<J>, K$1>, kl: UnaryFunction<Awaited<K$1>, L>, lm: UnaryFunction<Awaited<L>, M>, mn: UnaryFunction<Awaited<M>, N>, no: UnaryFunction<Awaited<N>, O>, op: UnaryFunction<Awaited<O>, P>, pq: UnaryFunction<Awaited<P>, Q>, qr: UnaryFunction<Awaited<Q>, R$1>, rs: UnaryFunction<Awaited<R$1>, S>, st: UnaryFunction<Awaited<S>, T>): Promise<Awaited<T>>;
46
+ pipeAsync<A, B, C, D, E, F, G, H, I, J, K$1, L, M, N, O, P, Q, R$1, S, T, U>(this: A, ab: UnaryFunction<A, B>, bc: UnaryFunction<Awaited<B>, C>, cd: UnaryFunction<Awaited<C>, D>, de: UnaryFunction<Awaited<D>, E>, ef: UnaryFunction<Awaited<E>, F>, fg: UnaryFunction<Awaited<F>, G>, gh: UnaryFunction<Awaited<G>, H>, hi: UnaryFunction<Awaited<H>, I>, ij: UnaryFunction<Awaited<I>, J>, jk: UnaryFunction<Awaited<J>, K$1>, kl: UnaryFunction<Awaited<K$1>, L>, lm: UnaryFunction<Awaited<L>, M>, mn: UnaryFunction<Awaited<M>, N>, no: UnaryFunction<Awaited<N>, O>, op: UnaryFunction<Awaited<O>, P>, pq: UnaryFunction<Awaited<P>, Q>, qr: UnaryFunction<Awaited<Q>, R$1>, rs: UnaryFunction<Awaited<R$1>, S>, st: UnaryFunction<Awaited<S>, T>, tu: UnaryFunction<Awaited<T>, U>): Promise<Awaited<U>>;
47
47
  }
48
48
  //#endregion
49
- //#region src/matcher.d.ts
49
+ //#region src/core/matcher.d.ts
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 for Err values (returns any return type, e.g. string messages).
53
+ * Matcher für Err-Values (liefert einen beliebigen Return-Type, z.B. string messages).
54
54
  *
55
55
  * - `.when(Ctor, handler)` matched via `instanceof`
56
- * - `.whenGuard(guard, handler)` matched via type guard
57
- * - `.run()` is only allowed once all error cases are handled (`E` is reduced to `never`)
56
+ * - `.whenGuard(guard, handler)` matched via Type-Guard
57
+ * - `.run()` ist nur erlaubt, wenn alle Error-Cases behandelt wurden (`E` wurde zu `never` reduziert)
58
58
  */
59
59
  declare class ErrorMatchBuilder<E, R$1> {
60
60
  #private;
61
61
  constructor(error: unknown, matched?: boolean, value?: unknown);
62
- when<C extends Ctor<any>, R1>(ctor: C, handler: (error: InstanceType<C>) => R1): ErrorMatchBuilder<Exclude<E, InstanceType<C>>, R$1 | R1>;
62
+ when<C extends Ctor<E>, R1>(ctor: C, handler: (error: InstanceType<C>) => R1): ErrorMatchBuilder<Exclude<E, InstanceType<C>>, R$1 | R1>;
63
63
  whenGuard<A extends E, R1>(guard: TypeGuard<E, A>, handler: (error: A) => R1): ErrorMatchBuilder<Exclude<E, A>, R$1 | R1>;
64
- otherwise<R2>(handler: (error: any) => R2): R$1 | R2;
64
+ otherwise<R2>(handler: (error: E) => R2): R$1 | R2;
65
65
  run(this: ErrorMatchBuilder<never, R$1>): R$1;
66
66
  }
67
67
  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 for `Result` errors that always returns a `Result`.
71
+ * Matcher für `Result`-Errors, der immer wieder ein `Result` zurückgibt.
72
72
  *
73
- * Handlers may:
74
- * - return a `Result` (returned directly)
75
- * - return an error value (automatically wrapped to `Err(error)`)
73
+ * Handler dürfen:
74
+ * - ein `Result` zurückgeben (wird direkt returned)
75
+ * - einen Error-Wert zurückgeben (wird automatisch zu `Err(error)` gewrappt)
76
76
  */
77
77
  declare class ErrMatchBuilder<T, E, OutT, OutE> {
78
78
  #private;
79
79
  private constructor();
80
80
  static fromResult<T, E>(result: Result<T, E>, makeErr: ErrFactory): ErrMatchBuilder<T, E, never, never>;
81
- when<C extends Ctor<any>, R1>(ctor: C, handler: (error: InstanceType<C>) => R1): ErrMatchBuilder<T, Exclude<E, InstanceType<C>>, OutT | OkOfReturn$1<R1>, OutE | ErrOfReturn$1<R1>>;
81
+ when<C extends Ctor<E>, R1>(ctor: C, handler: (error: InstanceType<C>) => R1): ErrMatchBuilder<T, Exclude<E, InstanceType<C>>, OutT | OkOfReturn$1<R1>, OutE | ErrOfReturn$1<R1>>;
82
82
  whenGuard<A extends E, R1>(guard: TypeGuard<E, A>, handler: (error: A) => R1): ErrMatchBuilder<T, Exclude<E, A>, OutT | OkOfReturn$1<R1>, OutE | ErrOfReturn$1<R1>>;
83
83
  otherwise<R2>(handler: (error: E) => R2): Result<T | OutT | OkOfReturn$1<R2>, OutE | ErrOfReturn$1<R2>>;
84
84
  run(this: ErrMatchBuilder<T, never, OutT, OutE>): Result<T | OutT, OutE>;
85
85
  }
86
- type ErrCase = {
87
- readonly kind: 'ctor';
88
- readonly ctor: Ctor<any>;
89
- readonly handler: (error: any) => unknown;
90
- } | {
91
- readonly kind: 'val';
92
- readonly value: unknown;
93
- readonly handler: (error: any) => unknown;
94
- };
95
- declare const HAS_OK: unique symbol;
96
- type HasOk = {
97
- readonly [HAS_OK]: true;
98
- };
99
- type WithOk<T, E, R$1> = ResultMatchBuilder<T, E, R$1> & HasOk;
100
- type IsUnion<T, U = T> = T extends any ? ([U] extends [T] ? false : true) : never;
101
- type ExcludeIfLiteral<E, V> = IsUnion<V> extends true ? E : V extends string ? string extends V ? E : Exclude<E, V> : V extends number ? number extends V ? E : Exclude<E, V> : V extends boolean ? boolean extends V ? E : Exclude<E, V> : V extends bigint ? bigint extends V ? E : Exclude<E, V> : V extends symbol ? symbol extends V ? E : Exclude<E, V> : Exclude<E, V>;
86
+ //#endregion
87
+ //#region src/core/map.d.ts
102
88
  /**
103
- * Universal matcher for `Result` (Ok + Err in a single chain).
104
- *
105
- * - `.err(Ctor, handler)` matched via `instanceof`
106
- * - `.errVal(value, handler)` matched via `Object.is`
107
- * - `.ok(handler)` defines the success branch
108
- * - `.run()` is only allowed after `.ok()` is set
109
- *
110
- * Lazy: if the Result is `Ok`, Err cases are not evaluated in `.run()`.
89
+ * Transformiert den Wert (Ok-Fall).
90
+ * Entspricht Rust `map`.
111
91
  */
112
- declare class ResultMatchBuilder<T, E, R$1> {
113
- #private;
114
- constructor(result: Result<T, E>, errCases?: readonly ErrCase[], okHandler?: (value: T) => unknown);
115
- static fromResult<T, E>(result: Result<T, E>): ResultMatchBuilder<T, E, never>;
116
- err<C extends Ctor<any>, R1>(this: ResultMatchBuilder<T, E, R$1>, ctor: C, handler: (error: InstanceType<C>) => R1): ResultMatchBuilder<T, Exclude<E, InstanceType<C>>, R$1 | R1>;
117
- err<C extends Ctor<any>, R1>(this: WithOk<T, E, R$1>, ctor: C, handler: (error: InstanceType<C>) => R1): WithOk<T, Exclude<E, InstanceType<C>>, R$1 | R1>;
118
- errVal<const V, R1>(this: ResultMatchBuilder<T, E, R$1>, value: V, handler: (error: V) => R1): ResultMatchBuilder<T, ExcludeIfLiteral<E, V>, R$1 | R1>;
119
- errVal<const V, R1>(this: WithOk<T, E, R$1>, value: V, handler: (error: V) => R1): WithOk<T, ExcludeIfLiteral<E, V>, R$1 | R1>;
120
- ok<R1>(handler: (value: T) => R1): WithOk<T, E, R$1 | R1>;
121
- run(this: WithOk<T, E, R$1>): R$1;
122
- }
92
+ declare function map<T, E, U>(project: (value: T) => U): (source: Result<T, E>) => Result<U, E>;
93
+ //#endregion
94
+ //#region src/core/mapErr.d.ts
95
+ /**
96
+ * Transformiert den Fehler (Err-Fall).
97
+ * Entspricht Rust `map_err`.
98
+ */
99
+ declare function mapErr<T, E, F>(project: (error: E) => F): (source: Result<T, E>) => Result<T, F>;
100
+ //#endregion
101
+ //#region src/core/mapBoth.d.ts
102
+ /**
103
+ * Transformiert sowohl den Ok-Wert als auch den Err-Fehler.
104
+ * Entspricht FP `bimap` / `mapBoth`.
105
+ */
106
+ declare function mapBoth<T, E, U, F>(mapOk: (value: T) => U, mapErr: (error: E) => F): (source: Result<T, E>) => Result<U, F>;
107
+ /**
108
+ * Alias für `mapBoth`.
109
+ */
110
+ declare const bimap: typeof mapBoth;
111
+ //#endregion
112
+ //#region src/core/flatMap.d.ts
113
+ /**
114
+ * Verkettet eine weitere Operation, die ein Result zurückgibt.
115
+ * Entspricht Rust `and_then` oder JS `flatMap`.
116
+ */
117
+ declare function flatMap<T, E, U>(project: (value: T) => Result<U, E>): (source: Result<T, E>) => Result<U, E>;
123
118
  //#endregion
124
- //#region src/result.d.ts
119
+ //#region src/core/zip.d.ts
120
+ /**
121
+ * Kombiniert zwei Results zu einem Result eines Tupels.
122
+ * Short-circuits beim ersten Err (links vor rechts).
123
+ */
124
+ declare function zip<A, AE, B, BE>(left: Result<A, AE>, right: Result<B, BE>): Result<[A, B], AE | BE>;
125
+ declare function zip<A, AE, B, BE>(right: Result<B, BE>): (left: Result<A, AE>) => Result<[A, B], AE | BE>;
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)
130
+ */
131
+ declare function combine<A, AE, B, BE>(left: Result<A, AE>, right: Result<B, BE>): Result<[A, B], Array<AE | BE>>;
132
+ declare function combine<A, AE, B, BE>(right: Result<B, BE>): (left: Result<A, AE>) => Result<[A, B], Array<AE | BE>>;
133
+ //#endregion
134
+ //#region src/core/tap.d.ts
135
+ /**
136
+ * Führt einen Seiteneffekt aus (Logging, Debugging), ohne das Result zu ändern.
137
+ * Entspricht Rust `inspect` / `inspect_err`.
138
+ */
139
+ declare function tap<T, E>(observer: {
140
+ ok?: (val: T) => void;
141
+ err?: (e: E) => void;
142
+ }): (source: Result<T, E>) => Result<T, E>;
143
+ //#endregion
144
+ //#region src/core/filter.d.ts
145
+ /**
146
+ * Prüft eine Bedingung. Wenn falsch, wird das Result zu Err.
147
+ * Entspricht Rust `filter` (teilweise).
148
+ */
149
+ declare function filter<T, E>(predicate: (val: T) => boolean, errorFn: () => E): (source: Result<T, E>) => Result<T, E>;
150
+ //#endregion
151
+ //#region src/core/match.d.ts
152
+ /**
153
+ * Löst das Result auf. Das Ende der Pipe.
154
+ * Entspricht Rust `match`.
155
+ */
156
+ declare function match<T, E, R$1>(handlers: {
157
+ ok: (val: T) => R$1;
158
+ err: (e: E) => R$1;
159
+ }): (source: Result<T, E>) => R$1;
160
+ //#endregion
161
+ //#region src/core/recover.d.ts
162
+ /**
163
+ * Recover: wandelt Err in Ok(defaultValue) um.
164
+ * Ergebnis ist garantiert Ok → Error-Typ wird `never`.
165
+ */
166
+ declare function recover<T, E, F>(defaultValue: F): (source: Result<T, E>) => Result<T | F, never>;
167
+ /**
168
+ * Wie `recover`, aber berechnet den Default-Wert anhand des Errors.
169
+ */
170
+ declare function recoverWith<T, E, F>(fn: (error: E) => F): (source: Result<T, E>) => Result<T | F, never>;
171
+ //#endregion
172
+ //#region src/core/swap.d.ts
173
+ /**
174
+ * Tauscht Ok und Err.
175
+ * Result<T, E> → Result<E, T>
176
+ */
177
+ declare function swap<T, E>(result: Result<T, E>): Result<E, T>;
178
+ //#endregion
179
+ //#region src/core/tryCatch.d.ts
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.
184
+ */
185
+ declare function tryCatch<T, E = unknown>(fn: () => T, errorMapper?: (error: unknown) => E): (source: Result<any, any>) => Result<T, E>;
186
+ //#endregion
187
+ //#region src/core/tryMap.d.ts
188
+ /**
189
+ * Wie `map`, aber fängt Exceptions ab und wandelt sie in Err um.
190
+ */
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
+ //#endregion
193
+ //#region src/core/collectFirstOk.d.ts
194
+ type OkValueOf$2<R$1> = R$1 extends Result<infer T, any> ? T : never;
195
+ type ErrValueOf$2<R$1> = R$1 extends Result<any, infer E> ? E : never;
196
+ /**
197
+ * Parse a set of `Result`s, short-circuits when an input value is `Ok`.
198
+ * If no `Ok` is found, returns an `Err` containing the collected error values.
199
+ * Useful for "try multiple approaches until one works" patterns.
200
+ */
201
+ declare function collectFirstOk<const Results extends readonly Result<any, any>[]>(results: Results): Result<OkValueOf$2<Results[number]>, ErrValueOf$2<Results[number]>[]>;
202
+ //#endregion
203
+ //#region src/core/mapAsync.d.ts
204
+ /**
205
+ * Async-Version von map.
206
+ */
207
+ declare function mapAsync<T, E, U>(project: (value: T) => Promise<U>): (source: Result<T, E>) => Promise<Result<U, E>>;
208
+ //#endregion
209
+ //#region src/core/mapErrAsync.d.ts
210
+ /**
211
+ * Async-Version von mapErr.
212
+ */
213
+ declare function mapErrAsync<T, E, F>(project: (error: E) => Promise<F>): (source: Result<T, E>) => Promise<Result<T, F>>;
214
+ //#endregion
215
+ //#region src/core/flatMapAsync.d.ts
216
+ /**
217
+ * Async-Version von flatMap.
218
+ */
219
+ declare function flatMapAsync<T, E, U>(project: (value: T) => Promise<Result<U, E>>): (source: Result<T, E>) => Promise<Result<U, E>>;
220
+ //#endregion
221
+ //#region src/core/tapAsync.d.ts
222
+ /**
223
+ * Async-Version von tap.
224
+ */
225
+ declare function tapAsync<T, E>(observer: {
226
+ ok?: (val: T) => Promise<void>;
227
+ err?: (e: E) => Promise<void>;
228
+ }): (source: Result<T, E>) => Promise<Result<T, E>>;
229
+ //#endregion
230
+ //#region src/core/filterAsync.d.ts
231
+ /**
232
+ * Async-Version von filter.
233
+ */
234
+ declare function filterAsync<T, E>(predicate: (val: T) => Promise<boolean>, errorFn: () => Promise<E>): (source: Result<T, E>) => Promise<Result<T, E>>;
235
+ //#endregion
236
+ //#region src/core/matchAsync.d.ts
237
+ /**
238
+ * Async-Version von match.
239
+ */
240
+ declare function matchAsync<T, E, R$1>(handlers: {
241
+ ok: (val: T) => Promise<R$1>;
242
+ err: (e: E) => Promise<R$1>;
243
+ }): (source: Result<T, E>) => Promise<R$1>;
244
+ //#endregion
245
+ //#region src/core/tryCatchAsync.d.ts
246
+ /**
247
+ * Async-Version von tryCatch.
248
+ */
249
+ declare function tryCatchAsync<T, E = unknown>(fn: () => Promise<T>, errorMapper?: (error: unknown) => E): (source: Result<any, any>) => Promise<Result<T, E>>;
250
+ //#endregion
251
+ //#region src/core/tryMapAsync.d.ts
252
+ /**
253
+ * Async-Version von tryMap.
254
+ */
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
+ //#endregion
257
+ //#region src/core/result.d.ts
125
258
  type OperatorFunction<T, E, R$1> = (input: Result<T, E>) => R$1;
126
259
  type AsyncOperatorFunction<T, E, R$1> = (input: Result<T, E>) => Promise<R$1>;
127
- type Ok<T> = {
260
+ type ResultType<T, E> = {
128
261
  readonly _tag: 'Ok';
129
262
  readonly value: T;
130
- };
131
- type Err<E> = {
263
+ } | {
132
264
  readonly _tag: 'Err';
133
265
  readonly error: E;
134
266
  };
135
- type ResultType<T, E> = Ok<T> | Err<E>;
136
- declare class Result<T, E> extends Pipeable {
137
- #private;
138
- private constructor();
139
- /**
140
- * Creates an Ok Result with the given value.
141
- *
142
- * **Note**: `null` and `undefined` are allowed as values.
143
- * If you want to convert `null`/`undefined` to an Err, use `fromNullable()`.
144
- *
145
- * @param value The value for the Ok Result
146
- * @returns An Ok Result with the given value
147
- *
148
- * @example
149
- * ```ts
150
- * const result = Result.ok(42);
151
- * const nullResult = Result.ok(null); // Allowed!
152
- * ```
153
- */
154
- static ok<T, E = never>(value: T): Result<T, E>;
155
- /**
156
- * Creates an Err Result with the given error.
157
- *
158
- * **Note**: `null` and `undefined` are allowed as errors.
159
- *
160
- * @param error The error for the Err Result
161
- * @returns An Err Result with the given error
162
- *
163
- * @example
164
- * ```ts
165
- * const result = Result.err('error message');
166
- * const nullError = Result.err(null); // Allowed!
167
- * ```
168
- */
169
- static err<E, T = never>(error: E): Result<T, E>;
170
- /**
171
- * Converts `null | undefined` to `Err`, everything else to `Ok`.
172
- *
173
- * **Type Safety**: The type assertion `as NonNullable<T>` is safe,
174
- * as the runtime check guarantees that the value is not null/undefined.
175
- *
176
- * @param value The value to check
177
- * @param error The error to use if value is null/undefined
178
- * @returns An Ok Result with the NonNullable value, or an Err Result with the error
179
- *
180
- * @example
181
- * ```ts
182
- * Result.fromNullable(user, 'User not found')
183
- * // Ok(user) or Err('User not found')
184
- * ```
185
- */
186
- static fromNullable<T, E>(value: T, error: E): Result<NonNullable<T>, E>;
187
- /**
188
- * Converts a Promise to a Result-Promise.
189
- * Exceptions are converted to Err.
190
- *
191
- * This static method delegates to the standalone `fromPromise()` function.
192
- *
193
- * @example
194
- * ```ts
195
- * const result = await Result.fromPromise(fetch('/api/user'));
196
- * // Ok(response) or Err(error)
197
- *
198
- * // With custom error mapper
199
- * const result = await Result.fromPromise(
200
- * fetch('/api/user'),
201
- * (e) => `Network error: ${e}`
202
- * );
203
- * ```
204
- */
205
- static fromPromise<T>(promise: Promise<T>): Promise<Result<T, unknown>>;
206
- static fromPromise<T, E>(promise: Promise<T>, errorMapper?: (error: unknown) => E): Promise<Result<T, E>>;
207
- /**
208
- * Executes a function and catches exceptions.
209
- *
210
- * @example
211
- * ```ts
212
- * const result = Result.try(() => JSON.parse(input));
213
- * // Ok(parsed) or Err(SyntaxError)
214
- * ```
215
- */
216
- static try<T>(fn: () => T): Result<T, unknown>;
217
- /**
218
- * Checks if the Result is Ok.
219
- *
220
- * @returns `true` if the Result is Ok (and narrows the type)
221
- *
222
- * @example
223
- * ```ts
224
- * if (result.isOk()) {
225
- * const value: T = result.value; // TypeScript knows that value is defined
226
- * }
227
- * ```
228
- */
229
- isOk(): this is Result<T, E> & {
230
- readonly value: T;
231
- readonly error: undefined;
232
- };
233
- /**
234
- * Checks if the Result is Err.
235
- *
236
- * @returns `true` if the Result is Err (and narrows the type)
237
- *
238
- * @example
239
- * ```ts
240
- * if (result.isErr()) {
241
- * const error: E = result.error; // TypeScript knows that error is defined
242
- * }
243
- * ```
244
- */
245
- isErr(): this is Result<T, E> & {
246
- readonly value: undefined;
247
- readonly error: E;
248
- };
249
- get value(): T | undefined;
250
- get error(): E | undefined;
251
- /**
252
- * Returns the value, guaranteed to be defined after `isOk()` check.
253
- * This method provides better type narrowing than the `value` getter.
254
- *
255
- * ⚠️ **Warning**: This method throws an Error if called on an Err result.
256
- * Use this method only after a type guard (`if (result.isOk())`).
257
- * For a safer alternative with a custom message, use `expect()`.
258
- *
259
- * @throws {Error} If called on an Err result
260
- *
261
- * @example
262
- * ```ts
263
- * if (result.isOk()) {
264
- * const value = result.unwrap(); // Type is T, not T | undefined
265
- * }
266
- * ```
267
- */
268
- unwrap(): T;
269
- /**
270
- * Returns the error, guaranteed to be defined after `isErr()` check.
271
- * This method provides better type narrowing than the `error` getter.
272
- *
273
- * ⚠️ **Warning**: This method throws an Error if called on an Ok result.
274
- * Use this method only after a type guard (`if (result.isErr())`).
275
- * For a safer alternative with a custom message, use `expectErr()`.
276
- *
277
- * @throws {Error} If called on an Ok result
278
- *
279
- * @example
280
- * ```ts
281
- * if (result.isErr()) {
282
- * const error = result.unwrapErr(); // Type is E, not E | undefined
283
- * }
284
- * ```
285
- */
286
- unwrapErr(): E;
287
- /**
288
- * Returns the value with a custom error message if the result is Err.
289
- * Similar to `unwrap()`, but allows you to provide a custom error message.
290
- *
291
- * ⚠️ **Warning**: This method throws an Error if called on an Err result.
292
- * Use this method only if you are sure the Result is Ok,
293
- * or if you need a meaningful error message.
294
- *
295
- * @param message Custom error message to throw if result is Err
296
- * @returns The value if result is Ok
297
- * @throws {Error} If called on an Err result with the provided message
298
- *
299
- * @example
300
- * ```ts
301
- * const result = fetchUser(id);
302
- * const user = result.expect('User should exist'); // Throws with custom message if Err
303
- * ```
304
- */
305
- expect(message: string): T;
306
- /**
307
- * Returns the error with a custom error message if the result is Ok.
308
- * Similar to `unwrapErr()`, but allows you to provide a custom error message.
309
- *
310
- * ⚠️ **Warning**: This method throws an Error if called on an Ok result.
311
- * Use this method only if you are sure the Result is Err,
312
- * or if you need a meaningful error message.
313
- *
314
- * @param message Custom error message to throw if result is Ok
315
- * @returns The error if result is Err
316
- * @throws {Error} If called on an Ok result with the provided message
317
- *
318
- * @example
319
- * ```ts
320
- * const result = validateInput(input);
321
- * if (result.isErr()) {
322
- * const error = result.expectErr('Validation should have failed'); // Throws if Ok
323
- * }
324
- * ```
325
- */
326
- expectErr(message: string): E;
327
- unwrapOr<D = T>(defaultValue: D): T | D;
328
- /**
329
- * Converts the Result to a Promise.
330
- * Ok → resolves with the value, Err → rejects with the error
331
- *
332
- * This instance method delegates to the standalone `toPromise()` function.
333
- *
334
- * @returns A Promise that resolves with the value if Ok, or rejects with the error if Err
335
- *
336
- * @example
337
- * ```ts
338
- * const result = ok(42);
339
- * const promise = result.toPromise();
340
- * const value = await promise; // 42
341
- *
342
- * const errResult = err('error');
343
- * try {
344
- * await errResult.toPromise();
345
- * } catch (error) {
346
- * console.log(error); // 'error'
347
- * }
348
- * ```
349
- */
350
- toPromise(): Promise<T>;
267
+ type Result<T, E> = Ok<T, E> | Err<T, E>;
268
+ type OkValue<R$1> = R$1 extends {
269
+ readonly _tag: 'Ok';
270
+ readonly value: infer T;
271
+ } ? T : never;
272
+ declare abstract class ResultBase extends Pipeable {
273
+ abstract readonly _tag: 'Ok' | 'Err';
274
+ abstract readonly value: unknown;
275
+ abstract readonly error: unknown;
276
+ isOk<T, E>(this: Result<T, E>): this is Ok<T, E>;
277
+ isErr<T, E>(this: Result<T, E>): this is Err<T, E>;
278
+ unwrapOr<T, E>(this: Result<T, E>, defaultValue: T): T;
351
279
  /**
352
- * Converts the Result to `T | null`.
353
- * Ok → returns the value, Err → returns null
354
- *
355
- * This instance method delegates to the standalone `toNullable()` function.
356
- *
357
- * @returns The value if Ok, or null if Err
358
- *
359
- * @example
360
- * ```ts
361
- * const result = ok(42);
362
- * const value = result.toNullable(); // 42
363
- *
364
- * const errResult = err('error');
365
- * const nullValue = errResult.toNullable(); // null
366
- * ```
280
+ * Folds the Result into a single value by applying one of two functions.
367
281
  */
368
- toNullable(): T | null;
282
+ fold<T, E, R1, R2 = R1>(this: Result<T, E>, onOk: (value: T) => R1, onErr: (error: E) => R2): R1 | R2;
369
283
  /**
370
284
  * Enables `yield* result` in generators (Do-notation).
371
285
  *
@@ -373,142 +287,67 @@ declare class Result<T, E> extends Pipeable {
373
287
  * - Ok → sends back the Ok value (`next(value)`), `yield*` yields `T`
374
288
  * - Err → aborts and returns the Err Result
375
289
  */
376
- [Symbol.iterator](): Generator<Result<T, E>, T, unknown>;
290
+ [Symbol.iterator](): Generator<unknown, OkValue<this>, unknown>;
377
291
  /**
378
- * Universal pattern matcher for Ok + Err cases.
379
- *
380
- * Use this to exhaustively match on both success and error cases with type-based
381
- * and value-based pattern matching.
292
+ * Matcht auf den Err-Wert via `.when(...)` Kette.
382
293
  *
383
- * @example
384
- * ```ts
385
- * const message = result
386
- * .match()
387
- * .err(NetworkError, e => `Network: ${e.message}`)
388
- * .err(ValidationError, e => `Validation: ${e.message}`)
389
- * .ok(val => `Success: ${val}`)
390
- * .run();
391
- * ```
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()) { ... }`.
392
296
  */
393
- match(): ResultMatchBuilder<T, E, never>;
297
+ match<T, E>(this: Result<T, E>): ErrorMatchBuilder<E, never>;
394
298
  /**
395
- * Matches on the Err value via `.when(...)` chain.
396
- *
397
- * Note: For type safety reasons, `.matchErr()` can only be called on a Result that has already been narrowed to `Err`,
398
- * e.g., inside `if (result.isErr()) { ... }`.
399
- *
400
- * @example
401
- * ```ts
402
- * if (result.isErr()) {
403
- * const message = result
404
- * .matchErr()
405
- * .when(IOError, () => 'IO error')
406
- * .when(ParseError, () => 'Parse error')
407
- * .otherwise(e => `Other: ${e}`);
408
- * }
409
- * ```
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)
410
302
  */
411
- matchErr(this: Result<T, E> & {
412
- readonly error: E;
413
- }): ErrorMatchBuilder<E, never>;
414
- matchErr(this: Result<T, E>): never;
303
+ matchErr<T, E>(this: Result<T, E>): ErrMatchBuilder<T, E, never, never>;
415
304
  /**
416
- * Matches on the Err value, but normalizes every branch to a `Result`:
417
- * - Handlers may return a `Result` (returned directly)
418
- * - or an error value (wrapped to `Err(error)`)
305
+ * Serialisiert das Result in ein einfaches Objekt-Format.
306
+ * Behält die ursprünglichen Typen bei.
419
307
  */
420
- matchErrResult(): ErrMatchBuilder<T, E, never, never>;
421
- /**
422
- * @deprecated Use `.match()` instead. Will be removed in next major version.
423
- */
424
- pattern(): ResultMatchBuilder<T, E, never>;
425
- /**
426
- * @deprecated Use `.match()` instead. Will be removed in next major version.
427
- */
428
- switch(): ResultMatchBuilder<T, E, never>;
429
- /**
430
- * Folds the Result into a single value by applying one of two functions.
431
- *
432
- * This is a direct method equivalent to the `match` pipe operator.
433
- * Use this when you want to handle both Ok and Err cases and return a single value.
434
- *
435
- * @param onOk Function to apply if the Result is Ok
436
- * @param onErr Function to apply if the Result is Err
437
- * @returns The result of applying the appropriate function
438
- *
439
- * @example
440
- * ```ts
441
- * const result = ok(42);
442
- * const message = result.fold(
443
- * val => `Success: ${val}`,
444
- * err => `Error: ${err}`
445
- * );
446
- * // message = "Success: 42"
447
- * ```
448
- *
449
- * @example
450
- * ```ts
451
- * // Works with discriminated unions
452
- * const result: Result<string, number> = err(404);
453
- * const response = result.fold(
454
- * data => ({ success: true as const, data }),
455
- * code => ({ success: false as const, code })
456
- * );
457
- * // response: { success: true; data: string } | { success: false; code: number }
458
- * ```
459
- */
460
- fold<R1, R2 = R1>(onOk: (value: T) => R1, onErr: (error: E) => R2): R1 | R2;
461
- /**
462
- * Returns the Result as a discriminated union (`{ _tag: 'Ok', value } | { _tag: 'Err', error }`).
463
- * Useful for libraries like `ts-pattern` that match on plain object unions.
464
- */
465
- toUnion(): ResultType<T, E>;
466
- /**
467
- * Serializes the Result into a simple object format.
468
- * Preserves the original types.
469
- */
470
- serialize(): {
308
+ serialize<T, E>(this: Result<T, E>): {
471
309
  isSuccess: boolean;
472
310
  data?: T;
473
311
  error?: E;
474
312
  };
475
313
  /**
476
- * Serializes the Result into a user-friendly format.
477
- * Converts errors to readable strings.
314
+ * Serialisiert das Result in ein user-friendly Format.
315
+ * Konvertiert Errors zu lesbaren Strings.
478
316
  */
479
- toUserFriendly(): {
317
+ toUserFriendly<T, E>(this: Result<T, E>): {
480
318
  isSuccess: boolean;
481
319
  data?: T;
482
320
  error?: string;
483
321
  };
484
322
  }
485
- declare const ok: typeof Result.ok;
486
- declare const err: typeof Result.err;
487
- /**
488
- * Helper for conditional Result creation.
489
- * Avoids type inference issues with ternary operators.
490
- *
491
- * @example
492
- * ```ts
493
- * const result = okIf(value > 5, value, 'too small');
494
- * // instead of: value > 5 ? ok(value) : err('too small')
495
- * ```
496
- */
323
+ declare class Ok<T, E = never> extends ResultBase {
324
+ readonly _tag: "Ok";
325
+ readonly value: T;
326
+ readonly error: undefined;
327
+ constructor(value: T);
328
+ }
329
+ declare class Err<T = never, E = never> extends ResultBase {
330
+ readonly _tag: "Err";
331
+ readonly value: undefined;
332
+ readonly error: E;
333
+ constructor(error: E);
334
+ }
335
+ declare function ok(): Result<void, never>;
336
+ declare function ok<T, E = never>(value: T): Result<T, E>;
337
+ declare function err<E, T = never>(error: E): Result<T, E>;
497
338
  declare function okIf<T, E>(condition: boolean, okValue: T, errValue: E): Result<T, E>;
498
- /**
499
- * Helper for conditional Result creation with lazy evaluation.
500
- * Evaluates values only when they are needed.
501
- *
502
- * @example
503
- * ```ts
504
- * const result = okIfLazy(
505
- * value > 5,
506
- * () => expensiveComputation(value),
507
- * () => 'too small'
508
- * );
509
- * ```
510
- */
511
339
  declare function okIfLazy<T, E>(condition: boolean, okFn: () => T, errFn: () => E): Result<T, E>;
340
+ declare function fromNullable<T, E>(value: T, error: E): Result<NonNullable<T>, E>;
341
+ declare function fromPromise<T>(promise: Promise<T>): Promise<Result<T, unknown>>;
342
+ declare function fromPromise<T, E>(promise: Promise<T>, errorMapper?: (error: unknown) => E): Promise<Result<T, E>>;
343
+ declare function tryFn<T>(fn: () => T): Result<T, unknown>;
344
+ declare const Result: {
345
+ ok: typeof ok;
346
+ err: typeof err;
347
+ fromNullable: typeof fromNullable;
348
+ fromPromise: typeof fromPromise;
349
+ try: typeof tryFn;
350
+ };
512
351
  //#endregion
513
352
  //#region src/gen.d.ts
514
353
  type AnyGenerator = Generator<any, any, unknown> | AsyncGenerator<any, any, unknown>;
@@ -536,56 +375,7 @@ declare function task<const G extends AnyGenerator>(makeGenerator: () => G): Pro
536
375
  declare function task<const G extends AnyGenerator, EThrown>(makeGenerator: () => G, onThrow: OnThrow<EThrown>): Promise<Result<OkOfReturn<G>, ErrorOfGenerator<G> | ErrOfReturn<G> | EThrown>>;
537
376
  declare const gen: typeof task;
538
377
  //#endregion
539
- //#region src/operators/map.d.ts
540
- /**
541
- * Transforms the value (Ok case).
542
- * Equivalent to Rust `map`.
543
- */
544
- declare function map<T, E, U>(project: (value: T) => U): (source: Result<T, E>) => Result<U, E>;
545
- //#endregion
546
- //#region src/operators/mapErr.d.ts
547
- /**
548
- * Transforms the error (Err case).
549
- * Equivalent to Rust `map_err`.
550
- */
551
- declare function mapErr<T, E, F>(project: (error: E) => F): (source: Result<T, E>) => Result<T, F>;
552
- //#endregion
553
- //#region src/operators/mapBoth.d.ts
554
- /**
555
- * Transforms both the Ok value and the Err error.
556
- * Equivalent to FP `bimap` / `mapBoth`.
557
- */
558
- declare function mapBoth<T, E, U, F>(mapOk: (value: T) => U, mapErr: (error: E) => F): (source: Result<T, E>) => Result<U, F>;
559
- /**
560
- * Alias for `mapBoth`.
561
- */
562
- declare const bimap: typeof mapBoth;
563
- //#endregion
564
- //#region src/operators/flatMap.d.ts
565
- /**
566
- * Chains another operation that returns a Result.
567
- * Equivalent to Rust `and_then` or JS `flatMap`.
568
- */
569
- declare function flatMap<T, E, U, E2 = E>(project: (value: T) => Result<U, E2>): (source: Result<T, E>) => Result<U, E | E2>;
570
- //#endregion
571
- //#region src/operators/tap.d.ts
572
- /**
573
- * Executes a side effect (logging, debugging) without changing the Result.
574
- * Equivalent to Rust `inspect` / `inspect_err`.
575
- */
576
- declare function tap<T, E>(observer: {
577
- ok?: (val: T) => void;
578
- err?: (e: E) => void;
579
- }): <SourceT extends T, SourceE extends E>(source: Result<SourceT, SourceE>) => Result<SourceT, SourceE>;
580
- //#endregion
581
- //#region src/operators/filter.d.ts
582
- /**
583
- * Checks a predicate. If false, the Result becomes Err.
584
- * Partially equivalent to Rust `filter`.
585
- */
586
- declare function filter<T, E>(predicate: (val: T) => boolean, errorFn: () => E): (source: Result<T, E>) => Result<T, E>;
587
- //#endregion
588
- //#region src/operators/fold.d.ts
378
+ //#region src/core/fold.d.ts
589
379
  /**
590
380
  * Folds the Result into a single value by applying one of two functions.
591
381
  * The end of the pipe.
@@ -596,71 +386,8 @@ declare function fold<T, E, R$1>(handlers: {
596
386
  ok: (val: T) => R$1;
597
387
  err: (e: E) => R$1;
598
388
  }): (source: Result<T, E>) => R$1;
599
- /**
600
- * @deprecated Use `fold` instead. Will be removed in next major version.
601
- */
602
- declare const match: typeof fold;
603
- //#endregion
604
- //#region src/operators/tryCatch.d.ts
605
- /**
606
- * Executes a function and catches exceptions.
607
- * Converts exceptions into Result<E>.
608
- * Equivalent to Rust `Result::from` for fallible operations.
609
- */
610
- declare function tryCatch<T, E = unknown>(fn: () => T, errorMapper?: (error: unknown) => E): <SourceT, SourceE>(source: Result<SourceT, SourceE>) => Result<T | SourceT, E | SourceE>;
611
- //#endregion
612
- //#region src/operators/tryMap.d.ts
613
- /**
614
- * Like `map`, but catches exceptions and turns them into Err.
615
- */
616
- declare function tryMap<T, E, U, F = unknown>(project: (value: T) => U, errorMapper?: (error: unknown) => F): (source: Result<T, E>) => Result<U, E | F>;
617
- //#endregion
618
- //#region src/operators/recover.d.ts
619
- /**
620
- * Recover: turns Err into Ok(defaultValue).
621
- * Result is guaranteed Ok → error type becomes `never`.
622
- */
623
- declare function recover<T, E, D = T>(defaultValue: D): (source: Result<T, E>) => Result<T | D, never>;
624
- /**
625
- * Like `recover`, but computes the default value from the error.
626
- */
627
- declare function recoverWith<T, E, D = T>(fn: (error: E) => D): (source: Result<T, E>) => Result<T | D, never>;
628
- //#endregion
629
- //#region src/operators-async/mapAsync.d.ts
630
- /**
631
- * Async version of map.
632
- */
633
- declare function mapAsync<T, E, U>(project: (value: T) => Promise<U>): (source: Result<T, E>) => Promise<Result<Awaited<U>, E>>;
634
- //#endregion
635
- //#region src/operators-async/mapErrAsync.d.ts
636
- /**
637
- * Async version of mapErr.
638
- */
639
- declare function mapErrAsync<T, E, F>(project: (error: E) => Promise<F>): (source: Result<T, E>) => Promise<Result<T, F>>;
640
- //#endregion
641
- //#region src/operators-async/flatMapAsync.d.ts
642
- /**
643
- * Async version of flatMap.
644
- * Allows different error types in the projected Result.
645
- */
646
- declare function flatMapAsync<T, E, U, E2 = E>(project: (value: T) => Promise<Result<U, E2>>): (source: Result<T, E>) => Promise<Result<U, E | E2>>;
647
- //#endregion
648
- //#region src/operators-async/tapAsync.d.ts
649
- /**
650
- * Async version of tap.
651
- */
652
- declare function tapAsync<T, E>(observer: {
653
- ok?: (val: T) => Promise<void>;
654
- err?: (e: E) => Promise<void>;
655
- }): <SourceT extends T, SourceE extends E>(source: Result<SourceT, SourceE>) => Promise<Result<SourceT, SourceE>>;
656
389
  //#endregion
657
- //#region src/operators-async/filterAsync.d.ts
658
- /**
659
- * Async version of filter.
660
- */
661
- declare function filterAsync<T, E>(predicate: (val: T) => Promise<boolean>, errorFn: () => Promise<E>): (source: Result<T, E>) => Promise<Result<T, E>>;
662
- //#endregion
663
- //#region src/operators-async/foldAsync.d.ts
390
+ //#region src/core/foldAsync.d.ts
664
391
  /**
665
392
  * Async version of `fold`. Folds the Result into a single value asynchronously.
666
393
  * The end of the pipe.
@@ -671,226 +398,163 @@ declare function foldAsync<T, E, R$1>(handlers: {
671
398
  ok: (val: T) => Promise<R$1>;
672
399
  err: (e: E) => Promise<R$1>;
673
400
  }): (source: Result<T, E>) => Promise<R$1>;
674
- /**
675
- * @deprecated Use `foldAsync` instead. Will be removed in next major version.
676
- */
677
- declare const matchAsync: typeof foldAsync;
678
401
  //#endregion
679
- //#region src/operators-async/tryCatchAsync.d.ts
402
+ //#region src/core/unwrap.d.ts
680
403
  /**
681
- * Async version of tryCatch.
682
- */
683
- declare function tryCatchAsync<T, E = unknown>(fn: () => Promise<T>, errorMapper?: (error: unknown) => E): <SourceT, SourceE>(source: Result<SourceT, SourceE>) => Promise<Result<T, E | SourceE>>;
684
- //#endregion
685
- //#region src/operators-async/tryMapAsync.d.ts
686
- /**
687
- * Async version of tryMap.
688
- */
689
- 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>>;
690
- //#endregion
691
- //#region src/unwrap/unwrap.d.ts
692
- /**
693
- * Returns the value or throws an Error.
694
- * Equivalent to Rust `unwrap`.
404
+ * Gibt den Wert zurück oder wirft einen Error.
405
+ * Entspricht Rust `unwrap`.
695
406
  */
696
407
  declare function unwrap<T, E>(result: Result<T, E>): T;
697
408
  //#endregion
698
- //#region src/unwrap/unwrapOr.d.ts
409
+ //#region src/core/unwrapOr.d.ts
699
410
  /**
700
- * Returns the value or a default value.
701
- * Pure function alternative to the instance method.
411
+ * Gibt den Wert zurück oder einen Default-Wert.
412
+ * Pure function Alternative zur Instanz-Methode.
702
413
  */
703
- declare function unwrapOr<T, E, D = T>(result: Result<T, E>, defaultValue: D): T | D;
414
+ declare function unwrapOr<T, E>(result: Result<T, E>, defaultValue: T): T;
704
415
  //#endregion
705
- //#region src/unwrap/unwrapOrElse.d.ts
416
+ //#region src/core/unwrapOrElse.d.ts
706
417
  /**
707
- * Returns the value or computes a default value with a function.
708
- * Equivalent to Rust `unwrap_or_else`.
418
+ * Gibt den Wert zurück oder berechnet einen Default-Wert mit einer Funktion.
419
+ * Entspricht Rust `unwrap_or_else`.
709
420
  */
710
- declare function unwrapOrElse<T, E, D = T>(result: Result<T, E>, fn: (error: E) => D): T | D;
421
+ declare function unwrapOrElse<T, E>(result: Result<T, E>, fn: (error: E) => T): T;
711
422
  //#endregion
712
- //#region src/unwrap/unwrapOrDefault.d.ts
423
+ //#region src/core/unwrapOrDefault.d.ts
713
424
  /**
714
- * Alias for `unwrapOr`.
715
- * Equivalent to Rust `unwrap_or_default` (with an explicit default value).
425
+ * Alias für `unwrapOr`.
426
+ * Entspricht Rust `unwrap_or_default` (mit explizitem Default-Wert).
716
427
  */
717
- declare function unwrapOrDefault<T, E, D = T>(result: Result<T, E>, defaultValue: D): T | D;
428
+ declare function unwrapOrDefault<T, E>(result: Result<T, E>, defaultValue: T): T;
718
429
  //#endregion
719
- //#region src/unwrap/unwrapOrThrow.d.ts
430
+ //#region src/core/unwrapOrThrow.d.ts
720
431
  /**
721
- * Returns the value or throws the original Err value (not wrapped).
722
- * Useful to keep `Error` instances with stack traces.
432
+ * Gibt den Wert zurück oder wirft den originalen Err-Wert (nicht gewrappt).
433
+ * Nützlich um `Error`-Instanzen inkl. Stacktrace zu erhalten.
723
434
  */
724
435
  declare function unwrapOrThrow<T, E>(result: Result<T, E>): T;
725
436
  //#endregion
726
- //#region src/unwrap/unwrapErr.d.ts
437
+ //#region src/core/unwrapErr.d.ts
727
438
  /**
728
- * Returns the error or throws an Error.
729
- * Equivalent to Rust `unwrap_err`.
439
+ * Gibt den Fehler zurück oder wirft einen Error.
440
+ * Entspricht Rust `unwrap_err`.
730
441
  */
731
442
  declare function unwrapErr<T, E>(result: Result<T, E>): E;
732
443
  //#endregion
733
- //#region src/unwrap/expectResult.d.ts
444
+ //#region src/core/expectResult.d.ts
734
445
  /**
735
- * Returns the value or throws an Error with a custom message.
736
- * Equivalent to Rust `expect`.
446
+ * Gibt den Wert zurück oder wirft einen Error mit custom Nachricht.
447
+ * Entspricht Rust `expect`.
737
448
  */
738
449
  declare function expectResult<T, E>(result: Result<T, E>, message: string): T;
739
450
  //#endregion
740
- //#region src/unwrap/expectErr.d.ts
451
+ //#region src/core/expectErr.d.ts
741
452
  /**
742
- * Returns the error or throws an Error with a custom message.
743
- * Equivalent to Rust `expect_err`.
453
+ * Gibt den Fehler zurück oder wirft einen Error mit custom Nachricht.
454
+ * Entspricht Rust `expect_err`.
744
455
  */
745
456
  declare function expectErr<T, E>(result: Result<T, E>, message: string): E;
746
457
  //#endregion
747
- //#region src/combinators/and.d.ts
458
+ //#region src/core/and.d.ts
748
459
  /**
749
- * Combines two Results. Returns the second only if the first is Ok.
750
- * Equivalent to Rust `and`.
460
+ * Kombiniert zwei Results. Gibt den zweiten zurück nur wenn erster Ok ist.
461
+ * Entspricht Rust `and`.
751
462
  */
752
463
  declare function and<T, E, U>(result: Result<T, E>, other: Result<U, E>): Result<U, E>;
753
464
  //#endregion
754
- //#region src/combinators/or.d.ts
465
+ //#region src/core/or.d.ts
755
466
  /**
756
- * Fallback to another Result when the first is Err.
757
- * Equivalent to Rust `or`.
467
+ * Fallback zu einem anderen Result wenn erster Err ist.
468
+ * Entspricht Rust `or`.
758
469
  */
759
- declare function or<T, E, T2 = T, E2 = E>(result: Result<T, E>, other: Result<T2, E2>): Result<T | T2, E2>;
470
+ declare function or<T, E, F>(result: Result<T, E>, other: Result<T, F>): Result<T, F>;
760
471
  //#endregion
761
- //#region src/combinators/orElse.d.ts
472
+ //#region src/core/orElse.d.ts
762
473
  /**
763
- * Fallback using a function that returns a Result.
764
- * Equivalent to Rust `or_else`.
474
+ * Fallback mit einer Funktion die ein Result zurückgibt.
475
+ * Entspricht Rust `or_else`.
765
476
  */
766
- declare function orElse<T, E, T2 = T, E2 = E>(result: Result<T, E>, fn: (error: E) => Result<T2, E2>): Result<T | T2, E2>;
477
+ declare function orElse<T, E, F>(result: Result<T, E>, fn: (error: E) => Result<T, F>): Result<T, F>;
767
478
  //#endregion
768
- //#region src/combinators/mapOr.d.ts
479
+ //#region src/core/mapOr.d.ts
769
480
  /**
770
- * Transforms the value or returns a default value.
771
- * Equivalent to Rust `map_or`.
481
+ * Transformiert den Wert oder gibt einen Default-Wert zurück.
482
+ * Entspricht Rust `map_or`.
772
483
  */
773
484
  declare function mapOr<T, E, U>(result: Result<T, E>, defaultValue: U, fn: (value: T) => U): U;
774
485
  //#endregion
775
- //#region src/combinators/mapOrElse.d.ts
486
+ //#region src/core/mapOrElse.d.ts
776
487
  /**
777
- * Transforms the value or computes a default value with a function.
778
- * Equivalent to Rust `map_or_else`.
488
+ * Transformiert den Wert oder berechnet einen Default-Wert mit einer Funktion.
489
+ * Entspricht Rust `map_or_else`.
779
490
  */
780
491
  declare function mapOrElse<T, E, U>(result: Result<T, E>, defaultFn: (error: E) => U, fn: (value: T) => U): U;
781
492
  //#endregion
782
- //#region src/combinators/zip.d.ts
783
- /**
784
- * Combines two Results into a Result of a tuple.
785
- * Short-circuits on the first Err (left before right).
786
- */
787
- declare function zip<A, AE, B, BE>(left: Result<A, AE>, right: Result<B, BE>): Result<[A, B], AE | BE>;
788
- declare function zip<A, AE, B, BE>(right: Result<B, BE>): (left: Result<A, AE>) => Result<[A, B], AE | BE>;
789
- /**
790
- * Combines two Results and collects errors.
791
- * - Ok only if both are Ok
792
- * - Err([errors]) if at least one is Err (left before right)
793
- */
794
- declare function combine<A, AE, B, BE>(left: Result<A, AE>, right: Result<B, BE>): Result<[A, B], Array<AE | BE>>;
795
- declare function combine<A, AE, B, BE>(right: Result<B, BE>): (left: Result<A, AE>) => Result<[A, B], Array<AE | BE>>;
796
- //#endregion
797
- //#region src/combinators/swap.d.ts
798
- /**
799
- * Swaps Ok and Err.
800
- * Result<T, E> → Result<E, T>
801
- */
802
- declare function swap<T, E>(result: Result<T, E>): Result<E, T>;
803
- //#endregion
804
- //#region src/collections/sequence.d.ts
805
- type ResultLike$1<T, E> = {
806
- isOk(): boolean;
807
- isErr(): boolean;
808
- readonly value: T | undefined;
809
- readonly error: E | undefined;
810
- };
811
- type OkValueOf$3<R$1> = R$1 extends ResultLike$1<infer T, any> ? T : never;
812
- type ErrValueOf$3<R$1> = R$1 extends ResultLike$1<any, infer E> ? E : never;
493
+ //#region src/core/sequence.d.ts
813
494
  /**
814
- * Combines a list of Results into a Result of a list.
815
- * Short-circuits on the first Err.
816
- * Analogous to Rust `collect::<Result<Vec<_>, _>>()`.
495
+ * Kombiniert eine Liste von Results zu einem Result einer Liste.
496
+ * Short-circuits beim ersten Err.
497
+ * Analog zu Rust `collect::<Result<Vec<_>, _>>()`.
817
498
  */
818
- declare function sequence<const Results extends readonly ResultLike$1<any, any>[]>(results: Results): Result<Array<OkValueOf$3<Results[number]>>, ErrValueOf$3<Results[number]>>;
499
+ declare function sequence<T, E>(results: readonly Result<T, E>[]): Result<T[], E>;
819
500
  /**
820
- * Alias for `sequence`.
501
+ * Alias für `sequence`.
821
502
  */
822
- declare function all<const Results extends readonly ResultLike$1<any, any>[]>(results: Results): Result<Array<OkValueOf$3<Results[number]>>, ErrValueOf$3<Results[number]>>;
503
+ declare function all<T, E>(results: readonly Result<T, E>[]): Result<T[], E>;
823
504
  //#endregion
824
- //#region src/collections/sequenceRecord.d.ts
825
- type ResultLike<T, E> = {
826
- isOk(): boolean;
827
- isErr(): boolean;
828
- readonly value: T | undefined;
829
- readonly error: E | undefined;
830
- };
831
- type OkValueOf$2<R$1> = R$1 extends ResultLike<infer T, any> ? T : never;
832
- type ErrValueOf$2<R$1> = R$1 extends ResultLike<any, infer E> ? E : never;
505
+ //#region src/core/sequenceRecord.d.ts
506
+ type OkValueOf$1<R$1> = R$1 extends Result<infer T, any> ? T : never;
507
+ type ErrValueOf$1<R$1> = R$1 extends Result<any, infer E> ? E : never;
833
508
  /**
834
- * Like `sequence`, but for records/objects.
835
- * Short-circuits on the first Err.
509
+ * Wie `sequence`, aber für Records/Objekte.
510
+ * Short-circuits beim ersten Err.
836
511
  */
837
- declare function sequenceRecord<const R$1 extends Record<string, ResultLike<any, any>>>(record: R$1): Result<{ [K in keyof R$1]: OkValueOf$2<R$1[K]> }, ErrValueOf$2<R$1[keyof R$1]>>;
512
+ 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]>>;
838
513
  //#endregion
839
- //#region src/collections/collectFirstOk.d.ts
840
- /**
841
- * Parse a set of `Result`s, short-circuits when an input value is `Ok`.
842
- * If no `Ok` is found, returns an `Err` containing the collected error values.
843
- * Useful for "try multiple approaches until one works" patterns.
844
- */
845
- declare function collectFirstOk<T, E>(results: readonly (Result<T, E> | Result<T, never> | Result<never, E>)[]): Result<T, E[]>;
846
- //#endregion
847
- //#region src/collections/collectFirstOkAsync.d.ts
514
+ //#region src/core/collectFirstOkAsync.d.ts
848
515
  type CollectFirstOkAsyncInput$1 = Promise<Result<any, any>> | (() => Awaitable<Result<any, any>>);
849
516
  type ResolvedResult$1<I> = I extends (() => infer R) ? Awaited<R> : I extends Promise<infer R> ? R : never;
850
517
  type OkValueOfInput$1<I> = ResolvedResult$1<I> extends Result<infer T, any> ? T : never;
851
518
  type ErrValueOfInput$1<I> = ResolvedResult$1<I> extends Result<any, infer E> ? E : never;
852
519
  /**
853
- * Async version of collectFirstOk.
520
+ * Async-Version von collectFirstOk.
854
521
  *
855
- * - Accepts already-started promises or "thunks" (`() => Awaitable<Result<...>>`).
856
- * - Processes inputs strictly sequentially (like `for ... of` + `await`).
857
- * - Returns the first `Ok` and collects all errors when no `Ok` is found.
522
+ * - Nimmt entweder bereits gestartete Promises oder "Thunks" (`() => Awaitable<Result<...>>`).
523
+ * - Verarbeitet die Inputs strikt sequentiell (wie `for ... of` + `await`).
524
+ * - Gibt das erste `Ok` zurück und sammelt alle Errors wenn kein `Ok` gefunden wird.
858
525
  */
859
526
  declare function collectFirstOkAsync<const Inputs extends readonly CollectFirstOkAsyncInput$1[]>(inputs: Inputs): Promise<Result<OkValueOfInput$1<Inputs[number]>, ErrValueOfInput$1<Inputs[number]>[]>>;
860
527
  //#endregion
861
- //#region src/collections/collectFirstOkRaceAsync.d.ts
528
+ //#region src/core/collectFirstOkRaceAsync.d.ts
862
529
  type CollectFirstOkAsyncInput = Promise<Result<any, any>> | (() => Awaitable<Result<any, any>>);
863
530
  type ResolvedResult<I> = I extends (() => infer R) ? Awaited<R> : I extends Promise<infer R> ? R : never;
864
531
  type OkValueOfInput<I> = ResolvedResult<I> extends Result<infer T, any> ? T : never;
865
532
  type ErrValueOfInput<I> = ResolvedResult<I> extends Result<any, infer E> ? E : never;
866
533
  /**
867
- * Parallel/race variant of `collectFirstOkAsync`.
534
+ * Parallel/Race-Variante von `collectFirstOkAsync`.
868
535
  *
869
- * - Starts all inputs immediately (promises or thunks).
870
- * - Returns the first `Ok` as soon as it is available.
871
- * - If no `Ok` is found, returns an `Err` with all error values (in input order).
872
- * - **Note**: There is no cancellation logic. All inputs keep running even after the first `Ok` is found.
536
+ * - Startet alle Inputs sofort (Promises oder Thunks).
537
+ * - Gibt das erste `Ok` zurück, sobald es verfügbar ist.
538
+ * - Wenn kein `Ok` gefunden wird, gibt ein `Err` mit allen Error-Werten (in Input-Reihenfolge) zurück.
873
539
  */
874
540
  declare function collectFirstOkRaceAsync<const Inputs extends readonly CollectFirstOkAsyncInput[]>(inputs: Inputs): Promise<Result<OkValueOfInput<Inputs[number]>, ErrValueOfInput<Inputs[number]>[]>>;
875
541
  //#endregion
876
- //#region src/collections/collectAllErrors.d.ts
877
- type OkValueOf$1<R$1> = R$1 extends Result<infer T, any> ? T : never;
878
- type ErrValueOf$1<R$1> = R$1 extends Result<any, infer E> ? E : never;
542
+ //#region src/core/collectAllErrors.d.ts
879
543
  /**
880
- * Combines a list of Results.
881
- * Returns Ok(values) only if all are Ok, otherwise Err([errors]).
544
+ * Kombiniert eine Liste von Results.
545
+ * Gibt Ok(values) nur zurück wenn alle Ok sind, sonst Err([errors]).
882
546
  */
883
- declare function collectAllErrors<const Results extends readonly Result<any, any>[]>(results: Results): Result<Array<OkValueOf$1<Results[number]>>, Array<ErrValueOf$1<Results[number]>>>;
547
+ declare function collectAllErrors<T, E>(results: readonly Result<T, E>[]): Result<T[], E[]>;
884
548
  //#endregion
885
- //#region src/collections/partition.d.ts
549
+ //#region src/core/partition.d.ts
886
550
  type OkValueOf<R$1> = R$1 extends Result<infer T, any> ? T : never;
887
551
  type ErrValueOf<R$1> = R$1 extends Result<any, infer E> ? E : never;
888
552
  /**
889
- * Partitions Results into Ok values and Err errors.
553
+ * Partitioniert Results in Ok-Werte und Err-Fehler.
890
554
  */
891
555
  declare function partition<const Results extends readonly Result<any, any>[]>(results: Results): [oks: Array<OkValueOf<Results[number]>>, errs: Array<ErrValueOf<Results[number]>>];
892
556
  //#endregion
893
- //#region src/collections/flatten.d.ts
557
+ //#region src/core/flatten.d.ts
894
558
  /**
895
559
  * Flacht ein nested Result ab.
896
560
  * Result<Result<T, E>, E> → Result<T, E>
@@ -898,135 +562,53 @@ declare function partition<const Results extends readonly Result<any, any>[]>(re
898
562
  */
899
563
  declare function flatten<T, E>(result: Result<Result<T, E>, E>): Result<T, E>;
900
564
  //#endregion
901
- //#region src/conversions/fromPromise.d.ts
565
+ //#region src/core/toPromise.d.ts
902
566
  /**
903
- * Converts a Promise to a Result-Promise.
904
- * Exceptions are converted to Err.
905
- *
906
- * @param promise The Promise to convert
907
- * @param errorMapper Optional function to map errors to a specific type
908
- * @returns A Promise that resolves to an Ok Result with the value, or an Err Result with the error
909
- *
910
- * @example
911
- * ```ts
912
- * const result = await fromPromise(fetch('/api/user'));
913
- * // Ok(response) or Err(error)
914
- *
915
- * // With custom error mapper
916
- * const result = await fromPromise(
917
- * fetch('/api/user'),
918
- * (e) => `Network error: ${e}`
919
- * );
920
- * ```
921
- */
922
- declare function fromPromise<T>(promise: Promise<T>): Promise<Result<T, unknown>>;
923
- declare function fromPromise<T, E>(promise: Promise<T>, errorMapper?: (error: unknown) => E): Promise<Result<T, E>>;
924
- //#endregion
925
- //#region src/conversions/fromNullable.d.ts
926
- /**
927
- * Converts `null | undefined` to `Err`, everything else to `Ok`.
928
- *
929
- * **Type Safety**: The type assertion `as NonNullable<T>` is safe,
930
- * as the runtime check guarantees that the value is not null/undefined.
931
- *
932
- * @param value The value to check
933
- * @param error The error to use if value is null/undefined
934
- * @returns An Ok Result with the NonNullable value, or an Err Result with the error
935
- *
936
- * @example
937
- * ```ts
938
- * fromNullable(user, 'User not found')
939
- * // Ok(user) or Err('User not found')
940
- * ```
941
- */
942
- declare function fromNullable<T, E>(value: T, error: E): Result<NonNullable<T>, E>;
943
- //#endregion
944
- //#region src/conversions/try.d.ts
945
- /**
946
- * Executes a function and catches exceptions.
947
- *
948
- * @param fn The function to execute
949
- * @returns An Ok Result with the return value, or an Err Result with the caught exception
950
- *
951
- * @example
952
- * ```ts
953
- * const result = tryFn(() => JSON.parse(input));
954
- * // Ok(parsed) or Err(SyntaxError)
955
- * ```
956
- */
957
- declare function tryFn<T>(fn: () => T): Result<T, unknown>;
958
- //#endregion
959
- //#region src/conversions/toPromise.d.ts
960
- /**
961
- * Converts a Result to a Promise.
962
- * Ok → resolves with the value, Err → rejects with the error
963
- *
964
- * @param result The Result to convert
965
- * @returns A Promise that resolves with the value if Ok, or rejects with the error if Err
966
- *
967
- * @example
968
- * ```ts
969
- * const result = ok(42);
970
- * const promise = toPromise(result);
971
- * const value = await promise; // 42
972
- * ```
567
+ * Konvertiert ein Result zu einem Promise.
568
+ * Ok resolve(value), Err → reject(error)
973
569
  */
974
570
  declare function toPromise<T, E>(result: Result<T, E>): Promise<T>;
975
571
  //#endregion
976
- //#region src/conversions/toNullable.d.ts
572
+ //#region src/core/toNullable.d.ts
977
573
  /**
978
- * Converts a Result to `T | null`.
979
- * Ok → returns the value, Err → returns null
980
- *
981
- * @param result The Result to convert
982
- * @returns The value if Ok, or null if Err
983
- *
984
- * @example
985
- * ```ts
986
- * const result = ok(42);
987
- * const value = toNullable(result); // 42
988
- *
989
- * const errResult = err('error');
990
- * const nullValue = toNullable(errResult); // null
991
- * ```
574
+ * Konvertiert ein Result zu `T | null`.
575
+ * Ok → value, Err → null
992
576
  */
993
577
  declare function toNullable<T, E>(result: Result<T, E>): T | null;
994
578
  //#endregion
995
- //#region src/utils/isOk.d.ts
579
+ //#region src/core/isOk.d.ts
996
580
  /**
997
- * Checks whether a Result is Ok.
998
- * Pure function alternative to the instance method.
581
+ * Prüft ob ein Result Ok ist.
582
+ * Pure function Alternative zur Instanz-Methode.
999
583
  */
1000
- declare function isOk<T, E>(result: Result<T, E>): result is Result<T, E> & {
1001
- readonly value: T;
1002
- readonly error: undefined;
1003
- };
584
+ declare function isOk<T, E>(result: Result<T, E>): result is Ok<T, E>;
1004
585
  //#endregion
1005
- //#region src/utils/isErr.d.ts
586
+ //#region src/core/isErr.d.ts
1006
587
  /**
1007
- * Checks whether a Result is Err.
1008
- * Pure function alternative to the instance method.
588
+ * Prüft ob ein Result Err ist.
589
+ * Pure function Alternative zur Instanz-Methode.
1009
590
  */
1010
- declare function isErr<T, E>(result: Result<T, E>): result is Result<T, E> & {
1011
- readonly value: undefined;
1012
- readonly error: E;
1013
- };
591
+ declare function isErr<T, E>(result: Result<T, E>): result is Err<T, E>;
1014
592
  //#endregion
1015
- //#region src/utils/contains.d.ts
593
+ //#region src/core/contains.d.ts
1016
594
  /**
1017
- * Checks whether the Result contains a specific value.
1018
- * Equivalent to Rust `contains`.
595
+ * Prüft ob das Result einen bestimmten Wert enthält.
596
+ * Entspricht Rust `contains`.
1019
597
  */
1020
- declare function contains<T, E>(result: Result<any, E>, value: T): boolean;
598
+ declare function contains<T, E>(result: Result<T, E>, value: T): boolean;
1021
599
  //#endregion
1022
- //#region src/utils/containsErr.d.ts
600
+ //#region src/core/containsErr.d.ts
1023
601
  /**
1024
- * Checks whether the Result contains a specific error.
1025
- * Analogous to `contains` for the Err case.
602
+ * Prüft ob das Result einen bestimmten Fehler enthält.
603
+ * Analog zu `contains` für den Err-Fall.
1026
604
  */
1027
605
  declare function containsErr<T, E>(result: Result<T, E>, error: E): boolean;
1028
606
  //#endregion
1029
- //#region src/utils/isResult.d.ts
607
+ //#region src/core/isResult.d.ts
608
+ /**
609
+ * Checks whether a value is a Result.
610
+ * Pure function alternative for runtime checks.
611
+ */
1030
612
  declare function isResult(value: unknown): value is Result<any, any>;
1031
613
  //#endregion
1032
614
  export { AsyncOperatorFunction, type Awaitable, Err, Ok, OperatorFunction, Result, ResultType, all, and, bimap, collectAllErrors, collectFirstOk, collectFirstOkAsync, collectFirstOkRaceAsync, 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 };