@shirudo/result 1.0.1 → 1.1.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.
- package/dist/collections.cjs +4 -3
- package/dist/collections.d.cts +2 -2
- package/dist/collections.d.mts +2 -2
- package/dist/collections.mjs +2 -2
- package/dist/errors.cjs +131 -20
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.cts +63 -2
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.mts +63 -2
- package/dist/errors.d.mts.map +1 -0
- package/dist/errors.mjs +109 -2
- package/dist/errors.mjs.map +1 -0
- package/dist/{flatten-Df9U40nO.cjs → flatten-B_XIkaOK.cjs} +29 -3
- package/dist/flatten-B_XIkaOK.cjs.map +1 -0
- package/dist/flatten-C7D6Kttf.d.mts +81 -0
- package/dist/flatten-C7D6Kttf.d.mts.map +1 -0
- package/dist/{flatten-C6Y9hx79.mjs → flatten-ChTL5BfA.mjs} +24 -4
- package/dist/flatten-ChTL5BfA.mjs.map +1 -0
- package/dist/flatten-D0K8UcQH.d.cts +81 -0
- package/dist/flatten-D0K8UcQH.d.cts.map +1 -0
- package/dist/index.cjs +90 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +78 -58
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +78 -58
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +58 -12
- package/dist/index.mjs.map +1 -1
- package/dist/operators.cjs +31 -30
- package/dist/operators.d.cts +2 -2
- package/dist/operators.d.mts +2 -2
- package/dist/operators.mjs +2 -2
- package/dist/{result-CY-KIivk.cjs → result-BBOGxvSH.cjs} +86 -503
- package/dist/result-BBOGxvSH.cjs.map +1 -0
- package/dist/{result-DKKaNdOx.mjs → result-q9Na2bGa.mjs} +87 -372
- package/dist/result-q9Na2bGa.mjs.map +1 -0
- package/dist/sequence-DDwePRLd.d.cts +283 -0
- package/dist/sequence-DDwePRLd.d.cts.map +1 -0
- package/dist/sequence-DDwePRLd.d.mts +283 -0
- package/dist/sequence-DDwePRLd.d.mts.map +1 -0
- package/dist/swap-BnyMBdD_.cjs +552 -0
- package/dist/swap-BnyMBdD_.cjs.map +1 -0
- package/dist/swap-CFD2g1cB.mjs +385 -0
- package/dist/swap-CFD2g1cB.mjs.map +1 -0
- package/dist/swap-CrHQZIax.d.cts +212 -0
- package/dist/swap-CrHQZIax.d.cts.map +1 -0
- package/dist/swap-DT4LdRFV.d.mts +212 -0
- package/dist/swap-DT4LdRFV.d.mts.map +1 -0
- package/package.json +9 -8
- package/dist/errors-2WOswg7r.mjs +0 -95
- package/dist/errors-2WOswg7r.mjs.map +0 -1
- package/dist/errors-BFjY06EV.d.cts +0 -55
- package/dist/errors-BFjY06EV.d.cts.map +0 -1
- package/dist/errors-C5qGMRiU.d.mts +0 -55
- package/dist/errors-C5qGMRiU.d.mts.map +0 -1
- package/dist/errors-D2EMzJQl.cjs +0 -209
- package/dist/errors-D2EMzJQl.cjs.map +0 -1
- package/dist/flatten-B8bN6fiI.d.mts +0 -71
- package/dist/flatten-B8bN6fiI.d.mts.map +0 -1
- package/dist/flatten-C6Y9hx79.mjs.map +0 -1
- package/dist/flatten-DK7eJKPx.d.cts +0 -71
- package/dist/flatten-DK7eJKPx.d.cts.map +0 -1
- package/dist/flatten-Df9U40nO.cjs.map +0 -1
- package/dist/mapOrElse-B0_4r6Jn.mjs +0 -96
- package/dist/mapOrElse-B0_4r6Jn.mjs.map +0 -1
- package/dist/mapOrElse-B5gx9x2E.d.mts +0 -64
- package/dist/mapOrElse-B5gx9x2E.d.mts.map +0 -1
- package/dist/mapOrElse-DIe7LkYV.d.cts +0 -64
- package/dist/mapOrElse-DIe7LkYV.d.cts.map +0 -1
- package/dist/mapOrElse-H-GvAUka.cjs +0 -137
- package/dist/mapOrElse-H-GvAUka.cjs.map +0 -1
- package/dist/result-CY-KIivk.cjs.map +0 -1
- package/dist/result-DKKaNdOx.mjs.map +0 -1
- package/dist/sequence-Br6tAIIu.d.cts +0 -419
- package/dist/sequence-Br6tAIIu.d.cts.map +0 -1
- package/dist/sequence-C0jlR3AY.d.mts +0 -419
- package/dist/sequence-C0jlR3AY.d.mts.map +0 -1
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { s as Result } from "./sequence-DDwePRLd.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/core/map.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Transforms the value (Ok case).
|
|
6
|
+
* Corresponds to Rust `map`.
|
|
7
|
+
*/
|
|
8
|
+
declare function map<T, E, U>(project: (value: T) => U): (source: Result<T, E>) => Result<U, E>;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/core/mapErr.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* Transforms the error (Err case).
|
|
13
|
+
* Corresponds to Rust `map_err`.
|
|
14
|
+
*/
|
|
15
|
+
declare function mapErr<T, E, F>(project: (error: E) => F): (source: Result<T, E>) => Result<T, F>;
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/core/mapBoth.d.ts
|
|
18
|
+
/**
|
|
19
|
+
* Transforms both the Ok value and the Err error.
|
|
20
|
+
* Corresponds to FP `bimap` / `mapBoth`.
|
|
21
|
+
*/
|
|
22
|
+
declare function mapBoth<T, E, U, F>(mapOk: (value: T) => U, mapErr: (error: E) => F): (source: Result<T, E>) => Result<U, F>;
|
|
23
|
+
/**
|
|
24
|
+
* Alias for `mapBoth`.
|
|
25
|
+
*/
|
|
26
|
+
declare const bimap: typeof mapBoth;
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/core/flatMap.d.ts
|
|
29
|
+
/**
|
|
30
|
+
* Chains another operation that returns a Result.
|
|
31
|
+
* Corresponds to Rust `and_then` or JS `flatMap`.
|
|
32
|
+
*/
|
|
33
|
+
declare function flatMap<T, E, U, F>(project: (value: T) => Result<U, F>): (source: Result<T, E>) => Result<U, E | F>;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/core/tap.d.ts
|
|
36
|
+
/**
|
|
37
|
+
* Executes a side effect (logging, debugging) without changing the Result.
|
|
38
|
+
* Corresponds to Rust `inspect` / `inspect_err`.
|
|
39
|
+
*/
|
|
40
|
+
declare function tap<T, E>(observer: {
|
|
41
|
+
ok?: (val: T) => void;
|
|
42
|
+
err?: (e: E) => void;
|
|
43
|
+
}): (source: Result<T, E>) => Result<T, E>;
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/core/filter.d.ts
|
|
46
|
+
/**
|
|
47
|
+
* Checks a condition. If false, the Result becomes Err.
|
|
48
|
+
* Corresponds to Rust `filter` (partially).
|
|
49
|
+
*/
|
|
50
|
+
declare function filter<T, E>(predicate: (val: T) => boolean, errorFn: () => E): (source: Result<T, E>) => Result<T, E>;
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/core/fold.d.ts
|
|
53
|
+
/**
|
|
54
|
+
* Folds the Result into a single value by applying one of two functions.
|
|
55
|
+
* The end of the pipe.
|
|
56
|
+
*
|
|
57
|
+
* This is the pipe operator equivalent of the `.fold()` instance method.
|
|
58
|
+
*/
|
|
59
|
+
declare function fold<T, E, R>(handlers: {
|
|
60
|
+
ok: (val: T) => R;
|
|
61
|
+
err: (e: E) => R;
|
|
62
|
+
}): (source: Result<T, E>) => R;
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/core/match.d.ts
|
|
65
|
+
/**
|
|
66
|
+
* Resolves the Result. The end of the pipe.
|
|
67
|
+
* Corresponds to Rust `match`.
|
|
68
|
+
*/
|
|
69
|
+
declare function match<T, E, R>(handlers: {
|
|
70
|
+
ok: (val: T) => R;
|
|
71
|
+
err: (e: E) => R;
|
|
72
|
+
}): (source: Result<T, E>) => R;
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/core/tryCatch.d.ts
|
|
75
|
+
/**
|
|
76
|
+
* Executes a function and catches exceptions.
|
|
77
|
+
* Converts exceptions into Result<E>.
|
|
78
|
+
* Corresponds to Rust `Result::from` for fallible operations.
|
|
79
|
+
*/
|
|
80
|
+
declare function tryCatch<T>(fn: () => T): <SE>(source: Result<unknown, SE>) => Result<T, unknown>;
|
|
81
|
+
declare function tryCatch<T, E>(fn: () => T, errorMapper: (error: unknown) => E): <SE>(source: Result<unknown, SE>) => Result<T, SE | E>;
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/core/tryMap.d.ts
|
|
84
|
+
/**
|
|
85
|
+
* Like `map`, but catches exceptions and converts them to Err.
|
|
86
|
+
*/
|
|
87
|
+
declare function tryMap<T, E, U>(project: (value: T) => U): (source: Result<T, E>) => Result<U, unknown>;
|
|
88
|
+
declare function tryMap<T, E, U, F>(project: (value: T) => U, errorMapper: (error: unknown) => F): (source: Result<T, E>) => Result<U, E | F>;
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/core/recover.d.ts
|
|
91
|
+
/**
|
|
92
|
+
* Recover: converts Err to Ok(defaultValue).
|
|
93
|
+
* Result is guaranteed to be Ok → Error type becomes `never`.
|
|
94
|
+
*/
|
|
95
|
+
declare function recover<T, E, F>(defaultValue: F): (source: Result<T, E>) => Result<T | F, never>;
|
|
96
|
+
/**
|
|
97
|
+
* Like `recover`, but calculates the default value based on the error.
|
|
98
|
+
*/
|
|
99
|
+
declare function recoverWith<T, E, F>(fn: (error: E) => F): (source: Result<T, E>) => Result<T | F, never>;
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/core/mapAsync.d.ts
|
|
102
|
+
/**
|
|
103
|
+
* Async version of map.
|
|
104
|
+
*/
|
|
105
|
+
declare function mapAsync<T, E, U>(project: (value: T) => Promise<U>): (source: Result<T, E>) => Promise<Result<U, E>>;
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/core/mapErrAsync.d.ts
|
|
108
|
+
/**
|
|
109
|
+
* Async version of mapErr.
|
|
110
|
+
*/
|
|
111
|
+
declare function mapErrAsync<T, E, F>(project: (error: E) => Promise<F>): (source: Result<T, E>) => Promise<Result<T, F>>;
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/core/flatMapAsync.d.ts
|
|
114
|
+
/**
|
|
115
|
+
* Async version of flatMap.
|
|
116
|
+
*/
|
|
117
|
+
declare function flatMapAsync<T, E, U, F>(project: (value: T) => Promise<Result<U, F>>): (source: Result<T, E>) => Promise<Result<U, E | F>>;
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/core/tapAsync.d.ts
|
|
120
|
+
/**
|
|
121
|
+
* Async version of tap.
|
|
122
|
+
*/
|
|
123
|
+
declare function tapAsync<T, E>(observer: {
|
|
124
|
+
ok?: (val: T) => Promise<void>;
|
|
125
|
+
err?: (e: E) => Promise<void>;
|
|
126
|
+
}): (source: Result<T, E>) => Promise<Result<T, E>>;
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/core/filterAsync.d.ts
|
|
129
|
+
/**
|
|
130
|
+
* Async version of filter.
|
|
131
|
+
*/
|
|
132
|
+
declare function filterAsync<T, E>(predicate: (val: T) => Promise<boolean>, errorFn: () => Promise<E>): (source: Result<T, E>) => Promise<Result<T, E>>;
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/core/foldAsync.d.ts
|
|
135
|
+
/**
|
|
136
|
+
* Async version of `fold`. Folds the Result into a single value asynchronously.
|
|
137
|
+
* The end of the pipe.
|
|
138
|
+
*
|
|
139
|
+
* This is the async pipe operator equivalent of the `.fold()` instance method.
|
|
140
|
+
*/
|
|
141
|
+
declare function foldAsync<T, E, R>(handlers: {
|
|
142
|
+
ok: (val: T) => Promise<R>;
|
|
143
|
+
err: (e: E) => Promise<R>;
|
|
144
|
+
}): (source: Result<T, E>) => Promise<R>;
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/core/matchAsync.d.ts
|
|
147
|
+
/**
|
|
148
|
+
* Async version of match.
|
|
149
|
+
*/
|
|
150
|
+
declare function matchAsync<T, E, R>(handlers: {
|
|
151
|
+
ok: (val: T) => Promise<R>;
|
|
152
|
+
err: (e: E) => Promise<R>;
|
|
153
|
+
}): (source: Result<T, E>) => Promise<R>;
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/core/tryCatchAsync.d.ts
|
|
156
|
+
/**
|
|
157
|
+
* Async version of tryCatch.
|
|
158
|
+
*/
|
|
159
|
+
declare function tryCatchAsync<T>(fn: () => Promise<T>): <SE>(source: Result<unknown, SE>) => Promise<Result<T, unknown>>;
|
|
160
|
+
declare function tryCatchAsync<T, E>(fn: () => Promise<T>, errorMapper: (error: unknown) => E): <SE>(source: Result<unknown, SE>) => Promise<Result<T, SE | E>>;
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region src/core/tryMapAsync.d.ts
|
|
163
|
+
/**
|
|
164
|
+
* Async version of tryMap.
|
|
165
|
+
*/
|
|
166
|
+
declare function tryMapAsync<T, E, U>(project: (value: T) => Promise<U>): (source: Result<T, E>) => Promise<Result<U, unknown>>;
|
|
167
|
+
declare function tryMapAsync<T, E, U, F>(project: (value: T) => Promise<U>, errorMapper: (error: unknown) => F): (source: Result<T, E>) => Promise<Result<U, E | F>>;
|
|
168
|
+
//#endregion
|
|
169
|
+
//#region src/core/and.d.ts
|
|
170
|
+
/**
|
|
171
|
+
* Combines two Results. Returns the second one only if the first is Ok.
|
|
172
|
+
* Corresponds to Rust `and`.
|
|
173
|
+
*/
|
|
174
|
+
declare function and<T, E, U>(result: Result<T, E>, other: Result<U, E>): Result<U, E>;
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region src/core/or.d.ts
|
|
177
|
+
/**
|
|
178
|
+
* Fallback to another Result if the first is Err.
|
|
179
|
+
* Corresponds to Rust `or`.
|
|
180
|
+
*/
|
|
181
|
+
declare function or<T, E, F>(result: Result<T, E>, other: Result<T, F>): Result<T, F>;
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/core/orElse.d.ts
|
|
184
|
+
/**
|
|
185
|
+
* Fallback with a function that returns a Result.
|
|
186
|
+
* Corresponds to Rust `or_else`.
|
|
187
|
+
*/
|
|
188
|
+
declare function orElse<T, E, F>(result: Result<T, E>, fn: (error: E) => Result<T, F>): Result<T, F>;
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region src/core/mapOr.d.ts
|
|
191
|
+
/**
|
|
192
|
+
* Transforms the value or returns a default value.
|
|
193
|
+
* Corresponds to Rust `map_or`.
|
|
194
|
+
*/
|
|
195
|
+
declare function mapOr<T, E, U>(result: Result<T, E>, defaultValue: U, fn: (value: T) => U): U;
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/core/mapOrElse.d.ts
|
|
198
|
+
/**
|
|
199
|
+
* Transforms the value or calculates a default value using a function.
|
|
200
|
+
* Corresponds to Rust `map_or_else`.
|
|
201
|
+
*/
|
|
202
|
+
declare function mapOrElse<T, E, U>(result: Result<T, E>, defaultFn: (error: E) => U, fn: (value: T) => U): U;
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region src/core/swap.d.ts
|
|
205
|
+
/**
|
|
206
|
+
* Swaps Ok and Err.
|
|
207
|
+
* Result<T, E> → Result<E, T>
|
|
208
|
+
*/
|
|
209
|
+
declare function swap<T, E>(result: Result<T, E>): Result<E, T>;
|
|
210
|
+
//#endregion
|
|
211
|
+
export { tap as C, mapErr as D, mapBoth as E, map as O, filter as S, bimap as T, recoverWith as _, or as a, match as b, tryCatchAsync as c, filterAsync as d, tapAsync as f, recover as g, mapAsync as h, orElse as i, matchAsync as l, mapErrAsync as m, mapOrElse as n, and as o, flatMapAsync as p, mapOr as r, tryMapAsync as s, swap as t, foldAsync as u, tryMap as v, flatMap as w, fold as x, tryCatch as y };
|
|
212
|
+
//# sourceMappingURL=swap-DT4LdRFV.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swap-DT4LdRFV.d.mts","names":[],"sources":["../src/core/map.ts","../src/core/mapErr.ts","../src/core/mapBoth.ts","../src/core/flatMap.ts","../src/core/tap.ts","../src/core/filter.ts","../src/core/fold.ts","../src/core/match.ts","../src/core/tryCatch.ts","../src/core/tryMap.ts","../src/core/recover.ts","../src/core/mapAsync.ts","../src/core/mapErrAsync.ts","../src/core/flatMapAsync.ts","../src/core/tapAsync.ts","../src/core/filterAsync.ts","../src/core/foldAsync.ts","../src/core/matchAsync.ts","../src/core/tryCatchAsync.ts","../src/core/tryMapAsync.ts","../src/core/and.ts","../src/core/or.ts","../src/core/orElse.ts","../src/core/mapOr.ts","../src/core/mapOrElse.ts","../src/core/swap.ts"],"mappings":";;;;;AAQA;;iBAAgB,GAAA,UAAa,OAAA,GAAU,KAAA,EAAO,CAAA,KAAM,CAAA,IACxC,MAAA,EAAQ,MAAA,CAAO,CAAA,EAAG,CAAA,MAAK,MAAA,CAAO,CAAA,EAAG,CAAA;;;;;AAD7C;;iBCAgB,MAAA,UAAgB,OAAA,GAAU,KAAA,EAAO,CAAA,KAAM,CAAA,IAC3C,MAAA,EAAQ,MAAA,CAAO,CAAA,EAAG,CAAA,MAAK,MAAA,CAAO,CAAA,EAAG,CAAA;;;;;ADD7C;;iBEAgB,OAAA,aAAoB,KAAA,GAAQ,KAAA,EAAO,CAAA,KAAM,CAAA,EAAG,MAAA,GAAS,KAAA,EAAO,CAAA,KAAM,CAAA,IACtE,MAAA,EAAQ,MAAA,CAAO,CAAA,EAAG,CAAA,MAAK,MAAA,CAAO,CAAA,EAAG,CAAA;;;;cAchC,KAAA,SAAc,OAAA;;;;;AFf3B;;iBGDgB,OAAA,aAAoB,OAAA,GAAU,KAAA,EAAO,CAAA,KAAM,MAAA,CAAO,CAAA,EAAG,CAAA,KACzD,MAAA,EAAQ,MAAA,CAAO,CAAA,EAAG,CAAA,MAAK,MAAA,CAAO,CAAA,EAAG,CAAA,GAAI,CAAA;;;;;AHAjD;;iBIDgB,GAAA,OAAU,QAAA;EAAY,EAAA,IAAM,GAAA,EAAK,CAAA;EAAY,GAAA,IAAO,CAAA,EAAG,CAAA;AAAA,KAC3D,MAAA,EAAQ,MAAA,CAAO,CAAA,EAAG,CAAA,MAAK,MAAA,CAAO,CAAA,EAAG,CAAA;;;;;AJA7C;;iBKAgB,MAAA,OAAa,SAAA,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AG,CAAA,MAAO,OAAA,CAAQ,MAAA,CAAO,CAAA,EAAG,CAAA,GAAI,CAAA;;;;;AnBHnD;;iBoBDgB,GAAA,UAAa,MAAA,EAAQ,MAAA,CAAO,CAAA,EAAG,CAAA,GAAI,KAAA,EAAO,MAAA,CAAO,CAAA,EAAG,CAAA,IAAK,MAAA,CAAO,CAAA,EAAG,CAAA;;;;;ApBCnF;;iBqBDgB,EAAA,UAAY,MAAA,EAAQ,MAAA,CAAO,CAAA,EAAG,CAAA,GAAI,KAAA,EAAO,MAAA,CAAO,CAAA,EAAG,CAAA,IAAK,MAAA,CAAO,CAAA,EAAG,CAAA;;;;;ArBClF;;iBsBDgB,MAAA,UAAgB,MAAA,EAAQ,MAAA,CAAO,CAAA,EAAG,CAAA,GAAI,EAAA,GAAK,KAAA,EAAO,CAAA,KAAM,MAAA,CAAO,CAAA,EAAG,CAAA,IAAK,MAAA,CAAO,CAAA,EAAG,CAAA;;;;;AtBCjG;;iBuBDgB,KAAA,UAAe,MAAA,EAAQ,MAAA,CAAO,CAAA,EAAG,CAAA,GAAI,YAAA,EAAc,CAAA,EAAG,EAAA,GAAK,KAAA,EAAO,CAAA,KAAM,CAAA,GAAI,CAAA;;;;;AvBC5F;;iBwBDgB,SAAA,UAAmB,MAAA,EAAQ,MAAA,CAAO,CAAA,EAAG,CAAA,GAAI,SAAA,GAAY,KAAA,EAAO,CAAA,KAAM,CAAA,EAAG,EAAA,GAAK,KAAA,EAAO,CAAA,KAAM,CAAA,GAAI,CAAA;;;;;AxBC3G;;iByBAgB,IAAA,OAAW,MAAA,EAAQ,MAAA,CAAO,CAAA,EAAG,CAAA,IAAK,MAAA,CAAO,CAAA,EAAG,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shirudo/result",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Robust, type-safe error handling for TypeScript using the Result pattern (Monad)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -64,13 +64,13 @@
|
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/node": "^25.0.2",
|
|
67
|
-
"@vitest/coverage-v8": "^4.
|
|
67
|
+
"@vitest/coverage-v8": "^4.1.9",
|
|
68
68
|
"fast-check": "^4.8.0",
|
|
69
|
-
"tsdown": "^0.
|
|
70
|
-
"tsx": "^4.
|
|
71
|
-
"typescript": "^
|
|
69
|
+
"tsdown": "^0.22.3",
|
|
70
|
+
"tsx": "^4.22.4",
|
|
71
|
+
"typescript": "^6.0.3",
|
|
72
72
|
"vitepress": "^1.6.4",
|
|
73
|
-
"vitest": "^4.
|
|
73
|
+
"vitest": "^4.1.9"
|
|
74
74
|
},
|
|
75
75
|
"scripts": {
|
|
76
76
|
"typecheck": "tsc --noEmit --emitDeclarationOnly false",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"test": "vitest",
|
|
80
80
|
"test:coverage": "vitest run --coverage --coverage.reporter=text --coverage.reporter=json --coverage.reporter=lcov",
|
|
81
81
|
"test:edge": "node scripts/check-edge-runtime.mjs",
|
|
82
|
-
"check": "pnpm typecheck && pnpm test:types && pnpm test run && pnpm build && pnpm docs:check && pnpm docs:build && pnpm test:edge && pnpm test:exports",
|
|
82
|
+
"check": "pnpm typecheck && node scripts/generate-pipeable.mjs --check && pnpm test:types && pnpm test run && pnpm build && pnpm docs:check && pnpm docs:build && pnpm test:edge && pnpm test:exports",
|
|
83
83
|
"check:clean": "git diff --exit-code && git diff --cached --exit-code",
|
|
84
84
|
"docs:dev": "vitepress dev docs",
|
|
85
85
|
"docs:check": "node scripts/check-docs-examples.mjs",
|
|
@@ -87,6 +87,7 @@
|
|
|
87
87
|
"docs:preview": "vitepress preview docs",
|
|
88
88
|
"prebuild": "pnpm lint && pnpm test:types && pnpm test run",
|
|
89
89
|
"build": "tsdown",
|
|
90
|
-
"test:exports": "node scripts/check-package-exports.mjs"
|
|
90
|
+
"test:exports": "node scripts/check-package-exports.mjs",
|
|
91
|
+
"generate:pipeable": "node scripts/generate-pipeable.mjs"
|
|
91
92
|
}
|
|
92
93
|
}
|
package/dist/errors-2WOswg7r.mjs
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
//#region src/errors.ts
|
|
2
|
-
const ERR_INVALID_RESULT_STATE = "ERR_INVALID_RESULT_STATE";
|
|
3
|
-
const ERR_INVALID_STATE = ERR_INVALID_RESULT_STATE;
|
|
4
|
-
const ERR_TASK_YIELD_NOT_RESULT = "ERR_TASK_YIELD_NOT_RESULT";
|
|
5
|
-
const ERR_MATCH_ON_OK = "ERR_MATCH_ON_OK";
|
|
6
|
-
const ERR_MATCH_ERR_HANDLER_NOT_RESULT = "ERR_MATCH_ERR_HANDLER_NOT_RESULT";
|
|
7
|
-
const ERR_UNWRAP_ON_ERR = "ERR_UNWRAP_ON_ERR";
|
|
8
|
-
const ERR_UNWRAP_ERR_ON_OK = "ERR_UNWRAP_ERR_ON_OK";
|
|
9
|
-
const ERR_EXPECT_OK = "ERR_EXPECT_OK";
|
|
10
|
-
const ERR_EXPECT_ERR = "ERR_EXPECT_ERR";
|
|
11
|
-
const formatResultErrorMessage = (code, message, context) => {
|
|
12
|
-
if (context) return `${code}: ${message} (context: ${context})`;
|
|
13
|
-
return `${code}: ${message}`;
|
|
14
|
-
};
|
|
15
|
-
var ResultError = class extends Error {
|
|
16
|
-
code;
|
|
17
|
-
context;
|
|
18
|
-
constructor(message, code, context) {
|
|
19
|
-
super(formatResultErrorMessage(code, message, context));
|
|
20
|
-
this.code = code;
|
|
21
|
-
this.context = context;
|
|
22
|
-
this.name = new.target.name;
|
|
23
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
var ResultTypeError = class extends TypeError {
|
|
27
|
-
code;
|
|
28
|
-
context;
|
|
29
|
-
constructor(message, code, context) {
|
|
30
|
-
super(formatResultErrorMessage(code, message, context));
|
|
31
|
-
this.code = code;
|
|
32
|
-
this.context = context;
|
|
33
|
-
this.name = new.target.name;
|
|
34
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
const INVALID_RESULT_STATE_MESSAGE = "Unreachable: Result is neither Ok nor Err";
|
|
38
|
-
var InvalidResultStateError = class extends ResultError {
|
|
39
|
-
constructor(context) {
|
|
40
|
-
super(INVALID_RESULT_STATE_MESSAGE, ERR_INVALID_RESULT_STATE, context);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
var TaskYieldNotResultError = class extends ResultTypeError {
|
|
44
|
-
yieldedValue;
|
|
45
|
-
constructor(yieldedValue) {
|
|
46
|
-
super("task() expected yielded values to be Result. Use `yield*` on a Result.", ERR_TASK_YIELD_NOT_RESULT);
|
|
47
|
-
this.yieldedValue = yieldedValue;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
var MatchOnOkError = class extends ResultTypeError {
|
|
51
|
-
constructor(methodName = "match") {
|
|
52
|
-
super(`${methodName}() can only be called on Err results. Use \`if (result.isErr()) { ... }\` first.`, ERR_MATCH_ON_OK);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
var MatchErrHandlerNotResultError = class extends ResultTypeError {
|
|
56
|
-
handlerName;
|
|
57
|
-
returnedValue;
|
|
58
|
-
constructor(handlerName, returnedValue) {
|
|
59
|
-
super(`matchErr().${handlerName}() handlers must return a Result. Wrap values with ok(...) or err(...).`, ERR_MATCH_ERR_HANDLER_NOT_RESULT);
|
|
60
|
-
this.handlerName = handlerName;
|
|
61
|
-
this.returnedValue = returnedValue;
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
var UnwrapOnErrError = class extends ResultTypeError {
|
|
65
|
-
errorValue;
|
|
66
|
-
constructor(errorValue) {
|
|
67
|
-
super(`Called unwrap() on Err: ${String(errorValue)}`, ERR_UNWRAP_ON_ERR);
|
|
68
|
-
this.errorValue = errorValue;
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
var UnwrapErrOnOkError = class extends ResultTypeError {
|
|
72
|
-
okValue;
|
|
73
|
-
constructor(okValue) {
|
|
74
|
-
super(`Called unwrapErr() on Ok: ${String(okValue)}`, ERR_UNWRAP_ERR_ON_OK);
|
|
75
|
-
this.okValue = okValue;
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
var ExpectOkError = class extends ResultError {
|
|
79
|
-
expectedMessage;
|
|
80
|
-
constructor(expectedMessage) {
|
|
81
|
-
super(expectedMessage, ERR_EXPECT_OK);
|
|
82
|
-
this.expectedMessage = expectedMessage;
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
var ExpectErrError = class extends ResultError {
|
|
86
|
-
expectedMessage;
|
|
87
|
-
constructor(expectedMessage) {
|
|
88
|
-
super(expectedMessage, ERR_EXPECT_ERR);
|
|
89
|
-
this.expectedMessage = expectedMessage;
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
//#endregion
|
|
94
|
-
export { TaskYieldNotResultError as _, ERR_MATCH_ERR_HANDLER_NOT_RESULT as a, ERR_UNWRAP_ERR_ON_OK as c, ExpectOkError as d, InvalidResultStateError as f, ResultTypeError as g, ResultError as h, ERR_INVALID_STATE as i, ERR_UNWRAP_ON_ERR as l, MatchOnOkError as m, ERR_EXPECT_OK as n, ERR_MATCH_ON_OK as o, MatchErrHandlerNotResultError as p, ERR_INVALID_RESULT_STATE as r, ERR_TASK_YIELD_NOT_RESULT as s, ERR_EXPECT_ERR as t, ExpectErrError as u, UnwrapErrOnOkError as v, UnwrapOnErrError as y };
|
|
95
|
-
//# sourceMappingURL=errors-2WOswg7r.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors-2WOswg7r.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["export const ERR_INVALID_RESULT_STATE = 'ERR_INVALID_RESULT_STATE' as const;\nexport const ERR_INVALID_STATE = ERR_INVALID_RESULT_STATE;\nexport const ERR_TASK_YIELD_NOT_RESULT = 'ERR_TASK_YIELD_NOT_RESULT' as const;\nexport const ERR_MATCH_ON_OK = 'ERR_MATCH_ON_OK' as const;\nexport const ERR_MATCH_ERR_HANDLER_NOT_RESULT = 'ERR_MATCH_ERR_HANDLER_NOT_RESULT' as const;\nexport const ERR_UNWRAP_ON_ERR = 'ERR_UNWRAP_ON_ERR' as const;\nexport const ERR_UNWRAP_ERR_ON_OK = 'ERR_UNWRAP_ERR_ON_OK' as const;\nexport const ERR_EXPECT_OK = 'ERR_EXPECT_OK' as const;\nexport const ERR_EXPECT_ERR = 'ERR_EXPECT_ERR' as const;\n\nexport type ResultErrorCode =\n | typeof ERR_INVALID_RESULT_STATE\n | typeof ERR_TASK_YIELD_NOT_RESULT\n | typeof ERR_MATCH_ON_OK\n | typeof ERR_MATCH_ERR_HANDLER_NOT_RESULT\n | typeof ERR_UNWRAP_ON_ERR\n | typeof ERR_UNWRAP_ERR_ON_OK\n | typeof ERR_EXPECT_OK\n | typeof ERR_EXPECT_ERR;\n\nconst formatResultErrorMessage = (code: ResultErrorCode, message: string, context?: string): string => {\n if (context) {\n return `${code}: ${message} (context: ${context})`;\n }\n return `${code}: ${message}`;\n};\n\nexport class ResultError extends Error {\n readonly code: ResultErrorCode;\n readonly context?: string;\n\n constructor(message: string, code: ResultErrorCode, context?: string) {\n super(formatResultErrorMessage(code, message, context));\n this.code = code;\n this.context = context;\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nexport class ResultTypeError extends TypeError {\n readonly code: ResultErrorCode;\n readonly context?: string;\n\n constructor(message: string, code: ResultErrorCode, context?: string) {\n super(formatResultErrorMessage(code, message, context));\n this.code = code;\n this.context = context;\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\nconst INVALID_RESULT_STATE_MESSAGE = 'Unreachable: Result is neither Ok nor Err';\n\nexport class InvalidResultStateError extends ResultError {\n constructor(context?: string) {\n super(INVALID_RESULT_STATE_MESSAGE, ERR_INVALID_RESULT_STATE, context);\n }\n}\n\nexport class TaskYieldNotResultError extends ResultTypeError {\n readonly yieldedValue: unknown;\n\n constructor(yieldedValue: unknown) {\n super('task() expected yielded values to be Result. Use `yield*` on a Result.', ERR_TASK_YIELD_NOT_RESULT);\n this.yieldedValue = yieldedValue;\n }\n}\n\nexport class MatchOnOkError extends ResultTypeError {\n constructor(methodName = 'match') {\n super(`${methodName}() can only be called on Err results. Use \\`if (result.isErr()) { ... }\\` first.`, ERR_MATCH_ON_OK);\n }\n}\n\nexport class MatchErrHandlerNotResultError extends ResultTypeError {\n readonly handlerName: string;\n readonly returnedValue: unknown;\n\n constructor(handlerName: string, returnedValue: unknown) {\n super(`matchErr().${handlerName}() handlers must return a Result. Wrap values with ok(...) or err(...).`, ERR_MATCH_ERR_HANDLER_NOT_RESULT);\n this.handlerName = handlerName;\n this.returnedValue = returnedValue;\n }\n}\n\nexport class UnwrapOnErrError extends ResultTypeError {\n readonly errorValue: unknown;\n\n constructor(errorValue: unknown) {\n super(`Called unwrap() on Err: ${String(errorValue)}`, ERR_UNWRAP_ON_ERR);\n this.errorValue = errorValue;\n }\n}\n\nexport class UnwrapErrOnOkError extends ResultTypeError {\n readonly okValue: unknown;\n\n constructor(okValue: unknown) {\n super(`Called unwrapErr() on Ok: ${String(okValue)}`, ERR_UNWRAP_ERR_ON_OK);\n this.okValue = okValue;\n }\n}\n\nexport class ExpectOkError extends ResultError {\n readonly expectedMessage: string;\n\n constructor(expectedMessage: string) {\n super(expectedMessage, ERR_EXPECT_OK);\n this.expectedMessage = expectedMessage;\n }\n}\n\nexport class ExpectErrError extends ResultError {\n readonly expectedMessage: string;\n\n constructor(expectedMessage: string) {\n super(expectedMessage, ERR_EXPECT_ERR);\n this.expectedMessage = expectedMessage;\n }\n}\n"],"mappings":";AAAA,MAAa,2BAA2B;AACxC,MAAa,oBAAoB;AACjC,M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,OAAK,cAAc;AACnB,OAAK,gBAAgB;;;AAI7B,IAAa,mBAAb,cAAsC,gBAAgB;CAClD,AAAS;CAET,YAAY,YAAqB;AAC7B,QAAM,2BAA2B,OAAO,WAAW,IAAI,kBAAkB;AACzE,OAAK,aAAa;;;AAI1B,IAAa,qBAAb,cAAwC,gBAAgB;CACpD,AAAS;CAET,YAAY,SAAkB;AAC1B,QAAM,6BAA6B,OAAO,QAAQ,IAAI,qBAAqB;AAC3E,OAAK,UAAU;;;AAIvB,IAAa,gBAAb,cAAmC,YAAY;CAC3C,AAAS;CAET,YAAY,iBAAyB;AACjC,QAAM,iBAAiB,cAAc;AACrC,OAAK,kBAAkB;;;AAI/B,IAAa,iBAAb,cAAoC,YAAY;CAC5C,AAAS;CAET,YAAY,iBAAyB;AACjC,QAAM,iBAAiB,eAAe;AACtC,OAAK,kBAAkB"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
//#region src/errors.d.ts
|
|
2
|
-
declare const ERR_INVALID_RESULT_STATE: "ERR_INVALID_RESULT_STATE";
|
|
3
|
-
declare const ERR_INVALID_STATE: "ERR_INVALID_RESULT_STATE";
|
|
4
|
-
declare const ERR_TASK_YIELD_NOT_RESULT: "ERR_TASK_YIELD_NOT_RESULT";
|
|
5
|
-
declare const ERR_MATCH_ON_OK: "ERR_MATCH_ON_OK";
|
|
6
|
-
declare const ERR_MATCH_ERR_HANDLER_NOT_RESULT: "ERR_MATCH_ERR_HANDLER_NOT_RESULT";
|
|
7
|
-
declare const ERR_UNWRAP_ON_ERR: "ERR_UNWRAP_ON_ERR";
|
|
8
|
-
declare const ERR_UNWRAP_ERR_ON_OK: "ERR_UNWRAP_ERR_ON_OK";
|
|
9
|
-
declare const ERR_EXPECT_OK: "ERR_EXPECT_OK";
|
|
10
|
-
declare const ERR_EXPECT_ERR: "ERR_EXPECT_ERR";
|
|
11
|
-
type ResultErrorCode = typeof ERR_INVALID_RESULT_STATE | typeof ERR_TASK_YIELD_NOT_RESULT | typeof ERR_MATCH_ON_OK | typeof ERR_MATCH_ERR_HANDLER_NOT_RESULT | typeof ERR_UNWRAP_ON_ERR | typeof ERR_UNWRAP_ERR_ON_OK | typeof ERR_EXPECT_OK | typeof ERR_EXPECT_ERR;
|
|
12
|
-
declare class ResultError extends Error {
|
|
13
|
-
readonly code: ResultErrorCode;
|
|
14
|
-
readonly context?: string;
|
|
15
|
-
constructor(message: string, code: ResultErrorCode, context?: string);
|
|
16
|
-
}
|
|
17
|
-
declare class ResultTypeError extends TypeError {
|
|
18
|
-
readonly code: ResultErrorCode;
|
|
19
|
-
readonly context?: string;
|
|
20
|
-
constructor(message: string, code: ResultErrorCode, context?: string);
|
|
21
|
-
}
|
|
22
|
-
declare class InvalidResultStateError extends ResultError {
|
|
23
|
-
constructor(context?: string);
|
|
24
|
-
}
|
|
25
|
-
declare class TaskYieldNotResultError extends ResultTypeError {
|
|
26
|
-
readonly yieldedValue: unknown;
|
|
27
|
-
constructor(yieldedValue: unknown);
|
|
28
|
-
}
|
|
29
|
-
declare class MatchOnOkError extends ResultTypeError {
|
|
30
|
-
constructor(methodName?: string);
|
|
31
|
-
}
|
|
32
|
-
declare class MatchErrHandlerNotResultError extends ResultTypeError {
|
|
33
|
-
readonly handlerName: string;
|
|
34
|
-
readonly returnedValue: unknown;
|
|
35
|
-
constructor(handlerName: string, returnedValue: unknown);
|
|
36
|
-
}
|
|
37
|
-
declare class UnwrapOnErrError extends ResultTypeError {
|
|
38
|
-
readonly errorValue: unknown;
|
|
39
|
-
constructor(errorValue: unknown);
|
|
40
|
-
}
|
|
41
|
-
declare class UnwrapErrOnOkError extends ResultTypeError {
|
|
42
|
-
readonly okValue: unknown;
|
|
43
|
-
constructor(okValue: unknown);
|
|
44
|
-
}
|
|
45
|
-
declare class ExpectOkError extends ResultError {
|
|
46
|
-
readonly expectedMessage: string;
|
|
47
|
-
constructor(expectedMessage: string);
|
|
48
|
-
}
|
|
49
|
-
declare class ExpectErrError extends ResultError {
|
|
50
|
-
readonly expectedMessage: string;
|
|
51
|
-
constructor(expectedMessage: string);
|
|
52
|
-
}
|
|
53
|
-
//#endregion
|
|
54
|
-
export { ResultTypeError as _, ERR_MATCH_ERR_HANDLER_NOT_RESULT as a, UnwrapOnErrError as b, ERR_UNWRAP_ERR_ON_OK as c, ExpectOkError as d, InvalidResultStateError as f, ResultErrorCode as g, ResultError as h, ERR_INVALID_STATE as i, ERR_UNWRAP_ON_ERR as l, MatchOnOkError as m, ERR_EXPECT_OK as n, ERR_MATCH_ON_OK as o, MatchErrHandlerNotResultError as p, ERR_INVALID_RESULT_STATE as r, ERR_TASK_YIELD_NOT_RESULT as s, ERR_EXPECT_ERR as t, ExpectErrError as u, TaskYieldNotResultError as v, UnwrapErrOnOkError as y };
|
|
55
|
-
//# sourceMappingURL=errors-BFjY06EV.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors-BFjY06EV.d.cts","names":[],"sources":["../src/errors.ts"],"sourcesContent":[],"mappings":";cAAa;AAAA,cACA,iBAD8D,EAAA,0BAAA;AAC9D,cACA,yBAD4C,EAAA,2BAAA;AAC5C,cACA,eADgE,EAAA,iBAAA;AAChE,cACA,gCAD4C,EAAA,kCAAA;AAC5C,cACA,iBADA,EAA8E,mBAAA;AAC9E,cACA,oBADgD,EAAA,sBAAA;AAChD,cACA,aADsD,EAAA,eAAA;AACtD,cACA,cADwC,EAAA,gBAAA;AACxC,KAED,eAAA,GAF2C,OAG1C,wBAH0C,GAAA,OAI1C,yBAJ0C,GAAA,OAK1C,eAL0C,GAAA,OAM1C,gCAN0C,GAAA,OAO1C,iBAP0C,GAAA,OAQ1C,oBAR0C,GAAA,OAS1C,aAT0C,GAAA,OAU1C,cAV0C;AAE3C,cAiBC,WAAA,SAAoB,KAAA,CAjBN;EACd,SAAA,IAAA,EAiBM,eAjBN;EACA,SAAA,OAAA,CAAA,EAAA,MAAA;EACA,WAAA,CAAA,OAAA,EAAA,MAAA,EAAA,IAAA,EAkB0B,eAlB1B,EAAA,OAAA,CAAA,EAAA,MAAA;;AAEA,cAyBA,eAAA,SAAwB,SAAA,CAzBxB;EACA,SAAA,IAAA,EAyBM,eAzBN;EACA,SAAA,OAAA,CAAA,EAAA,MAAA;EACA,WAAA,CAAA,OAAA,EAAA,MAAA,EAAA,IAAA,EA0B0B,eA1B1B,EAAA,OAAA,CAAA,EAAA,MAAA;;AASA,cA4BA,uBAAA,SAAgC,WAAA,CA5BpB;EACN,WAAA,CAAA,OAAA,CAAA,EAAA,MAAA;;AADc,cAkCpB,uBAAA,SAAgC,eAAA,CAlCZ;EAAK,SAAA,YAAA,EAAA,OAAA;EAazB,WAAA,CAAA,YAAgB,EAAA,OAAA;;AAIU,cA0B1B,cAAA,SAAuB,eAAA,CA1BG;EAJF,WAAA,CAAA,UAAA,CAAA,EAAA,MAAA;;AAexB,cAqBA,6BAAA,SAAsC,eAAA,CArBK;EAM3C,SAAA,WAAA,EAAA,MAAwB;EASxB,SAAA,aAAe,EAAA,OAAQ;EAMvB,WAAA,CAAA,WAAA,EAAA,MAAA,EAA8B,aAAQ,EAAA,OAAA;AAWnD;AASa,cATA,gBAAA,SAAyB,eAAA,CASiB;EAS1C,SAAA,UAAc,EAAA,OAAQ;EAStB,WAAA,CAAA,UAAe,EAAA,OAAQ;;cAlBvB,kBAAA,SAA2B,eAAA;;;;cAS3B,aAAA,SAAsB,WAAA;;;;cAStB,cAAA,SAAuB,WAAA"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
//#region src/errors.d.ts
|
|
2
|
-
declare const ERR_INVALID_RESULT_STATE: "ERR_INVALID_RESULT_STATE";
|
|
3
|
-
declare const ERR_INVALID_STATE: "ERR_INVALID_RESULT_STATE";
|
|
4
|
-
declare const ERR_TASK_YIELD_NOT_RESULT: "ERR_TASK_YIELD_NOT_RESULT";
|
|
5
|
-
declare const ERR_MATCH_ON_OK: "ERR_MATCH_ON_OK";
|
|
6
|
-
declare const ERR_MATCH_ERR_HANDLER_NOT_RESULT: "ERR_MATCH_ERR_HANDLER_NOT_RESULT";
|
|
7
|
-
declare const ERR_UNWRAP_ON_ERR: "ERR_UNWRAP_ON_ERR";
|
|
8
|
-
declare const ERR_UNWRAP_ERR_ON_OK: "ERR_UNWRAP_ERR_ON_OK";
|
|
9
|
-
declare const ERR_EXPECT_OK: "ERR_EXPECT_OK";
|
|
10
|
-
declare const ERR_EXPECT_ERR: "ERR_EXPECT_ERR";
|
|
11
|
-
type ResultErrorCode = typeof ERR_INVALID_RESULT_STATE | typeof ERR_TASK_YIELD_NOT_RESULT | typeof ERR_MATCH_ON_OK | typeof ERR_MATCH_ERR_HANDLER_NOT_RESULT | typeof ERR_UNWRAP_ON_ERR | typeof ERR_UNWRAP_ERR_ON_OK | typeof ERR_EXPECT_OK | typeof ERR_EXPECT_ERR;
|
|
12
|
-
declare class ResultError extends Error {
|
|
13
|
-
readonly code: ResultErrorCode;
|
|
14
|
-
readonly context?: string;
|
|
15
|
-
constructor(message: string, code: ResultErrorCode, context?: string);
|
|
16
|
-
}
|
|
17
|
-
declare class ResultTypeError extends TypeError {
|
|
18
|
-
readonly code: ResultErrorCode;
|
|
19
|
-
readonly context?: string;
|
|
20
|
-
constructor(message: string, code: ResultErrorCode, context?: string);
|
|
21
|
-
}
|
|
22
|
-
declare class InvalidResultStateError extends ResultError {
|
|
23
|
-
constructor(context?: string);
|
|
24
|
-
}
|
|
25
|
-
declare class TaskYieldNotResultError extends ResultTypeError {
|
|
26
|
-
readonly yieldedValue: unknown;
|
|
27
|
-
constructor(yieldedValue: unknown);
|
|
28
|
-
}
|
|
29
|
-
declare class MatchOnOkError extends ResultTypeError {
|
|
30
|
-
constructor(methodName?: string);
|
|
31
|
-
}
|
|
32
|
-
declare class MatchErrHandlerNotResultError extends ResultTypeError {
|
|
33
|
-
readonly handlerName: string;
|
|
34
|
-
readonly returnedValue: unknown;
|
|
35
|
-
constructor(handlerName: string, returnedValue: unknown);
|
|
36
|
-
}
|
|
37
|
-
declare class UnwrapOnErrError extends ResultTypeError {
|
|
38
|
-
readonly errorValue: unknown;
|
|
39
|
-
constructor(errorValue: unknown);
|
|
40
|
-
}
|
|
41
|
-
declare class UnwrapErrOnOkError extends ResultTypeError {
|
|
42
|
-
readonly okValue: unknown;
|
|
43
|
-
constructor(okValue: unknown);
|
|
44
|
-
}
|
|
45
|
-
declare class ExpectOkError extends ResultError {
|
|
46
|
-
readonly expectedMessage: string;
|
|
47
|
-
constructor(expectedMessage: string);
|
|
48
|
-
}
|
|
49
|
-
declare class ExpectErrError extends ResultError {
|
|
50
|
-
readonly expectedMessage: string;
|
|
51
|
-
constructor(expectedMessage: string);
|
|
52
|
-
}
|
|
53
|
-
//#endregion
|
|
54
|
-
export { ResultTypeError as _, ERR_MATCH_ERR_HANDLER_NOT_RESULT as a, UnwrapOnErrError as b, ERR_UNWRAP_ERR_ON_OK as c, ExpectOkError as d, InvalidResultStateError as f, ResultErrorCode as g, ResultError as h, ERR_INVALID_STATE as i, ERR_UNWRAP_ON_ERR as l, MatchOnOkError as m, ERR_EXPECT_OK as n, ERR_MATCH_ON_OK as o, MatchErrHandlerNotResultError as p, ERR_INVALID_RESULT_STATE as r, ERR_TASK_YIELD_NOT_RESULT as s, ERR_EXPECT_ERR as t, ExpectErrError as u, TaskYieldNotResultError as v, UnwrapErrOnOkError as y };
|
|
55
|
-
//# sourceMappingURL=errors-C5qGMRiU.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors-C5qGMRiU.d.mts","names":[],"sources":["../src/errors.ts"],"sourcesContent":[],"mappings":";cAAa;AAAA,cACA,iBAD8D,EAAA,0BAAA;AAC9D,cACA,yBAD4C,EAAA,2BAAA;AAC5C,cACA,eADgE,EAAA,iBAAA;AAChE,cACA,gCAD4C,EAAA,kCAAA;AAC5C,cACA,iBADA,EAA8E,mBAAA;AAC9E,cACA,oBADgD,EAAA,sBAAA;AAChD,cACA,aADsD,EAAA,eAAA;AACtD,cACA,cADwC,EAA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