@shirudo/result 0.0.1 → 0.0.3

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,896 +1,561 @@
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>;
102
- /**
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()`.
111
- */
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
- }
123
- //#endregion
124
- //#region src/result.d.ts
125
- type OperatorFunction<T, E, R$1> = (input: Result<T, E>) => R$1;
126
- type AsyncOperatorFunction<T, E, R$1> = (input: Result<T, E>) => Promise<R$1>;
127
- type Ok<T> = {
128
- readonly _tag: 'Ok';
129
- readonly value: T;
130
- };
131
- type Err<E> = {
132
- readonly _tag: 'Err';
133
- readonly error: E;
134
- };
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>;
351
- /**
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
- * ```
367
- */
368
- toNullable(): T | null;
369
- /**
370
- * Enables `yield* result` in generators (Do-notation).
371
- *
372
- * The iterator yields the `Result` itself; the runner (see `task`) decides:
373
- * - Ok → sends back the Ok value (`next(value)`), `yield*` yields `T`
374
- * - Err → aborts and returns the Err Result
375
- */
376
- [Symbol.iterator](): Generator<Result<T, E>, T, unknown>;
377
- /**
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.
382
- *
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
- * ```
392
- */
393
- match(): ResultMatchBuilder<T, E, never>;
394
- /**
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
- * ```
410
- */
411
- matchErr(this: Result<T, E> & {
412
- readonly error: E;
413
- }): ErrorMatchBuilder<E, never>;
414
- matchErr(this: Result<T, E>): never;
415
- /**
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)`)
419
- */
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(): {
471
- isSuccess: boolean;
472
- data?: T;
473
- error?: E;
474
- };
475
- /**
476
- * Serializes the Result into a user-friendly format.
477
- * Converts errors to readable strings.
478
- */
479
- toUserFriendly(): {
480
- isSuccess: boolean;
481
- data?: T;
482
- error?: string;
483
- };
484
- }
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
- */
497
- 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
- declare function okIfLazy<T, E>(condition: boolean, okFn: () => T, errFn: () => E): Result<T, E>;
512
86
  //#endregion
513
- //#region src/gen.d.ts
514
- type AnyGenerator = Generator<any, any, unknown> | AsyncGenerator<any, any, unknown>;
515
- type YieldOf<G> = G extends Generator<infer Y, any, any> ? Y : G extends AsyncGenerator<infer Y, any, any> ? Y : never;
516
- type ReturnOf<G> = G extends Generator<any, infer R, any> ? R : G extends AsyncGenerator<any, infer R, any> ? R : never;
517
- type ErrorOfYield<Y> = Y extends Result<any, infer E> ? E : never;
518
- type ErrorOfGenerator<G> = ErrorOfYield<YieldOf<G>>;
519
- type OnThrow<E> = (error: unknown) => E;
520
- type AwaitedReturnOf<G> = Awaited<ReturnOf<G>>;
521
- type OkOfReturn<G> = AwaitedReturnOf<G> extends Result<infer T, any> ? T : AwaitedReturnOf<G>;
522
- type ErrOfReturn<G> = AwaitedReturnOf<G> extends Result<any, infer E> ? E : never;
87
+ //#region src/core/map.d.ts
523
88
  /**
524
- * Generator-based do-notation for `Result`.
525
- *
526
- * Usage:
527
- * ```ts
528
- * const out = await task(async function* () {
529
- * const user = yield* await fromPromise(findUser(1));
530
- * const email = yield* validate(user.email);
531
- * return email;
532
- * });
533
- * ```
534
- */
535
- declare function task<const G extends AnyGenerator>(makeGenerator: () => G): Promise<Result<OkOfReturn<G>, ErrorOfGenerator<G> | ErrOfReturn<G>>>;
536
- declare function task<const G extends AnyGenerator, EThrown>(makeGenerator: () => G, onThrow: OnThrow<EThrown>): Promise<Result<OkOfReturn<G>, ErrorOfGenerator<G> | ErrOfReturn<G> | EThrown>>;
537
- declare const gen: typeof task;
538
- //#endregion
539
- //#region src/operators/map.d.ts
540
- /**
541
- * Transforms the value (Ok case).
542
- * Equivalent to Rust `map`.
89
+ * Transformiert den Wert (Ok-Fall).
90
+ * Entspricht Rust `map`.
543
91
  */
544
92
  declare function map<T, E, U>(project: (value: T) => U): (source: Result<T, E>) => Result<U, E>;
545
93
  //#endregion
546
- //#region src/operators/mapErr.d.ts
94
+ //#region src/core/mapErr.d.ts
547
95
  /**
548
- * Transforms the error (Err case).
549
- * Equivalent to Rust `map_err`.
96
+ * Transformiert den Fehler (Err-Fall).
97
+ * Entspricht Rust `map_err`.
550
98
  */
551
99
  declare function mapErr<T, E, F>(project: (error: E) => F): (source: Result<T, E>) => Result<T, F>;
552
100
  //#endregion
553
- //#region src/operators/mapBoth.d.ts
101
+ //#region src/core/mapBoth.d.ts
554
102
  /**
555
- * Transforms both the Ok value and the Err error.
556
- * Equivalent to FP `bimap` / `mapBoth`.
103
+ * Transformiert sowohl den Ok-Wert als auch den Err-Fehler.
104
+ * Entspricht FP `bimap` / `mapBoth`.
557
105
  */
558
106
  declare function mapBoth<T, E, U, F>(mapOk: (value: T) => U, mapErr: (error: E) => F): (source: Result<T, E>) => Result<U, F>;
559
107
  /**
560
- * Alias for `mapBoth`.
108
+ * Alias für `mapBoth`.
561
109
  */
562
110
  declare const bimap: typeof mapBoth;
563
111
  //#endregion
564
- //#region src/operators/flatMap.d.ts
112
+ //#region src/core/flatMap.d.ts
565
113
  /**
566
- * Chains another operation that returns a Result.
567
- * Equivalent to Rust `and_then` or JS `flatMap`.
114
+ * Verkettet eine weitere Operation, die ein Result zurückgibt.
115
+ * Entspricht Rust `and_then` oder JS `flatMap`.
568
116
  */
569
- declare function flatMap<T, E, U, E2 = E>(project: (value: T) => Result<U, E2>): (source: Result<T, E>) => Result<U, E | E2>;
117
+ declare function flatMap<T, E, U>(project: (value: T) => Result<U, E>): (source: Result<T, E>) => Result<U, E>;
570
118
  //#endregion
571
- //#region src/operators/tap.d.ts
119
+ //#region src/core/zip.d.ts
572
120
  /**
573
- * Executes a side effect (logging, debugging) without changing the Result.
574
- * Equivalent to Rust `inspect` / `inspect_err`.
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`.
575
138
  */
576
139
  declare function tap<T, E>(observer: {
577
140
  ok?: (val: T) => void;
578
141
  err?: (e: E) => void;
579
- }): <SourceT extends T, SourceE extends E>(source: Result<SourceT, SourceE>) => Result<SourceT, SourceE>;
142
+ }): (source: Result<T, E>) => Result<T, E>;
580
143
  //#endregion
581
- //#region src/operators/filter.d.ts
144
+ //#region src/core/filter.d.ts
582
145
  /**
583
- * Checks a predicate. If false, the Result becomes Err.
584
- * Partially equivalent to Rust `filter`.
146
+ * Prüft eine Bedingung. Wenn falsch, wird das Result zu Err.
147
+ * Entspricht Rust `filter` (teilweise).
585
148
  */
586
149
  declare function filter<T, E>(predicate: (val: T) => boolean, errorFn: () => E): (source: Result<T, E>) => Result<T, E>;
587
150
  //#endregion
588
- //#region src/operators/fold.d.ts
151
+ //#region src/core/match.d.ts
589
152
  /**
590
- * Folds the Result into a single value by applying one of two functions.
591
- * The end of the pipe.
592
- *
593
- * This is the pipe operator equivalent of the `.fold()` instance method.
153
+ * Löst das Result auf. Das Ende der Pipe.
154
+ * Entspricht Rust `match`.
594
155
  */
595
- declare function fold<T, E, R$1>(handlers: {
156
+ declare function match<T, E, R$1>(handlers: {
596
157
  ok: (val: T) => R$1;
597
158
  err: (e: E) => R$1;
598
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>;
599
167
  /**
600
- * @deprecated Use `fold` instead. Will be removed in next major version.
168
+ * Wie `recover`, aber berechnet den Default-Wert anhand des Errors.
601
169
  */
602
- declare const match: typeof fold;
170
+ declare function recoverWith<T, E, F>(fn: (error: E) => F): (source: Result<T, E>) => Result<T | F, never>;
603
171
  //#endregion
604
- //#region src/operators/tryCatch.d.ts
172
+ //#region src/core/swap.d.ts
605
173
  /**
606
- * Executes a function and catches exceptions.
607
- * Converts exceptions into Result<E>.
608
- * Equivalent to Rust `Result::from` for fallible operations.
174
+ * Tauscht Ok und Err.
175
+ * Result<T, E> Result<E, T>
609
176
  */
610
- declare function tryCatch<T, E = unknown>(fn: () => T, errorMapper?: (error: unknown) => E): <SourceT, SourceE>(source: Result<SourceT, SourceE>) => Result<T | SourceT, E | SourceE>;
177
+ declare function swap<T, E>(result: Result<T, E>): Result<E, T>;
611
178
  //#endregion
612
- //#region src/operators/tryMap.d.ts
179
+ //#region src/core/tryCatch.d.ts
613
180
  /**
614
- * Like `map`, but catches exceptions and turns them into Err.
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.
615
184
  */
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>;
185
+ declare function tryCatch<T, E = unknown>(fn: () => T, errorMapper?: (error: unknown) => E): (source: Result<any, any>) => Result<T, E>;
617
186
  //#endregion
618
- //#region src/operators/recover.d.ts
187
+ //#region src/core/tryMap.d.ts
619
188
  /**
620
- * Recover: turns Err into Ok(defaultValue).
621
- * Result is guaranteed Ok → error type becomes `never`.
189
+ * Wie `map`, aber fängt Exceptions ab und wandelt sie in Err um.
622
190
  */
623
- declare function recover<T, E, D = T>(defaultValue: D): (source: Result<T, E>) => Result<T | D, never>;
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;
624
196
  /**
625
- * Like `recover`, but computes the default value from the error.
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.
626
200
  */
627
- declare function recoverWith<T, E, D = T>(fn: (error: E) => D): (source: Result<T, E>) => Result<T | D, never>;
201
+ declare function collectFirstOk<const Results extends readonly Result<any, any>[]>(results: Results): Result<OkValueOf$2<Results[number]>, ErrValueOf$2<Results[number]>[]>;
628
202
  //#endregion
629
- //#region src/operators-async/mapAsync.d.ts
203
+ //#region src/core/mapAsync.d.ts
630
204
  /**
631
- * Async version of map.
205
+ * Async-Version von map.
632
206
  */
633
- declare function mapAsync<T, E, U>(project: (value: T) => Promise<U>): (source: Result<T, E>) => Promise<Result<Awaited<U>, E>>;
207
+ declare function mapAsync<T, E, U>(project: (value: T) => Promise<U>): (source: Result<T, E>) => Promise<Result<U, E>>;
634
208
  //#endregion
635
- //#region src/operators-async/mapErrAsync.d.ts
209
+ //#region src/core/mapErrAsync.d.ts
636
210
  /**
637
- * Async version of mapErr.
211
+ * Async-Version von mapErr.
638
212
  */
639
213
  declare function mapErrAsync<T, E, F>(project: (error: E) => Promise<F>): (source: Result<T, E>) => Promise<Result<T, F>>;
640
214
  //#endregion
641
- //#region src/operators-async/flatMapAsync.d.ts
215
+ //#region src/core/flatMapAsync.d.ts
642
216
  /**
643
- * Async version of flatMap.
644
- * Allows different error types in the projected Result.
217
+ * Async-Version von flatMap.
645
218
  */
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>>;
219
+ declare function flatMapAsync<T, E, U>(project: (value: T) => Promise<Result<U, E>>): (source: Result<T, E>) => Promise<Result<U, E>>;
647
220
  //#endregion
648
- //#region src/operators-async/tapAsync.d.ts
221
+ //#region src/core/tapAsync.d.ts
649
222
  /**
650
- * Async version of tap.
223
+ * Async-Version von tap.
651
224
  */
652
225
  declare function tapAsync<T, E>(observer: {
653
226
  ok?: (val: T) => Promise<void>;
654
227
  err?: (e: E) => Promise<void>;
655
- }): <SourceT extends T, SourceE extends E>(source: Result<SourceT, SourceE>) => Promise<Result<SourceT, SourceE>>;
228
+ }): (source: Result<T, E>) => Promise<Result<T, E>>;
656
229
  //#endregion
657
- //#region src/operators-async/filterAsync.d.ts
230
+ //#region src/core/filterAsync.d.ts
658
231
  /**
659
- * Async version of filter.
232
+ * Async-Version von filter.
660
233
  */
661
234
  declare function filterAsync<T, E>(predicate: (val: T) => Promise<boolean>, errorFn: () => Promise<E>): (source: Result<T, E>) => Promise<Result<T, E>>;
662
235
  //#endregion
663
- //#region src/operators-async/foldAsync.d.ts
236
+ //#region src/core/matchAsync.d.ts
664
237
  /**
665
- * Async version of `fold`. Folds the Result into a single value asynchronously.
666
- * The end of the pipe.
667
- *
668
- * This is the async pipe operator equivalent of the `.fold()` instance method.
238
+ * Async-Version von match.
669
239
  */
670
- declare function foldAsync<T, E, R$1>(handlers: {
240
+ declare function matchAsync<T, E, R$1>(handlers: {
671
241
  ok: (val: T) => Promise<R$1>;
672
242
  err: (e: E) => Promise<R$1>;
673
243
  }): (source: Result<T, E>) => Promise<R$1>;
244
+ //#endregion
245
+ //#region src/core/tryCatchAsync.d.ts
674
246
  /**
675
- * @deprecated Use `foldAsync` instead. Will be removed in next major version.
247
+ * Async-Version von tryCatch.
676
248
  */
677
- declare const matchAsync: typeof foldAsync;
249
+ declare function tryCatchAsync<T, E = unknown>(fn: () => Promise<T>, errorMapper?: (error: unknown) => E): (source: Result<any, any>) => Promise<Result<T, E>>;
678
250
  //#endregion
679
- //#region src/operators-async/tryCatchAsync.d.ts
251
+ //#region src/core/tryMapAsync.d.ts
680
252
  /**
681
- * Async version of tryCatch.
253
+ * Async-Version von tryMap.
682
254
  */
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>>;
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>>;
684
256
  //#endregion
685
- //#region src/operators-async/tryMapAsync.d.ts
257
+ //#region src/core/result.d.ts
258
+ type OperatorFunction<T, E, R$1> = (input: Result<T, E>) => R$1;
259
+ type AsyncOperatorFunction<T, E, R$1> = (input: Result<T, E>) => Promise<R$1>;
260
+ type ResultType<T, E> = {
261
+ readonly _tag: 'Ok';
262
+ readonly value: T;
263
+ } | {
264
+ readonly _tag: 'Err';
265
+ readonly error: E;
266
+ };
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;
279
+ /**
280
+ * Folds the Result into a single value by applying one of two functions.
281
+ */
282
+ fold<T, E, R1, R2 = R1>(this: Result<T, E>, onOk: (value: T) => R1, onErr: (error: E) => R2): R1 | R2;
283
+ /**
284
+ * Enables `yield* result` in generators (Do-notation).
285
+ *
286
+ * The iterator yields the `Result` itself; the runner (see `task`) decides:
287
+ * - Ok → sends back the Ok value (`next(value)`), `yield*` yields `T`
288
+ * - Err → aborts and returns the Err Result
289
+ */
290
+ [Symbol.iterator](): Generator<unknown, OkValue<this>, unknown>;
291
+ /**
292
+ * Matcht auf den Err-Wert via `.when(...)` Kette.
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()) { ... }`.
296
+ */
297
+ match<T, E>(this: Result<T, E>): ErrorMatchBuilder<E, never>;
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)
302
+ */
303
+ matchErr<T, E>(this: Result<T, E>): ErrMatchBuilder<T, E, never, never>;
304
+ /**
305
+ * Serialisiert das Result in ein einfaches Objekt-Format.
306
+ * Behält die ursprünglichen Typen bei.
307
+ */
308
+ serialize<T, E>(this: Result<T, E>): {
309
+ isSuccess: boolean;
310
+ data?: T;
311
+ error?: E;
312
+ };
313
+ /**
314
+ * Serialisiert das Result in ein user-friendly Format.
315
+ * Konvertiert Errors zu lesbaren Strings.
316
+ */
317
+ toUserFriendly<T, E>(this: Result<T, E>): {
318
+ isSuccess: boolean;
319
+ data?: T;
320
+ error?: string;
321
+ };
322
+ }
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>;
338
+ declare function okIf<T, E>(condition: boolean, okValue: T, errValue: E): Result<T, E>;
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
+ };
351
+ //#endregion
352
+ //#region src/gen.d.ts
353
+ type AnyGenerator<Y = unknown, R$1 = unknown, N = unknown> = Generator<Y, R$1, N> | AsyncGenerator<Y, R$1, N>;
354
+ type ErrorOfYield<Y> = Y extends Result<any, infer E> ? E : never;
355
+ type OnThrow<E> = (error: unknown) => E;
356
+ type AwaitedReturn<R$1> = Awaited<R$1>;
357
+ type OkOfReturn<R$1> = AwaitedReturn<R$1> extends Result<infer T, any> ? T : AwaitedReturn<R$1>;
358
+ type ErrOfReturn<R$1> = AwaitedReturn<R$1> extends Result<any, infer E> ? E : never;
686
359
  /**
687
- * Async version of tryMap.
360
+ * Generator-based do-notation for `Result`.
361
+ *
362
+ * Usage:
363
+ * ```ts
364
+ * const out = await task(async function* () {
365
+ * const user = yield* await fromPromise(findUser(1));
366
+ * const email = yield* validate(user.email);
367
+ * return email;
368
+ * });
369
+ * ```
688
370
  */
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>>;
371
+ declare function task<const Y, const R$1>(makeGenerator: () => AnyGenerator<Y, R$1, unknown>): Promise<Result<OkOfReturn<R$1>, ErrorOfYield<Y> | ErrOfReturn<R$1>>>;
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
+ declare const gen: typeof task;
690
374
  //#endregion
691
- //#region src/unwrap/unwrap.d.ts
375
+ //#region src/core/fold.d.ts
692
376
  /**
693
- * Returns the value or throws an Error.
694
- * Equivalent to Rust `unwrap`.
377
+ * Folds the Result into a single value by applying one of two functions.
378
+ * The end of the pipe.
379
+ *
380
+ * This is the pipe operator equivalent of the `.fold()` instance method.
381
+ */
382
+ declare function fold<T, E, R$1>(handlers: {
383
+ ok: (val: T) => R$1;
384
+ err: (e: E) => R$1;
385
+ }): (source: Result<T, E>) => R$1;
386
+ //#endregion
387
+ //#region src/core/foldAsync.d.ts
388
+ /**
389
+ * Async version of `fold`. Folds the Result into a single value asynchronously.
390
+ * The end of the pipe.
391
+ *
392
+ * This is the async pipe operator equivalent of the `.fold()` instance method.
393
+ */
394
+ declare function foldAsync<T, E, R$1>(handlers: {
395
+ ok: (val: T) => Promise<R$1>;
396
+ err: (e: E) => Promise<R$1>;
397
+ }): (source: Result<T, E>) => Promise<R$1>;
398
+ //#endregion
399
+ //#region src/core/unwrap.d.ts
400
+ /**
401
+ * Gibt den Wert zurück oder wirft einen Error.
402
+ * Entspricht Rust `unwrap`.
695
403
  */
696
404
  declare function unwrap<T, E>(result: Result<T, E>): T;
697
405
  //#endregion
698
- //#region src/unwrap/unwrapOr.d.ts
406
+ //#region src/core/unwrapOr.d.ts
699
407
  /**
700
- * Returns the value or a default value.
701
- * Pure function alternative to the instance method.
408
+ * Gibt den Wert zurück oder einen Default-Wert.
409
+ * Pure function Alternative zur Instanz-Methode.
702
410
  */
703
- declare function unwrapOr<T, E, D = T>(result: Result<T, E>, defaultValue: D): T | D;
411
+ declare function unwrapOr<T, E>(result: Result<T, E>, defaultValue: T): T;
704
412
  //#endregion
705
- //#region src/unwrap/unwrapOrElse.d.ts
413
+ //#region src/core/unwrapOrElse.d.ts
706
414
  /**
707
- * Returns the value or computes a default value with a function.
708
- * Equivalent to Rust `unwrap_or_else`.
415
+ * Gibt den Wert zurück oder berechnet einen Default-Wert mit einer Funktion.
416
+ * Entspricht Rust `unwrap_or_else`.
709
417
  */
710
- declare function unwrapOrElse<T, E, D = T>(result: Result<T, E>, fn: (error: E) => D): T | D;
418
+ declare function unwrapOrElse<T, E>(result: Result<T, E>, fn: (error: E) => T): T;
711
419
  //#endregion
712
- //#region src/unwrap/unwrapOrDefault.d.ts
420
+ //#region src/core/unwrapOrDefault.d.ts
713
421
  /**
714
- * Alias for `unwrapOr`.
715
- * Equivalent to Rust `unwrap_or_default` (with an explicit default value).
422
+ * Alias für `unwrapOr`.
423
+ * Entspricht Rust `unwrap_or_default` (mit explizitem Default-Wert).
716
424
  */
717
- declare function unwrapOrDefault<T, E, D = T>(result: Result<T, E>, defaultValue: D): T | D;
425
+ declare function unwrapOrDefault<T, E>(result: Result<T, E>, defaultValue: T): T;
718
426
  //#endregion
719
- //#region src/unwrap/unwrapOrThrow.d.ts
427
+ //#region src/core/unwrapOrThrow.d.ts
720
428
  /**
721
- * Returns the value or throws the original Err value (not wrapped).
722
- * Useful to keep `Error` instances with stack traces.
429
+ * Gibt den Wert zurück oder wirft den originalen Err-Wert (nicht gewrappt).
430
+ * Nützlich um `Error`-Instanzen inkl. Stacktrace zu erhalten.
723
431
  */
724
432
  declare function unwrapOrThrow<T, E>(result: Result<T, E>): T;
725
433
  //#endregion
726
- //#region src/unwrap/unwrapErr.d.ts
434
+ //#region src/core/unwrapErr.d.ts
727
435
  /**
728
- * Returns the error or throws an Error.
729
- * Equivalent to Rust `unwrap_err`.
436
+ * Gibt den Fehler zurück oder wirft einen Error.
437
+ * Entspricht Rust `unwrap_err`.
730
438
  */
731
439
  declare function unwrapErr<T, E>(result: Result<T, E>): E;
732
440
  //#endregion
733
- //#region src/unwrap/expectResult.d.ts
441
+ //#region src/core/expectResult.d.ts
734
442
  /**
735
- * Returns the value or throws an Error with a custom message.
736
- * Equivalent to Rust `expect`.
443
+ * Gibt den Wert zurück oder wirft einen Error mit custom Nachricht.
444
+ * Entspricht Rust `expect`.
737
445
  */
738
446
  declare function expectResult<T, E>(result: Result<T, E>, message: string): T;
739
447
  //#endregion
740
- //#region src/unwrap/expectErr.d.ts
448
+ //#region src/core/expectErr.d.ts
741
449
  /**
742
- * Returns the error or throws an Error with a custom message.
743
- * Equivalent to Rust `expect_err`.
450
+ * Gibt den Fehler zurück oder wirft einen Error mit custom Nachricht.
451
+ * Entspricht Rust `expect_err`.
744
452
  */
745
453
  declare function expectErr<T, E>(result: Result<T, E>, message: string): E;
746
454
  //#endregion
747
- //#region src/combinators/and.d.ts
455
+ //#region src/core/and.d.ts
748
456
  /**
749
- * Combines two Results. Returns the second only if the first is Ok.
750
- * Equivalent to Rust `and`.
457
+ * Kombiniert zwei Results. Gibt den zweiten zurück nur wenn erster Ok ist.
458
+ * Entspricht Rust `and`.
751
459
  */
752
460
  declare function and<T, E, U>(result: Result<T, E>, other: Result<U, E>): Result<U, E>;
753
461
  //#endregion
754
- //#region src/combinators/or.d.ts
462
+ //#region src/core/or.d.ts
755
463
  /**
756
- * Fallback to another Result when the first is Err.
757
- * Equivalent to Rust `or`.
464
+ * Fallback zu einem anderen Result wenn erster Err ist.
465
+ * Entspricht Rust `or`.
758
466
  */
759
- declare function or<T, E, T2 = T, E2 = E>(result: Result<T, E>, other: Result<T2, E2>): Result<T | T2, E2>;
467
+ declare function or<T, E, F>(result: Result<T, E>, other: Result<T, F>): Result<T, F>;
760
468
  //#endregion
761
- //#region src/combinators/orElse.d.ts
469
+ //#region src/core/orElse.d.ts
762
470
  /**
763
- * Fallback using a function that returns a Result.
764
- * Equivalent to Rust `or_else`.
471
+ * Fallback mit einer Funktion die ein Result zurückgibt.
472
+ * Entspricht Rust `or_else`.
765
473
  */
766
- declare function orElse<T, E, T2 = T, E2 = E>(result: Result<T, E>, fn: (error: E) => Result<T2, E2>): Result<T | T2, E2>;
474
+ declare function orElse<T, E, F>(result: Result<T, E>, fn: (error: E) => Result<T, F>): Result<T, F>;
767
475
  //#endregion
768
- //#region src/combinators/mapOr.d.ts
476
+ //#region src/core/mapOr.d.ts
769
477
  /**
770
- * Transforms the value or returns a default value.
771
- * Equivalent to Rust `map_or`.
478
+ * Transformiert den Wert oder gibt einen Default-Wert zurück.
479
+ * Entspricht Rust `map_or`.
772
480
  */
773
481
  declare function mapOr<T, E, U>(result: Result<T, E>, defaultValue: U, fn: (value: T) => U): U;
774
482
  //#endregion
775
- //#region src/combinators/mapOrElse.d.ts
483
+ //#region src/core/mapOrElse.d.ts
776
484
  /**
777
- * Transforms the value or computes a default value with a function.
778
- * Equivalent to Rust `map_or_else`.
485
+ * Transformiert den Wert oder berechnet einen Default-Wert mit einer Funktion.
486
+ * Entspricht Rust `map_or_else`.
779
487
  */
780
488
  declare function mapOrElse<T, E, U>(result: Result<T, E>, defaultFn: (error: E) => U, fn: (value: T) => U): U;
781
489
  //#endregion
782
- //#region src/combinators/zip.d.ts
490
+ //#region src/core/sequence.d.ts
783
491
  /**
784
- * Combines two Results into a Result of a tuple.
785
- * Short-circuits on the first Err (left before right).
492
+ * Kombiniert eine Liste von Results zu einem Result einer Liste.
493
+ * Short-circuits beim ersten Err.
494
+ * Analog zu Rust `collect::<Result<Vec<_>, _>>()`.
786
495
  */
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>;
496
+ declare function sequence<T, E>(results: readonly Result<T, E>[]): Result<T[], E>;
789
497
  /**
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)
498
+ * Alias für `sequence`.
793
499
  */
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>>;
500
+ declare function all<T, E>(results: readonly Result<T, E>[]): Result<T[], E>;
796
501
  //#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;
813
- /**
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<_>, _>>()`.
817
- */
818
- declare function sequence<const Results extends readonly ResultLike$1<any, any>[]>(results: Results): Result<Array<OkValueOf$3<Results[number]>>, ErrValueOf$3<Results[number]>>;
819
- /**
820
- * Alias for `sequence`.
821
- */
822
- declare function all<const Results extends readonly ResultLike$1<any, any>[]>(results: Results): Result<Array<OkValueOf$3<Results[number]>>, ErrValueOf$3<Results[number]>>;
823
- //#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;
833
- /**
834
- * Like `sequence`, but for records/objects.
835
- * Short-circuits on the first Err.
836
- */
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]>>;
838
- //#endregion
839
- //#region src/collections/collectFirstOk.d.ts
502
+ //#region src/core/sequenceRecord.d.ts
503
+ type OkValueOf$1<R$1> = R$1 extends Result<infer T, any> ? T : never;
504
+ type ErrValueOf$1<R$1> = R$1 extends Result<any, infer E> ? E : never;
840
505
  /**
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.
506
+ * Wie `sequence`, aber für Records/Objekte.
507
+ * Short-circuits beim ersten Err.
844
508
  */
845
- declare function collectFirstOk<T, E>(results: readonly (Result<T, E> | Result<T, never> | Result<never, E>)[]): Result<T, E[]>;
509
+ 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]>>;
846
510
  //#endregion
847
- //#region src/collections/collectFirstOkAsync.d.ts
511
+ //#region src/core/collectFirstOkAsync.d.ts
848
512
  type CollectFirstOkAsyncInput$1 = Promise<Result<any, any>> | (() => Awaitable<Result<any, any>>);
849
513
  type ResolvedResult$1<I> = I extends (() => infer R) ? Awaited<R> : I extends Promise<infer R> ? R : never;
850
514
  type OkValueOfInput$1<I> = ResolvedResult$1<I> extends Result<infer T, any> ? T : never;
851
515
  type ErrValueOfInput$1<I> = ResolvedResult$1<I> extends Result<any, infer E> ? E : never;
852
516
  /**
853
- * Async version of collectFirstOk.
517
+ * Async-Version von collectFirstOk.
854
518
  *
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.
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.
858
522
  */
859
523
  declare function collectFirstOkAsync<const Inputs extends readonly CollectFirstOkAsyncInput$1[]>(inputs: Inputs): Promise<Result<OkValueOfInput$1<Inputs[number]>, ErrValueOfInput$1<Inputs[number]>[]>>;
860
524
  //#endregion
861
- //#region src/collections/collectFirstOkRaceAsync.d.ts
525
+ //#region src/core/collectFirstOkParallelAsync.d.ts
862
526
  type CollectFirstOkAsyncInput = Promise<Result<any, any>> | (() => Awaitable<Result<any, any>>);
863
527
  type ResolvedResult<I> = I extends (() => infer R) ? Awaited<R> : I extends Promise<infer R> ? R : never;
864
528
  type OkValueOfInput<I> = ResolvedResult<I> extends Result<infer T, any> ? T : never;
865
529
  type ErrValueOfInput<I> = ResolvedResult<I> extends Result<any, infer E> ? E : never;
866
530
  /**
867
- * Parallel/race variant of `collectFirstOkAsync`.
531
+ * Parallel-Variante von `collectFirstOkAsync`.
868
532
  *
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.
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.
873
540
  */
874
- declare function collectFirstOkRaceAsync<const Inputs extends readonly CollectFirstOkAsyncInput[]>(inputs: Inputs): Promise<Result<OkValueOfInput<Inputs[number]>, ErrValueOfInput<Inputs[number]>[]>>;
541
+ declare function collectFirstOkParallelAsync<const Inputs extends readonly CollectFirstOkAsyncInput[]>(inputs: Inputs): Promise<Result<OkValueOfInput<Inputs[number]>, ErrValueOfInput<Inputs[number]>[]>>;
875
542
  //#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;
543
+ //#region src/core/collectAllErrors.d.ts
879
544
  /**
880
- * Combines a list of Results.
881
- * Returns Ok(values) only if all are Ok, otherwise Err([errors]).
545
+ * Kombiniert eine Liste von Results.
546
+ * Gibt Ok(values) nur zurück wenn alle Ok sind, sonst Err([errors]).
882
547
  */
883
- declare function collectAllErrors<const Results extends readonly Result<any, any>[]>(results: Results): Result<Array<OkValueOf$1<Results[number]>>, Array<ErrValueOf$1<Results[number]>>>;
548
+ declare function collectAllErrors<T, E>(results: readonly Result<T, E>[]): Result<T[], E[]>;
884
549
  //#endregion
885
- //#region src/collections/partition.d.ts
550
+ //#region src/core/partition.d.ts
886
551
  type OkValueOf<R$1> = R$1 extends Result<infer T, any> ? T : never;
887
552
  type ErrValueOf<R$1> = R$1 extends Result<any, infer E> ? E : never;
888
553
  /**
889
- * Partitions Results into Ok values and Err errors.
554
+ * Partitioniert Results in Ok-Werte und Err-Fehler.
890
555
  */
891
556
  declare function partition<const Results extends readonly Result<any, any>[]>(results: Results): [oks: Array<OkValueOf<Results[number]>>, errs: Array<ErrValueOf<Results[number]>>];
892
557
  //#endregion
893
- //#region src/collections/flatten.d.ts
558
+ //#region src/core/flatten.d.ts
894
559
  /**
895
560
  * Flacht ein nested Result ab.
896
561
  * Result<Result<T, E>, E> → Result<T, E>
@@ -898,136 +563,54 @@ declare function partition<const Results extends readonly Result<any, any>[]>(re
898
563
  */
899
564
  declare function flatten<T, E>(result: Result<Result<T, E>, E>): Result<T, E>;
900
565
  //#endregion
901
- //#region src/conversions/fromPromise.d.ts
902
- /**
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
566
+ //#region src/core/toPromise.d.ts
945
567
  /**
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
- * ```
568
+ * Konvertiert ein Result zu einem Promise.
569
+ * Ok → resolve(value), Err → reject(error)
973
570
  */
974
571
  declare function toPromise<T, E>(result: Result<T, E>): Promise<T>;
975
572
  //#endregion
976
- //#region src/conversions/toNullable.d.ts
573
+ //#region src/core/toNullable.d.ts
977
574
  /**
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
- * ```
575
+ * Konvertiert ein Result zu `T | null`.
576
+ * Ok → value, Err → null
992
577
  */
993
578
  declare function toNullable<T, E>(result: Result<T, E>): T | null;
994
579
  //#endregion
995
- //#region src/utils/isOk.d.ts
580
+ //#region src/core/isOk.d.ts
996
581
  /**
997
- * Checks whether a Result is Ok.
998
- * Pure function alternative to the instance method.
582
+ * Prüft ob ein Result Ok ist.
583
+ * Pure function Alternative zur Instanz-Methode.
999
584
  */
1000
- declare function isOk<T, E>(result: Result<T, E>): result is Result<T, E> & {
1001
- readonly value: T;
1002
- readonly error: undefined;
1003
- };
585
+ declare function isOk<T, E>(result: Result<T, E>): result is Ok<T, E>;
1004
586
  //#endregion
1005
- //#region src/utils/isErr.d.ts
587
+ //#region src/core/isErr.d.ts
1006
588
  /**
1007
- * Checks whether a Result is Err.
1008
- * Pure function alternative to the instance method.
589
+ * Prüft ob ein Result Err ist.
590
+ * Pure function Alternative zur Instanz-Methode.
1009
591
  */
1010
- declare function isErr<T, E>(result: Result<T, E>): result is Result<T, E> & {
1011
- readonly value: undefined;
1012
- readonly error: E;
1013
- };
592
+ declare function isErr<T, E>(result: Result<T, E>): result is Err<T, E>;
1014
593
  //#endregion
1015
- //#region src/utils/contains.d.ts
594
+ //#region src/core/contains.d.ts
1016
595
  /**
1017
- * Checks whether the Result contains a specific value.
1018
- * Equivalent to Rust `contains`.
596
+ * Prüft ob das Result einen bestimmten Wert enthält.
597
+ * Entspricht Rust `contains`.
1019
598
  */
1020
- declare function contains<T, E>(result: Result<any, E>, value: T): boolean;
599
+ declare function contains<T, E>(result: Result<T, E>, value: T): boolean;
1021
600
  //#endregion
1022
- //#region src/utils/containsErr.d.ts
601
+ //#region src/core/containsErr.d.ts
1023
602
  /**
1024
- * Checks whether the Result contains a specific error.
1025
- * Analogous to `contains` for the Err case.
603
+ * Prüft ob das Result einen bestimmten Fehler enthält.
604
+ * Analog zu `contains` für den Err-Fall.
1026
605
  */
1027
606
  declare function containsErr<T, E>(result: Result<T, E>, error: E): boolean;
1028
607
  //#endregion
1029
- //#region src/utils/isResult.d.ts
608
+ //#region src/core/isResult.d.ts
609
+ /**
610
+ * Checks whether a value is a Result.
611
+ * Pure function alternative for runtime checks.
612
+ */
1030
613
  declare function isResult(value: unknown): value is Result<any, any>;
1031
614
  //#endregion
1032
- 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 };
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 };
1033
616
  //# sourceMappingURL=index.d.mts.map