@shirudo/result 0.0.6 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +137 -296
  3. package/dist/collections.cjs +12 -0
  4. package/dist/collections.d.cts +3 -0
  5. package/dist/collections.d.mts +3 -0
  6. package/dist/collections.mjs +4 -0
  7. package/dist/errors-2WOswg7r.mjs +95 -0
  8. package/dist/errors-2WOswg7r.mjs.map +1 -0
  9. package/dist/errors-BFjY06EV.d.cts +55 -0
  10. package/dist/errors-BFjY06EV.d.cts.map +1 -0
  11. package/dist/errors-C5qGMRiU.d.mts +55 -0
  12. package/dist/errors-C5qGMRiU.d.mts.map +1 -0
  13. package/dist/errors-D2EMzJQl.cjs +209 -0
  14. package/dist/errors-D2EMzJQl.cjs.map +1 -0
  15. package/dist/errors.cjs +21 -0
  16. package/dist/errors.d.cts +2 -0
  17. package/dist/errors.d.mts +2 -0
  18. package/dist/errors.mjs +3 -0
  19. package/dist/flatten-B8bN6fiI.d.mts +71 -0
  20. package/dist/flatten-B8bN6fiI.d.mts.map +1 -0
  21. package/dist/flatten-C6Y9hx79.mjs +147 -0
  22. package/dist/flatten-C6Y9hx79.mjs.map +1 -0
  23. package/dist/flatten-DK7eJKPx.d.cts +71 -0
  24. package/dist/flatten-DK7eJKPx.d.cts.map +1 -0
  25. package/dist/flatten-Df9U40nO.cjs +182 -0
  26. package/dist/flatten-Df9U40nO.cjs.map +1 -0
  27. package/dist/index.cjs +113 -1018
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +12 -546
  30. package/dist/index.d.cts.map +1 -1
  31. package/dist/index.d.mts +12 -546
  32. package/dist/index.d.mts.map +1 -1
  33. package/dist/index.mjs +25 -935
  34. package/dist/index.mjs.map +1 -1
  35. package/dist/mapOrElse-B0_4r6Jn.mjs +96 -0
  36. package/dist/mapOrElse-B0_4r6Jn.mjs.map +1 -0
  37. package/dist/mapOrElse-B5gx9x2E.d.mts +64 -0
  38. package/dist/mapOrElse-B5gx9x2E.d.mts.map +1 -0
  39. package/dist/mapOrElse-DIe7LkYV.d.cts +64 -0
  40. package/dist/mapOrElse-DIe7LkYV.d.cts.map +1 -0
  41. package/dist/mapOrElse-H-GvAUka.cjs +137 -0
  42. package/dist/mapOrElse-H-GvAUka.cjs.map +1 -0
  43. package/dist/operators.cjs +33 -0
  44. package/dist/operators.d.cts +3 -0
  45. package/dist/operators.d.mts +3 -0
  46. package/dist/operators.mjs +4 -0
  47. package/dist/result-CY-KIivk.cjs +1100 -0
  48. package/dist/result-CY-KIivk.cjs.map +1 -0
  49. package/dist/result-DKKaNdOx.mjs +861 -0
  50. package/dist/result-DKKaNdOx.mjs.map +1 -0
  51. package/dist/sequence-Br6tAIIu.d.cts +419 -0
  52. package/dist/sequence-Br6tAIIu.d.cts.map +1 -0
  53. package/dist/sequence-C0jlR3AY.d.mts +419 -0
  54. package/dist/sequence-C0jlR3AY.d.mts.map +1 -0
  55. package/package.json +44 -10
package/dist/index.d.cts CHANGED
@@ -1,361 +1,15 @@
1
- //#region src/core/pipeable.d.ts
2
- type UnaryFunction<Input, Output> = (input: Input) => Output;
3
- type Awaitable<T> = T | Promise<T>;
4
- declare abstract class Pipeable {
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
- pipeAsync<A>(this: A): Promise<A>;
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
- }
48
- //#endregion
49
- //#region src/core/matcher.d.ts
50
- type Ctor<T> = abstract new (...args: any[]) => T;
51
- type TypeGuard<E, A extends E> = (error: E) => error is A;
52
- /**
53
- * Matcher for Err values (returns an arbitrary return type, e.g. string messages).
54
- *
55
- * - `.when(Ctor, handler)` matches via `instanceof`
56
- * - `.whenGuard(guard, handler)` matches via Type-Guard
57
- * - `.run()` is only allowed if all error cases have been handled (`E` has been reduced to `never`)
58
- */
59
- declare class ErrorMatchBuilder<E, R$1> {
60
- #private;
61
- constructor(error: unknown, matched?: boolean, value?: unknown);
62
- when<C extends Ctor<E>, R1>(ctor: C, handler: (error: InstanceType<C>) => R1): ErrorMatchBuilder<Exclude<E, InstanceType<C>>, R$1 | R1>;
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: E) => R2): R$1 | R2;
65
- run(this: ErrorMatchBuilder<never, R$1>): R$1;
66
- }
67
- type OkOfReturn$1<R$1> = R$1 extends Result<infer T, any> ? T : never;
68
- type ErrOfReturn$1<R$1> = R$1 extends Result<any, infer E> ? E : R$1;
69
- type ErrFactory = <E>(error: E) => Result<never, E>;
70
- /**
71
- * Matcher for `Result` Errors, which returns a `Result` again.
72
- *
73
- * Handlers may:
74
- * - return a `Result` (is returned directly)
75
- * - return an Error value (is automatically wrapped into `Err(error)`)
76
- */
77
- declare class ErrMatchBuilder<T, E, OutT, OutE> {
78
- #private;
79
- private constructor();
80
- static fromResult<T, E>(result: Result<T, E>, makeErr: ErrFactory): ErrMatchBuilder<T, E, never, never>;
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
- 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
- otherwise<R2>(handler: (error: E) => R2): Result<T | OutT | OkOfReturn$1<R2>, OutE | ErrOfReturn$1<R2>>;
84
- run(this: ErrMatchBuilder<T, never, OutT, OutE>): Result<T | OutT, OutE>;
85
- }
86
- //#endregion
87
- //#region src/core/map.d.ts
88
- /**
89
- * Transforms the value (Ok case).
90
- * Corresponds to Rust `map`.
91
- */
92
- declare function map<T, E, U>(project: (value: T) => U): (source: Result<T, E>) => Result<U, E>;
93
- //#endregion
94
- //#region src/core/mapErr.d.ts
95
- /**
96
- * Transforms the error (Err case).
97
- * Corresponds to Rust `map_err`.
98
- */
99
- declare function mapErr<T, E, F>(project: (error: E) => F): (source: Result<T, E>) => Result<T, F>;
100
- //#endregion
101
- //#region src/core/mapBoth.d.ts
102
- /**
103
- * Transforms both the Ok value and the Err error.
104
- * Corresponds to FP `bimap` / `mapBoth`.
105
- */
106
- declare function mapBoth<T, E, U, F>(mapOk: (value: T) => U, mapErr: (error: E) => F): (source: Result<T, E>) => Result<U, F>;
107
- /**
108
- * Alias for `mapBoth`.
109
- */
110
- declare const bimap: typeof mapBoth;
111
- //#endregion
112
- //#region src/core/flatMap.d.ts
113
- /**
114
- * Chains another operation that returns a Result.
115
- * Corresponds to Rust `and_then` or JS `flatMap`.
116
- */
117
- declare function flatMap<T, E, U>(project: (value: T) => Result<U, E>): (source: Result<T, E>) => Result<U, E>;
118
- //#endregion
119
- //#region src/core/zip.d.ts
120
- /**
121
- * Combines two Results into a Result of a tuple.
122
- * Short-circuits on the first Err (left before right).
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
- * Combines two Results and collects errors.
128
- * - Ok only if both are Ok
129
- * - Err([errors]) if at least one is Err (left before right)
130
- */
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
- * Executes a side effect (logging, debugging) without changing the Result.
137
- * Corresponds to Rust `inspect` / `inspect_err`.
138
- */
139
- declare function tap<T, E>(observer: {
140
- ok?: (val: T) => void;
141
- err?: (e: E) => void;
142
- }): (source: Result<T, E>) => Result<T, E>;
143
- //#endregion
144
- //#region src/core/filter.d.ts
145
- /**
146
- * Checks a condition. If false, the Result becomes Err.
147
- * Corresponds to Rust `filter` (partially).
148
- */
149
- declare function filter<T, E>(predicate: (val: T) => boolean, errorFn: () => E): (source: Result<T, E>) => Result<T, E>;
150
- //#endregion
151
- //#region src/core/match.d.ts
152
- /**
153
- * Resolves the Result. The end of the pipe.
154
- * Corresponds to Rust `match`.
155
- */
156
- declare function match<T, E, R$1>(handlers: {
157
- ok: (val: T) => R$1;
158
- err: (e: E) => R$1;
159
- }): (source: Result<T, E>) => R$1;
160
- //#endregion
161
- //#region src/core/recover.d.ts
162
- /**
163
- * Recover: converts Err to Ok(defaultValue).
164
- * Result is guaranteed to be Ok → Error type becomes `never`.
165
- */
166
- declare function recover<T, E, F>(defaultValue: F): (source: Result<T, E>) => Result<T | F, never>;
167
- /**
168
- * Like `recover`, but calculates the default value based on the error.
169
- */
170
- declare function recoverWith<T, E, F>(fn: (error: E) => F): (source: Result<T, E>) => Result<T | F, never>;
171
- //#endregion
172
- //#region src/core/swap.d.ts
173
- /**
174
- * Swaps Ok and Err.
175
- * Result<T, E> → Result<E, T>
176
- */
177
- declare function swap<T, E>(result: Result<T, E>): Result<E, T>;
178
- //#endregion
179
- //#region src/core/tryCatch.d.ts
180
- /**
181
- * Executes a function and catches exceptions.
182
- * Converts exceptions into Result<E>.
183
- * Corresponds to Rust `Result::from` for fallible operations.
184
- */
185
- declare function tryCatch<T, E = unknown>(fn: () => T, errorMapper?: (error: unknown) => E): (source: Result<any, any>) => Result<T, E>;
186
- //#endregion
187
- //#region src/core/tryMap.d.ts
188
- /**
189
- * Like `map`, but catches exceptions and converts them to Err.
190
- */
191
- declare function tryMap<T, E, U, F = unknown>(project: (value: T) => U, errorMapper?: (error: unknown) => F): (source: Result<T, E>) => Result<U, E | F>;
192
- //#endregion
193
- //#region src/core/collectFirstOk.d.ts
194
- type OkValueOf$2<R$1> = R$1 extends Result<infer T, any> ? T : never;
195
- type ErrValueOf$2<R$1> = R$1 extends Result<any, infer E> ? E : never;
196
- /**
197
- * Parse a set of `Result`s, short-circuits when an input value is `Ok`.
198
- * If no `Ok` is found, returns an `Err` containing the collected error values.
199
- * Useful for "try multiple approaches until one works" patterns.
200
- */
201
- declare function collectFirstOk<const Results extends readonly Result<any, any>[]>(results: Results): Result<OkValueOf$2<Results[number]>, ErrValueOf$2<Results[number]>[]>;
202
- //#endregion
203
- //#region src/core/mapAsync.d.ts
204
- /**
205
- * Async version of map.
206
- */
207
- declare function mapAsync<T, E, U>(project: (value: T) => Promise<U>): (source: Result<T, E>) => Promise<Result<U, E>>;
208
- //#endregion
209
- //#region src/core/mapErrAsync.d.ts
210
- /**
211
- * Async version of mapErr.
212
- */
213
- declare function mapErrAsync<T, E, F>(project: (error: E) => Promise<F>): (source: Result<T, E>) => Promise<Result<T, F>>;
214
- //#endregion
215
- //#region src/core/flatMapAsync.d.ts
216
- /**
217
- * Async version of flatMap.
218
- */
219
- declare function flatMapAsync<T, E, U>(project: (value: T) => Promise<Result<U, E>>): (source: Result<T, E>) => Promise<Result<U, E>>;
220
- //#endregion
221
- //#region src/core/tapAsync.d.ts
222
- /**
223
- * Async version of tap.
224
- */
225
- declare function tapAsync<T, E>(observer: {
226
- ok?: (val: T) => Promise<void>;
227
- err?: (e: E) => Promise<void>;
228
- }): (source: Result<T, E>) => Promise<Result<T, E>>;
229
- //#endregion
230
- //#region src/core/filterAsync.d.ts
231
- /**
232
- * Async version of filter.
233
- */
234
- declare function filterAsync<T, E>(predicate: (val: T) => Promise<boolean>, errorFn: () => Promise<E>): (source: Result<T, E>) => Promise<Result<T, E>>;
235
- //#endregion
236
- //#region src/core/matchAsync.d.ts
237
- /**
238
- * Async version of match.
239
- */
240
- declare function matchAsync<T, E, R$1>(handlers: {
241
- ok: (val: T) => Promise<R$1>;
242
- err: (e: E) => Promise<R$1>;
243
- }): (source: Result<T, E>) => Promise<R$1>;
244
- //#endregion
245
- //#region src/core/tryCatchAsync.d.ts
246
- /**
247
- * Async version of tryCatch.
248
- */
249
- declare function tryCatchAsync<T, E = unknown>(fn: () => Promise<T>, errorMapper?: (error: unknown) => E): (source: Result<any, any>) => Promise<Result<T, E>>;
250
- //#endregion
251
- //#region src/core/tryMapAsync.d.ts
252
- /**
253
- * Async version of tryMap.
254
- */
255
- declare function tryMapAsync<T, E, U, F = unknown>(project: (value: T) => Promise<U>, errorMapper?: (error: unknown) => F): (source: Result<T, E>) => Promise<Result<U, E | F>>;
256
- //#endregion
257
- //#region src/core/result.d.ts
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
- * Matches on the Err value via `.when(...)` chain.
293
- *
294
- * Note: for type safety reasons, `.match()` can only be called on a Result already narrowed to `Err`,
295
- * e.g. inside `if (result.isErr()) { ... }`.
296
- */
297
- match<T, E>(this: Result<T, E>): ErrorMatchBuilder<E, never>;
298
- /**
299
- * Matches on the Err value, but normalizes every branch to a `Result`:
300
- * - Handlers may return a `Result` (is returned directly)
301
- * - or an Error value (is wrapped into `Err(error)`)
302
- */
303
- matchErr<T, E>(this: Result<T, E>): ErrMatchBuilder<T, E, never, never>;
304
- /**
305
- * Serializes the Result into a simple object format.
306
- * Preserves the original types.
307
- */
308
- serialize<T, E>(this: Result<T, E>): {
309
- isSuccess: boolean;
310
- data?: T;
311
- error?: E;
312
- };
313
- /**
314
- * Serializes the Result into a user-friendly format.
315
- * Converts Errors to readable 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
1
+ import { A as recover, B as combine, C as flatMapAsync, D as tryMap, E as collectFirstOk, F as flatMap, H as isResult, I as bimap, L as mapBoth, M as match, N as filter, O as tryCatch, P as tap, R as mapErr, S as tapAsync, T as mapAsync, U as matchTag, V as zip, W as Awaitable, _ as tryFn, a as Ok, b as matchAsync, c as ResultType, d as fromPromise, f as fromThrowable, g as tryAsync, h as okIfLazy, i as Err, j as recoverWith, k as swap, l as err, m as okIf, n as sequence, o as OperatorFunction, p as ok, r as AsyncOperatorFunction, s as Result, t as all, u as fromNullable, v as tryMapAsync, w as mapErrAsync, x as filterAsync, y as tryCatchAsync, z as map } from "./sequence-Br6tAIIu.cjs";
2
+ import { a as collectFirstOkAsync, i as collectFirstOkParallelAsync, n as partition, o as sequenceRecord, r as collectAllErrors, t as flatten } from "./flatten-DK7eJKPx.cjs";
3
+ import { _ as ResultTypeError, a as ERR_MATCH_ERR_HANDLER_NOT_RESULT, b as UnwrapOnErrError, c as ERR_UNWRAP_ERR_ON_OK, d as ExpectOkError, f as InvalidResultStateError, g as ResultErrorCode, h as ResultError, i as ERR_INVALID_STATE, l as ERR_UNWRAP_ON_ERR, m as MatchOnOkError, n as ERR_EXPECT_OK, o as ERR_MATCH_ON_OK, p as MatchErrHandlerNotResultError, r as ERR_INVALID_RESULT_STATE, s as ERR_TASK_YIELD_NOT_RESULT, t as ERR_EXPECT_ERR, u as ExpectErrError, v as TaskYieldNotResultError, y as UnwrapErrOnOkError } from "./errors-BFjY06EV.cjs";
4
+ import { a as and, i as or, n as mapOr, o as foldAsync, r as orElse, s as fold, t as mapOrElse } from "./mapOrElse-DIe7LkYV.cjs";
5
+
352
6
  //#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>;
7
+ type AnyGenerator<Y = unknown, R = unknown, N = unknown> = Generator<Y, R, N> | AsyncGenerator<Y, R, N>;
354
8
  type ErrorOfYield<Y> = Y extends Result<any, infer E> ? E : never;
355
9
  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;
10
+ type AwaitedReturn<R> = Awaited<R>;
11
+ type OkOfReturn<R> = AwaitedReturn<R> extends Result<infer T, any> ? T : AwaitedReturn<R>;
12
+ type ErrOfReturn<R> = AwaitedReturn<R> extends Result<any, infer E> ? E : never;
359
13
  /**
360
14
  * Generator-based do-notation for `Result`.
361
15
  *
@@ -368,80 +22,10 @@ type ErrOfReturn<R$1> = AwaitedReturn<R$1> extends Result<any, infer E> ? E : ne
368
22
  * });
369
23
  * ```
370
24
  */
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>>;
25
+ declare function task<const Y, const R>(makeGenerator: () => AnyGenerator<Y, R, unknown>): Promise<Result<OkOfReturn<R>, ErrorOfYield<Y> | ErrOfReturn<R>>>;
26
+ declare function task<const Y, const R, EThrown>(makeGenerator: () => AnyGenerator<Y, R, unknown>, onThrow: OnThrow<EThrown>): Promise<Result<OkOfReturn<R>, ErrorOfYield<Y> | ErrOfReturn<R> | EThrown>>;
373
27
  declare const gen: typeof task;
374
28
  //#endregion
375
- //#region src/errors.d.ts
376
- declare const ERR_INVALID_STATE: "ERR_INVALID_STATE";
377
- declare const ERR_TASK_YIELD_NOT_RESULT: "ERR_TASK_YIELD_NOT_RESULT";
378
- declare const ERR_MATCH_ON_OK: "ERR_MATCH_ON_OK";
379
- declare const ERR_UNWRAP_ON_ERR: "ERR_UNWRAP_ON_ERR";
380
- declare const ERR_UNWRAP_ERR_ON_OK: "ERR_UNWRAP_ERR_ON_OK";
381
- declare const ERR_EXPECT_OK: "ERR_EXPECT_OK";
382
- declare const ERR_EXPECT_ERR: "ERR_EXPECT_ERR";
383
- type ResultErrorCode = typeof ERR_INVALID_STATE | typeof ERR_TASK_YIELD_NOT_RESULT | typeof ERR_MATCH_ON_OK | typeof ERR_UNWRAP_ON_ERR | typeof ERR_UNWRAP_ERR_ON_OK | typeof ERR_EXPECT_OK | typeof ERR_EXPECT_ERR;
384
- declare class ResultError extends Error {
385
- readonly code: ResultErrorCode;
386
- readonly context?: string;
387
- constructor(message: string, code: ResultErrorCode, context?: string);
388
- }
389
- declare class ResultTypeError extends TypeError {
390
- readonly code: ResultErrorCode;
391
- readonly context?: string;
392
- constructor(message: string, code: ResultErrorCode, context?: string);
393
- }
394
- declare class InvalidResultStateError extends ResultError {
395
- constructor(context?: string);
396
- }
397
- declare class TaskYieldNotResultError extends ResultTypeError {
398
- readonly yieldedValue: unknown;
399
- constructor(yieldedValue: unknown);
400
- }
401
- declare class MatchOnOkError extends ResultTypeError {
402
- constructor();
403
- }
404
- declare class UnwrapOnErrError extends ResultTypeError {
405
- readonly errorValue: unknown;
406
- constructor(errorValue: unknown);
407
- }
408
- declare class UnwrapErrOnOkError extends ResultTypeError {
409
- readonly okValue: unknown;
410
- constructor(okValue: unknown);
411
- }
412
- declare class ExpectOkError extends ResultError {
413
- readonly expectedMessage: string;
414
- constructor(expectedMessage: string);
415
- }
416
- declare class ExpectErrError extends ResultError {
417
- readonly expectedMessage: string;
418
- constructor(expectedMessage: string);
419
- }
420
- //#endregion
421
- //#region src/core/fold.d.ts
422
- /**
423
- * Folds the Result into a single value by applying one of two functions.
424
- * The end of the pipe.
425
- *
426
- * This is the pipe operator equivalent of the `.fold()` instance method.
427
- */
428
- declare function fold<T, E, R$1>(handlers: {
429
- ok: (val: T) => R$1;
430
- err: (e: E) => R$1;
431
- }): (source: Result<T, E>) => R$1;
432
- //#endregion
433
- //#region src/core/foldAsync.d.ts
434
- /**
435
- * Async version of `fold`. Folds the Result into a single value asynchronously.
436
- * The end of the pipe.
437
- *
438
- * This is the async pipe operator equivalent of the `.fold()` instance method.
439
- */
440
- declare function foldAsync<T, E, R$1>(handlers: {
441
- ok: (val: T) => Promise<R$1>;
442
- err: (e: E) => Promise<R$1>;
443
- }): (source: Result<T, E>) => Promise<R$1>;
444
- //#endregion
445
29
  //#region src/core/unwrap.d.ts
446
30
  /**
447
31
  * Returns the value or throws an Error.
@@ -498,117 +82,6 @@ declare function expectResult<T, E>(result: Result<T, E>, message: string): T;
498
82
  */
499
83
  declare function expectErr<T, E>(result: Result<T, E>, message: string): E;
500
84
  //#endregion
501
- //#region src/core/and.d.ts
502
- /**
503
- * Combines two Results. Returns the second one only if the first is Ok.
504
- * Corresponds to Rust `and`.
505
- */
506
- declare function and<T, E, U>(result: Result<T, E>, other: Result<U, E>): Result<U, E>;
507
- //#endregion
508
- //#region src/core/or.d.ts
509
- /**
510
- * Fallback to another Result if the first is Err.
511
- * Corresponds to Rust `or`.
512
- */
513
- declare function or<T, E, F>(result: Result<T, E>, other: Result<T, F>): Result<T, F>;
514
- //#endregion
515
- //#region src/core/orElse.d.ts
516
- /**
517
- * Fallback with a function that returns a Result.
518
- * Corresponds to Rust `or_else`.
519
- */
520
- declare function orElse<T, E, F>(result: Result<T, E>, fn: (error: E) => Result<T, F>): Result<T, F>;
521
- //#endregion
522
- //#region src/core/mapOr.d.ts
523
- /**
524
- * Transforms the value or returns a default value.
525
- * Corresponds to Rust `map_or`.
526
- */
527
- declare function mapOr<T, E, U>(result: Result<T, E>, defaultValue: U, fn: (value: T) => U): U;
528
- //#endregion
529
- //#region src/core/mapOrElse.d.ts
530
- /**
531
- * Transforms the value or calculates a default value using a function.
532
- * Corresponds to Rust `map_or_else`.
533
- */
534
- declare function mapOrElse<T, E, U>(result: Result<T, E>, defaultFn: (error: E) => U, fn: (value: T) => U): U;
535
- //#endregion
536
- //#region src/core/sequence.d.ts
537
- /**
538
- * Combines a list of Results into a single Result of a list.
539
- * Short-circuits on the first Err.
540
- * Analogous to Rust `collect::<Result<Vec<_>, _>>()`.
541
- */
542
- declare function sequence<T, E>(results: readonly Result<T, E>[]): Result<T[], E>;
543
- /**
544
- * Alias for `sequence`.
545
- */
546
- declare function all<T, E>(results: readonly Result<T, E>[]): Result<T[], E>;
547
- //#endregion
548
- //#region src/core/sequenceRecord.d.ts
549
- type OkValueOf$1<R$1> = R$1 extends Result<infer T, any> ? T : never;
550
- type ErrValueOf$1<R$1> = R$1 extends Result<any, infer E> ? E : never;
551
- /**
552
- * Like `sequence`, but for Records/Objects.
553
- * Short-circuits on the first Err.
554
- */
555
- declare function sequenceRecord<const R$1 extends Record<string, Result<any, any>>>(record: R$1): Result<{ [K in keyof R$1]: OkValueOf$1<R$1[K]> }, ErrValueOf$1<R$1[keyof R$1]>>;
556
- //#endregion
557
- //#region src/core/collectFirstOkAsync.d.ts
558
- type CollectFirstOkAsyncInput$1 = Promise<Result<any, any>> | (() => Awaitable<Result<any, any>>);
559
- type ResolvedResult$1<I> = I extends (() => infer R) ? Awaited<R> : I extends Promise<infer R> ? R : never;
560
- type OkValueOfInput$1<I> = ResolvedResult$1<I> extends Result<infer T, any> ? T : never;
561
- type ErrValueOfInput$1<I> = ResolvedResult$1<I> extends Result<any, infer E> ? E : never;
562
- /**
563
- * Async version of collectFirstOk.
564
- *
565
- * - Takes either already started Promises or "Thunks" (`() => Awaitable<Result<...>>`).
566
- * - Processes inputs strictly sequentially (like `for ... of` + `await`).
567
- * - Returns the first `Ok` and collects all errors if no `Ok` is found.
568
- */
569
- declare function collectFirstOkAsync<const Inputs extends readonly CollectFirstOkAsyncInput$1[]>(inputs: Inputs): Promise<Result<OkValueOfInput$1<Inputs[number]>, ErrValueOfInput$1<Inputs[number]>[]>>;
570
- //#endregion
571
- //#region src/core/collectFirstOkParallelAsync.d.ts
572
- type CollectFirstOkAsyncInput = Promise<Result<any, any>> | (() => Awaitable<Result<any, any>>);
573
- type ResolvedResult<I> = I extends (() => infer R) ? Awaited<R> : I extends Promise<infer R> ? R : never;
574
- type OkValueOfInput<I> = ResolvedResult<I> extends Result<infer T, any> ? T : never;
575
- type ErrValueOfInput<I> = ResolvedResult<I> extends Result<any, infer E> ? E : never;
576
- /**
577
- * Parallel version of `collectFirstOkAsync`.
578
- *
579
- * - Starts all inputs immediately (Promises or Thunks).
580
- * - Returns the first `Ok` as soon as it is available.
581
- * - If no `Ok` is found, returns an `Err` with all error values (in input order).
582
- * - Rejections are treated as `ErrValue` (`caught as ErrValue`).
583
- * - If multiple inputs provide an `Ok`, the one that completes first wins.
584
- * In case of simultaneous completion, the first observed result wins.
585
- * - If no `Ok` arrives and at least one input never settles, the Promise remains pending.
586
- */
587
- declare function collectFirstOkParallelAsync<const Inputs extends readonly CollectFirstOkAsyncInput[]>(inputs: Inputs): Promise<Result<OkValueOfInput<Inputs[number]>, ErrValueOfInput<Inputs[number]>[]>>;
588
- //#endregion
589
- //#region src/core/collectAllErrors.d.ts
590
- /**
591
- * Combines a list of Results.
592
- * Return Ok(values) only if all are Ok, otherwise Err([errors]).
593
- */
594
- declare function collectAllErrors<T, E>(results: readonly Result<T, E>[]): Result<T[], E[]>;
595
- //#endregion
596
- //#region src/core/partition.d.ts
597
- type OkValueOf<R$1> = R$1 extends Result<infer T, any> ? T : never;
598
- type ErrValueOf<R$1> = R$1 extends Result<any, infer E> ? E : never;
599
- /**
600
- * Partitions Results into Ok values and Err errors.
601
- */
602
- declare function partition<const Results extends readonly Result<any, any>[]>(results: Results): [oks: Array<OkValueOf<Results[number]>>, errs: Array<ErrValueOf<Results[number]>>];
603
- //#endregion
604
- //#region src/core/flatten.d.ts
605
- /**
606
- * Flattens a nested Result.
607
- * Result<Result<T, E>, E> → Result<T, E>
608
- * Corresponds to Rust `flatten`.
609
- */
610
- declare function flatten<T, E>(result: Result<Result<T, E>, E>): Result<T, E>;
611
- //#endregion
612
85
  //#region src/core/toPromise.d.ts
613
86
  /**
614
87
  * Converts a Result to a Promise.
@@ -651,12 +124,5 @@ declare function contains<T, E>(result: Result<T, E>, value: T): boolean;
651
124
  */
652
125
  declare function containsErr<T, E>(result: Result<T, E>, error: E): boolean;
653
126
  //#endregion
654
- //#region src/core/isResult.d.ts
655
- /**
656
- * Checks whether a value is a Result.
657
- * Pure function alternative for runtime checks.
658
- */
659
- declare function isResult(value: unknown): value is Result<any, any>;
660
- //#endregion
661
- export { AsyncOperatorFunction, type Awaitable, ERR_EXPECT_ERR, ERR_EXPECT_OK, ERR_INVALID_STATE, ERR_MATCH_ON_OK, ERR_TASK_YIELD_NOT_RESULT, ERR_UNWRAP_ERR_ON_OK, ERR_UNWRAP_ON_ERR, Err, ExpectErrError, ExpectOkError, InvalidResultStateError, MatchOnOkError, Ok, OperatorFunction, Result, ResultError, ResultErrorCode, ResultType, ResultTypeError, TaskYieldNotResultError, UnwrapErrOnOkError, UnwrapOnErrError, all, and, bimap, collectAllErrors, collectFirstOk, collectFirstOkAsync, collectFirstOkParallelAsync, combine, contains, containsErr, err, expectErr, expectResult, filter, filterAsync, flatMap, flatMapAsync, flatten, fold, foldAsync, fromNullable, fromPromise, gen, isErr, isOk, isResult, map, mapAsync, mapBoth, mapErr, mapErrAsync, mapOr, mapOrElse, match, matchAsync, ok, okIf, okIfLazy, or, orElse, partition, recover, recoverWith, sequence, sequenceRecord, swap, tap, tapAsync, task, toNullable, toPromise, tryCatch, tryCatchAsync, tryFn, tryMap, tryMapAsync, unwrap, unwrapErr, unwrapOr, unwrapOrDefault, unwrapOrElse, unwrapOrThrow, zip };
127
+ export { AsyncOperatorFunction, Awaitable, ERR_EXPECT_ERR, ERR_EXPECT_OK, ERR_INVALID_RESULT_STATE, ERR_INVALID_STATE, ERR_MATCH_ERR_HANDLER_NOT_RESULT, ERR_MATCH_ON_OK, ERR_TASK_YIELD_NOT_RESULT, ERR_UNWRAP_ERR_ON_OK, ERR_UNWRAP_ON_ERR, Err, ExpectErrError, ExpectOkError, InvalidResultStateError, MatchErrHandlerNotResultError, MatchOnOkError, Ok, OperatorFunction, Result, ResultError, ResultErrorCode, ResultType, ResultTypeError, TaskYieldNotResultError, UnwrapErrOnOkError, UnwrapOnErrError, all, and, bimap, collectAllErrors, collectFirstOk, collectFirstOkAsync, collectFirstOkParallelAsync, combine, contains, containsErr, err, expectErr, expectResult, filter, filterAsync, flatMap, flatMapAsync, flatten, fold, foldAsync, fromNullable, fromPromise, fromThrowable, gen, isErr, isOk, isResult, map, mapAsync, mapBoth, mapErr, mapErrAsync, mapOr, mapOrElse, match, matchAsync, matchTag, ok, okIf, okIfLazy, or, orElse, partition, recover, recoverWith, sequence, sequenceRecord, swap, tap, tapAsync, task, toNullable, toPromise, tryAsync, tryCatch, tryCatchAsync, tryFn, tryMap, tryMapAsync, unwrap, unwrapErr, unwrapOr, unwrapOrDefault, unwrapOrElse, unwrapOrThrow, zip };
662
128
  //# sourceMappingURL=index.d.cts.map