@pvorona/failable 0.2.2 → 0.3.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/README.md +158 -84
- package/dist/index.js +53 -41
- package/dist/lib/failable.d.ts +18 -1
- package/dist/lib/failable.d.ts.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Typed success/failure results for expected failures in TypeScript.
|
|
4
4
|
|
|
5
|
-
`Failable<T, E>` is a discriminated union of `Success<T>` and `Failure<E>`. In
|
|
5
|
+
`Failable<T, E>` is a discriminated union of `Success<T>` and `Failure<E>`. In normal application code, return `success(...)` / `failure(...)`, then branch with `result.isSuccess` / `result.isError`. Keep `isSuccess(...)` / `isFailure(...)` for validating hydrated unknown values, and use `isFailableLike(...)` for plain transport shapes.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -10,11 +10,13 @@ Typed success/failure results for expected failures in TypeScript.
|
|
|
10
10
|
npm i @pvorona/failable
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
This package is ESM-only. Use `import` syntax; the published package declares `Node >=18`.
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
14
16
|
|
|
15
17
|
```ts
|
|
16
18
|
import type { Failable } from '@pvorona/failable';
|
|
17
|
-
import { failure,
|
|
19
|
+
import { failure, success } from '@pvorona/failable';
|
|
18
20
|
|
|
19
21
|
function divide(a: number, b: number): Failable<number, string> {
|
|
20
22
|
if (b === 0) return failure('Cannot divide by zero');
|
|
@@ -24,22 +26,18 @@ function divide(a: number, b: number): Failable<number, string> {
|
|
|
24
26
|
|
|
25
27
|
const result = divide(10, 2);
|
|
26
28
|
|
|
27
|
-
if (
|
|
29
|
+
if (result.isError) {
|
|
28
30
|
console.error(result.error);
|
|
29
31
|
} else {
|
|
30
32
|
console.log(result.data);
|
|
31
33
|
}
|
|
32
34
|
```
|
|
33
35
|
|
|
34
|
-
##
|
|
35
|
-
|
|
36
|
-
### `type Failable<T, E>`
|
|
36
|
+
## Everyday Usage
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
### Return `success(...)` and `failure(...)`
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
Use these when you already know whether you are returning success or failure:
|
|
40
|
+
Use the explicit constructors when your function already knows which branch it should return:
|
|
43
41
|
|
|
44
42
|
```ts
|
|
45
43
|
import { failure, success } from '@pvorona/failable';
|
|
@@ -48,79 +46,165 @@ const ok = success({ id: '1' });
|
|
|
48
46
|
const err = failure({ code: 'bad_request' });
|
|
49
47
|
```
|
|
50
48
|
|
|
51
|
-
###
|
|
49
|
+
### Branch and unwrap with instance methods
|
|
52
50
|
|
|
53
|
-
|
|
51
|
+
Hydrated `Failable` values carry booleans and convenience methods, so everyday code can stay local and direct:
|
|
54
52
|
|
|
55
53
|
```ts
|
|
56
|
-
import { failure,
|
|
54
|
+
import { failure, success } from '@pvorona/failable';
|
|
57
55
|
|
|
58
|
-
const
|
|
56
|
+
const portResult = Math.random() > 0.5
|
|
57
|
+
? success(3000)
|
|
58
|
+
: failure('Missing port');
|
|
59
59
|
|
|
60
|
-
if (
|
|
61
|
-
console.
|
|
60
|
+
if (portResult.isError) {
|
|
61
|
+
console.error(portResult.error);
|
|
62
62
|
} else {
|
|
63
|
-
|
|
63
|
+
const requiredPort = portResult.getOrThrow();
|
|
64
|
+
console.log(requiredPort);
|
|
64
65
|
}
|
|
66
|
+
|
|
67
|
+
const port = portResult.getOr(3000);
|
|
68
|
+
const ensuredPort = portResult.or(3000);
|
|
69
|
+
console.log(port, ensuredPort.data);
|
|
65
70
|
```
|
|
66
71
|
|
|
67
|
-
|
|
72
|
+
- `result.isSuccess` / `result.isError`: branch on a hydrated result
|
|
73
|
+
- `result.getOr(fallback)`: eagerly get the success value or a fallback
|
|
74
|
+
- `result.getOrElse(() => fallback)`: lazily compute a fallback value only on failure
|
|
75
|
+
- `result.or(fallback)`: eagerly end up with `Success<T>`
|
|
76
|
+
- `result.orElse(() => fallback)`: lazily recover to `Success<T>` only on failure
|
|
77
|
+
- `result.match(onSuccess, onFailure)`: map both branches to one output type
|
|
78
|
+
- `result.getOrThrow()`: unwrap success or throw the failure value
|
|
79
|
+
|
|
80
|
+
Use the lazy forms when the fallback is expensive or has side effects:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import { failure, success } from '@pvorona/failable';
|
|
84
|
+
|
|
85
|
+
function readFallbackPort() {
|
|
86
|
+
console.log('Reading fallback port from disk');
|
|
87
|
+
return 3000;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const portResult = Math.random() > 0.5
|
|
91
|
+
? success(8080)
|
|
92
|
+
: failure('Missing port');
|
|
93
|
+
|
|
94
|
+
const eagerPort = portResult.getOr(readFallbackPort());
|
|
95
|
+
const lazyPort = portResult.getOrElse(() => readFallbackPort());
|
|
96
|
+
const ensuredPort = portResult.orElse(() => readFallbackPort());
|
|
97
|
+
|
|
98
|
+
console.log(eagerPort, lazyPort, ensuredPort.data);
|
|
99
|
+
```
|
|
68
100
|
|
|
69
|
-
`
|
|
101
|
+
`readFallbackPort()` runs before `getOr(...)` because the fallback expression is evaluated eagerly. With `getOrElse(...)` and `orElse(...)`, the callback runs only if the result is a failure.
|
|
70
102
|
|
|
71
|
-
|
|
72
|
-
|
|
103
|
+
`match(...)` is often clearer than a fallback when both branches need real handling:
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
import { failure, success } from '@pvorona/failable';
|
|
107
|
+
|
|
108
|
+
const portResult = Math.random() > 0.5
|
|
109
|
+
? success(3000)
|
|
110
|
+
: failure('Missing port');
|
|
111
|
+
|
|
112
|
+
const status = portResult.match(
|
|
113
|
+
(port) => `Listening on ${port}`,
|
|
114
|
+
(error) => `Cannot start server: ${error}`
|
|
115
|
+
);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### `createFailable(...)` for throwy or rejecting code
|
|
119
|
+
|
|
120
|
+
`createFailable(...)` is the convenience entrypoint when you want to capture sync throws, promise rejections, or reuse an existing result shape:
|
|
121
|
+
|
|
122
|
+
- `createFailable(failable)` returns the same tagged hydrated instance
|
|
123
|
+
- `createFailable(failableLike)` rehydrates a strict wire shape into a real `Success` / `Failure`
|
|
73
124
|
- `createFailable(() => value)` captures sync throws into `Failure`
|
|
74
125
|
- `createFailable(promise)` captures promise rejections into `Failure`
|
|
126
|
+
- If a callback returns, or a promise resolves to, a `Failable` or `FailableLike`, `createFailable(...)` preserves that result instead of nesting it inside `Success`
|
|
75
127
|
|
|
76
|
-
|
|
128
|
+
Plain lookalike objects are not treated as hydrated `Failable` instances. If you have plain `{ status, data }` or `{ status, error }` transport data, validate it with `isFailableLike(...)` or pass it to `createFailable(...)` to rehydrate before calling instance methods.
|
|
77
129
|
|
|
78
130
|
```ts
|
|
79
|
-
import {
|
|
131
|
+
import {
|
|
132
|
+
createFailable,
|
|
133
|
+
failure,
|
|
134
|
+
success,
|
|
135
|
+
type Failable,
|
|
136
|
+
} from '@pvorona/failable';
|
|
80
137
|
|
|
81
|
-
|
|
138
|
+
type PortError = {
|
|
139
|
+
readonly code: 'invalid_port';
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
function readPort(value: unknown): Failable<number, PortError> {
|
|
143
|
+
if (typeof value !== 'number') return failure({ code: 'invalid_port' });
|
|
144
|
+
|
|
145
|
+
return success(value);
|
|
146
|
+
}
|
|
82
147
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
console.error(
|
|
148
|
+
const configResult = createFailable(() => JSON.parse(rawConfig));
|
|
149
|
+
|
|
150
|
+
if (configResult.isError) {
|
|
151
|
+
console.error('Invalid JSON:', configResult.error);
|
|
87
152
|
} else {
|
|
88
|
-
const
|
|
89
|
-
const parseResult = createFailable(() => JSON.parse(text));
|
|
153
|
+
const portResult = createFailable(() => readPort(configResult.data.port));
|
|
90
154
|
|
|
91
|
-
if (
|
|
92
|
-
console.error(
|
|
155
|
+
if (portResult.isError) {
|
|
156
|
+
console.error(portResult.error.code);
|
|
93
157
|
} else {
|
|
94
|
-
console.log(
|
|
158
|
+
console.log(portResult.data);
|
|
95
159
|
}
|
|
96
160
|
}
|
|
97
161
|
```
|
|
98
162
|
|
|
99
|
-
|
|
163
|
+
Pass promises directly when you want rejection capture:
|
|
100
164
|
|
|
101
|
-
|
|
165
|
+
```ts
|
|
166
|
+
import { createFailable } from '@pvorona/failable';
|
|
167
|
+
|
|
168
|
+
const responseResult = await createFailable(fetch(url));
|
|
169
|
+
if (responseResult.isError) console.error(responseResult.error);
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Use guards for `unknown` values
|
|
173
|
+
|
|
174
|
+
Use `isFailable(...)`, `isSuccess(...)`, and `isFailure(...)` when you are validating something that might already be a hydrated `Failable` instance:
|
|
175
|
+
|
|
176
|
+
```ts
|
|
177
|
+
import { isFailable } from '@pvorona/failable';
|
|
178
|
+
|
|
179
|
+
const candidate: unknown = maybeFromAnotherModule();
|
|
180
|
+
|
|
181
|
+
if (isFailable(candidate) && candidate.isError) {
|
|
182
|
+
console.error(candidate.error);
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
These guards only recognize tagged hydrated instances created by `success(...)`, `failure(...)`, or `createFailable(...)`. Plain objects that merely look similar are not enough.
|
|
187
|
+
|
|
188
|
+
Use `isSuccess(...)` / `isFailure(...)` when you only care about one branch. If you are validating plain wire data, use `isFailableLike(...)` and then rehydrate with `createFailable(...)` before calling instance methods.
|
|
189
|
+
|
|
190
|
+
## Important Semantics
|
|
191
|
+
|
|
192
|
+
- Hydrated `Failable` values are frozen plain objects with methods. Prefer `result.isSuccess` / `result.isError`, and do not use `instanceof`.
|
|
102
193
|
- `or(...)` and `getOr(...)` are eager. The fallback expression runs before the method call.
|
|
103
|
-
- `
|
|
194
|
+
- `orElse(...)` and `getOrElse(...)` are lazy. The callback runs only on failure.
|
|
195
|
+
- `match(onSuccess, onFailure)` is useful when both branches should converge to the same output type.
|
|
196
|
+
- `isFailable(...)`, `isSuccess(...)`, and `isFailure(...)` recognize only tagged hydrated instances, not public-shape lookalikes.
|
|
197
|
+
- `isFailableLike(...)` remains the validator for transport shapes, and `createFailable(failableLike)` is the supported rehydration path before calling instance methods.
|
|
104
198
|
- By default, `createFailable(...)` preserves raw thrown and rejected values. If something throws `'boom'`, `{ code: 'bad_request' }`, or `[error1, error2]`, that exact value becomes `.error`.
|
|
105
|
-
- `
|
|
106
|
-
|
|
107
|
-
- arrays become `AggregateError`
|
|
108
|
-
- other values become `Error`
|
|
109
|
-
- the original raw value is preserved in `error.cause`
|
|
110
|
-
- `createFailable(input, { normalizeError })` lets you supply your own normalization strategy.
|
|
111
|
-
- The library still uses private runtime tags internally for hydrated instances, but those details are not part of the public API.
|
|
112
|
-
- This package is ESM-only. Use `import` syntax; there is no `require` export condition.
|
|
199
|
+
- `getOrThrow()` throws `result.error` unchanged on failures. If you want `Error` values, opt into normalization.
|
|
200
|
+
- `createFailable(async () => value)` is a footgun. The async function itself is treated as a sync return value, so the result is `Success<Promise<T>>`. If you want rejection capture, pass the promise directly: `await createFailable(somePromise)`.
|
|
113
201
|
|
|
114
|
-
## Normalizing
|
|
202
|
+
## Normalizing Errors
|
|
115
203
|
|
|
116
|
-
If you want `Error`-shaped
|
|
204
|
+
If you want `Error`-shaped failures, opt in explicitly with `NormalizedErrors`:
|
|
117
205
|
|
|
118
206
|
```ts
|
|
119
|
-
import {
|
|
120
|
-
createFailable,
|
|
121
|
-
isFailure,
|
|
122
|
-
NormalizedErrors,
|
|
123
|
-
} from '@pvorona/failable';
|
|
207
|
+
import { createFailable, NormalizedErrors } from '@pvorona/failable';
|
|
124
208
|
|
|
125
209
|
const result = createFailable(
|
|
126
210
|
() => {
|
|
@@ -129,12 +213,21 @@ const result = createFailable(
|
|
|
129
213
|
NormalizedErrors
|
|
130
214
|
);
|
|
131
215
|
|
|
132
|
-
if (
|
|
216
|
+
if (result.isError) {
|
|
133
217
|
console.error(result.error.message);
|
|
134
218
|
console.error(result.error.cause); // { code: 'bad_request' }
|
|
135
219
|
}
|
|
136
220
|
```
|
|
137
221
|
|
|
222
|
+
The same option also normalizes existing `failure(...)` values and rehydrated `FailableLike` failures.
|
|
223
|
+
|
|
224
|
+
Built-in normalization behaves like this:
|
|
225
|
+
|
|
226
|
+
- existing `Error` values pass through unchanged
|
|
227
|
+
- arrays become `AggregateError`
|
|
228
|
+
- other values become `Error`
|
|
229
|
+
- the original raw value is preserved in `error.cause`
|
|
230
|
+
|
|
138
231
|
For custom normalization:
|
|
139
232
|
|
|
140
233
|
```ts
|
|
@@ -149,48 +242,29 @@ const result = createFailable(doThing, {
|
|
|
149
242
|
});
|
|
150
243
|
```
|
|
151
244
|
|
|
152
|
-
##
|
|
245
|
+
## Boundary Transport
|
|
153
246
|
|
|
154
|
-
Hydrated `Failable`
|
|
247
|
+
Hydrated `Failable` values do not survive structured cloning because they carry methods and runtime details. If you need to cross a message boundary, convert to a plain shape first and rehydrate on the receiving side:
|
|
155
248
|
|
|
156
249
|
```ts
|
|
157
250
|
import { createFailable, toFailableLike } from '@pvorona/failable';
|
|
158
251
|
|
|
159
|
-
const result = createFailable(() => JSON.parse('{"ok":true}'));
|
|
160
|
-
|
|
161
|
-
// sender
|
|
162
252
|
const wire = toFailableLike(result);
|
|
163
|
-
postMessage(wire);
|
|
164
|
-
|
|
165
|
-
// receiver
|
|
166
253
|
const hydrated = createFailable(wire);
|
|
167
254
|
```
|
|
168
255
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
- `FailableLikeSuccess<T>`: `{ status: FailableStatus.Success, data: T }`
|
|
172
|
-
- `FailableLikeFailure<E>`: `{ status: FailableStatus.Failure, error: E }`
|
|
173
|
-
|
|
174
|
-
`FailableStatus` is a runtime object:
|
|
175
|
-
|
|
176
|
-
```ts
|
|
177
|
-
import { FailableStatus, type FailableLike } from '@pvorona/failable';
|
|
178
|
-
|
|
179
|
-
const wire: FailableLike<number, string> = {
|
|
180
|
-
status: FailableStatus.Success,
|
|
181
|
-
data: 1,
|
|
182
|
-
};
|
|
183
|
-
```
|
|
256
|
+
`isFailableLike(...)` validates the strict wire shape `{ status, data }` or `{ status, error }`, and the inner `data` / `error` values must still be structured-cloneable.
|
|
184
257
|
|
|
185
|
-
## API
|
|
258
|
+
## API At A Glance
|
|
186
259
|
|
|
187
260
|
- `type Failable<T, E>`: `Success<T> | Failure<E>`
|
|
188
|
-
- `type Success<T>`: success variant with `data`, `or(...)`, `getOr(...)`, and `getOrThrow()`
|
|
189
|
-
- `type Failure<E>`: failure variant with `error`, `or(...)`, `getOr(...)`, and `getOrThrow()`
|
|
190
|
-
- `
|
|
261
|
+
- `type Success<T>`: success variant with `isSuccess`, `data`, `or(...)`, `orElse(...)`, `getOr(...)`, `getOrElse(...)`, `match(...)`, and `getOrThrow()`
|
|
262
|
+
- `type Failure<E>`: failure variant with `isError`, `error`, `or(...)`, `orElse(...)`, `getOr(...)`, `getOrElse(...)`, `match(...)`, and `getOrThrow()`
|
|
263
|
+
- `type FailableLike<T, E>`: strict structured-clone-friendly wire shape
|
|
191
264
|
- `const NormalizedErrors`: built-in token for `Error` normalization
|
|
192
265
|
- `success(data)` / `failure(error)`: explicit constructors
|
|
193
|
-
- `
|
|
194
|
-
- `
|
|
195
|
-
- `
|
|
196
|
-
- `
|
|
266
|
+
- `createFailable(...)`: wrap, preserve, rehydrate, or normalize results
|
|
267
|
+
- `isFailable(...)`, `isSuccess(...)`, `isFailure(...)`: runtime validators for tagged hydrated values
|
|
268
|
+
- `toFailableLike(...)`: convert a hydrated result into a plain transport shape
|
|
269
|
+
- `isFailableLike(...)`: validate the strict wire shape
|
|
270
|
+
- `const FailableStatus`: runtime `{ Success, Failure }` object for wire values
|
package/dist/index.js
CHANGED
|
@@ -1,106 +1,118 @@
|
|
|
1
|
-
import { isFunction as
|
|
2
|
-
import { notImplemented as
|
|
3
|
-
const h = /* @__PURE__ */ Symbol("Failable"),
|
|
1
|
+
import { isFunction as S, isObject as o, hasOwnPropertyValue as F, hasOwnKey as b } from "@pvorona/assert";
|
|
2
|
+
import { notImplemented as u } from "@pvorona/not-implemented";
|
|
3
|
+
const h = /* @__PURE__ */ Symbol("Failable"), g = /* @__PURE__ */ Symbol("Success"), O = /* @__PURE__ */ Symbol("Failure"), n = Object.freeze({
|
|
4
4
|
Success: "success",
|
|
5
5
|
Failure: "failure"
|
|
6
6
|
}), j = Object.freeze({
|
|
7
7
|
mode: "normalized-errors"
|
|
8
8
|
});
|
|
9
9
|
function A(r) {
|
|
10
|
-
return
|
|
10
|
+
return o(r) && Object.keys(r).length === 2 && F(r, "status", n.Success) && b(r, "data");
|
|
11
11
|
}
|
|
12
12
|
function w(r) {
|
|
13
|
-
return
|
|
13
|
+
return o(r) && Object.keys(r).length === 2 && F(r, "status", n.Failure) && b(r, "error");
|
|
14
14
|
}
|
|
15
15
|
function a(r) {
|
|
16
16
|
return w(r) || A(r);
|
|
17
17
|
}
|
|
18
|
-
const
|
|
18
|
+
const m = {
|
|
19
19
|
[h]: !0,
|
|
20
20
|
isSuccess: !1,
|
|
21
21
|
isError: !1,
|
|
22
22
|
data: null,
|
|
23
23
|
error: null,
|
|
24
|
-
or:
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
or: u,
|
|
25
|
+
orElse: u,
|
|
26
|
+
getOr: u,
|
|
27
|
+
getOrElse: u,
|
|
28
|
+
getOrThrow: u,
|
|
29
|
+
match: u
|
|
27
30
|
}, y = (() => {
|
|
28
|
-
const r = Object.create(
|
|
29
|
-
return r[
|
|
31
|
+
const r = Object.create(m);
|
|
32
|
+
return r[g] = !0, r.status = n.Success, r.isSuccess = !0, r.or = function() {
|
|
33
|
+
return this;
|
|
34
|
+
}, r.orElse = function() {
|
|
30
35
|
return this;
|
|
31
36
|
}, r.getOr = function() {
|
|
32
37
|
return this.data;
|
|
38
|
+
}, r.getOrElse = function() {
|
|
39
|
+
return this.data;
|
|
33
40
|
}, r.getOrThrow = function() {
|
|
34
41
|
return this.data;
|
|
42
|
+
}, r.match = function(t) {
|
|
43
|
+
return t(this.data);
|
|
35
44
|
}, Object.freeze(r);
|
|
36
|
-
})(),
|
|
37
|
-
const r = Object.create(
|
|
38
|
-
return r[
|
|
45
|
+
})(), L = (() => {
|
|
46
|
+
const r = Object.create(m);
|
|
47
|
+
return r[O] = !0, r.status = n.Failure, r.isError = !0, r.or = function(t) {
|
|
39
48
|
return c(t);
|
|
49
|
+
}, r.orElse = function(t) {
|
|
50
|
+
return c(t());
|
|
40
51
|
}, r.getOr = function(t) {
|
|
41
52
|
return t;
|
|
53
|
+
}, r.getOrElse = function(t) {
|
|
54
|
+
return t();
|
|
42
55
|
}, r.getOrThrow = function() {
|
|
43
56
|
throw this.error;
|
|
57
|
+
}, r.match = function(t, d) {
|
|
58
|
+
return d(this.error);
|
|
44
59
|
}, Object.freeze(r);
|
|
45
60
|
})();
|
|
46
|
-
function
|
|
47
|
-
return
|
|
48
|
-
}
|
|
49
|
-
function g(r) {
|
|
50
|
-
return !(!i(r) || r.status !== n.Failure || r.isSuccess !== !1 || r.isError !== !0 || !("error" in r) || r.data !== null || !s(r.or) || !s(r.getOr) || !s(r.getOrThrow));
|
|
61
|
+
function f(r, e) {
|
|
62
|
+
return o(r) ? r[e] === !0 : !1;
|
|
51
63
|
}
|
|
52
64
|
function l(r) {
|
|
53
|
-
return
|
|
65
|
+
return f(r, h);
|
|
54
66
|
}
|
|
55
67
|
function U(r) {
|
|
56
|
-
return
|
|
68
|
+
return f(r, g);
|
|
57
69
|
}
|
|
58
70
|
function N(r) {
|
|
59
|
-
return
|
|
71
|
+
return f(r, O);
|
|
60
72
|
}
|
|
61
73
|
function c(r) {
|
|
62
74
|
const e = Object.create(y);
|
|
63
75
|
return e.data = r, Object.freeze(e);
|
|
64
76
|
}
|
|
65
|
-
function
|
|
66
|
-
const e = Object.create(
|
|
77
|
+
function i(r) {
|
|
78
|
+
const e = Object.create(L);
|
|
67
79
|
return e.error = r, Object.freeze(e);
|
|
68
80
|
}
|
|
69
81
|
function G(r) {
|
|
70
82
|
return r.status === n.Failure ? { status: n.Failure, error: r.error } : { status: n.Success, data: r.data };
|
|
71
83
|
}
|
|
72
84
|
function R(r, e) {
|
|
73
|
-
return l(r) ?
|
|
85
|
+
return l(r) ? s(r, e) : a(r) ? s(E(r), e) : S(r) ? T(r, e) : k(r, e);
|
|
74
86
|
}
|
|
75
|
-
function
|
|
76
|
-
return r.status === n.Success ? c(r.data) :
|
|
87
|
+
function E(r) {
|
|
88
|
+
return r.status === n.Success ? c(r.data) : i(r.error);
|
|
77
89
|
}
|
|
78
|
-
function
|
|
90
|
+
function T(r, e) {
|
|
79
91
|
try {
|
|
80
92
|
const t = r();
|
|
81
|
-
return l(t) ?
|
|
93
|
+
return l(t) ? s(t, e) : a(t) ? s(E(t), e) : c(t);
|
|
82
94
|
} catch (t) {
|
|
83
|
-
return
|
|
95
|
+
return s(i(t), e);
|
|
84
96
|
}
|
|
85
97
|
}
|
|
86
98
|
function k(r, e) {
|
|
87
99
|
return Promise.resolve(r).then(
|
|
88
|
-
(t) => l(t) ?
|
|
89
|
-
(t) =>
|
|
100
|
+
(t) => l(t) ? s(t, e) : a(t) ? s(E(t), e) : c(t),
|
|
101
|
+
(t) => s(i(t), e)
|
|
90
102
|
);
|
|
91
103
|
}
|
|
92
|
-
function
|
|
93
|
-
const t =
|
|
94
|
-
return t === null || r.status === n.Success || r.error instanceof Error ? r :
|
|
104
|
+
function s(r, e) {
|
|
105
|
+
const t = _(e);
|
|
106
|
+
return t === null || r.status === n.Success || r.error instanceof Error ? r : i(t(r.error));
|
|
95
107
|
}
|
|
96
|
-
function
|
|
97
|
-
return r === void 0 ? null : z(r) ? B :
|
|
108
|
+
function _(r) {
|
|
109
|
+
return r === void 0 ? null : z(r) ? B : I(r) ? r.normalizeError : null;
|
|
98
110
|
}
|
|
99
111
|
function z(r) {
|
|
100
|
-
return !
|
|
112
|
+
return !o(r) || Object.keys(r).length !== 1 ? !1 : Object.getOwnPropertyDescriptor(r, "mode")?.value === j.mode;
|
|
101
113
|
}
|
|
102
|
-
function
|
|
103
|
-
return
|
|
114
|
+
function I(r) {
|
|
115
|
+
return o(r) ? S(r.normalizeError) : !1;
|
|
104
116
|
}
|
|
105
117
|
function B(r) {
|
|
106
118
|
return r instanceof Error ? r : Array.isArray(r) ? new AggregateError(r, "Multiple errors", { cause: r }) : new Error(String(r), { cause: r });
|
|
@@ -109,7 +121,7 @@ export {
|
|
|
109
121
|
n as FailableStatus,
|
|
110
122
|
j as NormalizedErrors,
|
|
111
123
|
R as createFailable,
|
|
112
|
-
|
|
124
|
+
i as failure,
|
|
113
125
|
l as isFailable,
|
|
114
126
|
a as isFailableLike,
|
|
115
127
|
N as isFailure,
|
package/dist/lib/failable.d.ts
CHANGED
|
@@ -10,7 +10,12 @@ export type CreateFailableNormalizeErrorOptions = {
|
|
|
10
10
|
readonly normalizeError: (error: unknown) => Error;
|
|
11
11
|
};
|
|
12
12
|
type CreateFailableNormalizeErrorInput = typeof NormalizedErrors | CreateFailableNormalizeErrorOptions;
|
|
13
|
-
|
|
13
|
+
type Match<T, E> = <U>(onSuccess: (data: T) => U, onFailure: (error: E) => U) => U;
|
|
14
|
+
export type Failable<T, E> = (Success<T> & {
|
|
15
|
+
readonly match: Match<T, E>;
|
|
16
|
+
}) | (Failure<E> & {
|
|
17
|
+
readonly match: Match<T, E>;
|
|
18
|
+
});
|
|
14
19
|
/**
|
|
15
20
|
* Structured-clone-friendly representation of {@link Failable}.
|
|
16
21
|
*
|
|
@@ -35,6 +40,12 @@ export type FailableLikeFailure<E> = {
|
|
|
35
40
|
readonly status: typeof FailableStatus.Failure;
|
|
36
41
|
readonly error: E;
|
|
37
42
|
};
|
|
43
|
+
type SuccessMatch<T> = {
|
|
44
|
+
<U, E>(onSuccess: (data: T) => U, onFailure: (error: E) => U): U;
|
|
45
|
+
};
|
|
46
|
+
type FailureMatch<E> = {
|
|
47
|
+
<U, T>(onSuccess: (data: T) => U, onFailure: (error: E) => U): U;
|
|
48
|
+
};
|
|
38
49
|
export declare function isFailableLike(value: unknown): value is FailableLike<unknown, unknown>;
|
|
39
50
|
export type Success<T> = {
|
|
40
51
|
readonly status: typeof FailableStatus.Success;
|
|
@@ -43,8 +54,11 @@ export type Success<T> = {
|
|
|
43
54
|
readonly data: T;
|
|
44
55
|
readonly error: null;
|
|
45
56
|
readonly or: <U>(value: U) => Success<T>;
|
|
57
|
+
readonly orElse: <U>(getValue: () => U) => Success<T>;
|
|
46
58
|
readonly getOr: <U>(value: U) => T;
|
|
59
|
+
readonly getOrElse: <U>(getValue: () => U) => T;
|
|
47
60
|
readonly getOrThrow: () => T;
|
|
61
|
+
readonly match: SuccessMatch<T>;
|
|
48
62
|
};
|
|
49
63
|
export type Failure<E> = {
|
|
50
64
|
readonly status: typeof FailableStatus.Failure;
|
|
@@ -53,8 +67,11 @@ export type Failure<E> = {
|
|
|
53
67
|
readonly error: E;
|
|
54
68
|
readonly data: null;
|
|
55
69
|
readonly or: <U>(value: U) => Success<U>;
|
|
70
|
+
readonly orElse: <U>(getValue: () => U) => Success<U>;
|
|
56
71
|
readonly getOr: <U>(value: U) => U;
|
|
72
|
+
readonly getOrElse: <U>(getValue: () => U) => U;
|
|
57
73
|
readonly getOrThrow: () => never;
|
|
74
|
+
readonly match: FailureMatch<E>;
|
|
58
75
|
};
|
|
59
76
|
export declare function isFailable(value: unknown): value is Failable<unknown, unknown>;
|
|
60
77
|
export declare function isSuccess(value: unknown): value is Success<unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"failable.d.ts","sourceRoot":"","sources":["../../src/lib/failable.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,cAAc;;;EAGhB,CAAC;AAEZ,MAAM,MAAM,cAAc,GACxB,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAEvD,eAAO,MAAM,gBAAgB;;EAElB,CAAC;AAE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,CAAC,EAAE,CAAC,EACjC,KAAK,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,EACzB,eAAe,EAAE,iCAAiC,GACjD,QAAQ,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AACtB,wBAAgB,cAAc,CAC5B,CAAC,SAAS,MAAM,CAAC,EACjB,CAAC,GAAG,OAAO,EACX,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,EACjB,GAAG,EAAE,CAAC,GAAG,2BAA2B,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAChD,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,EACjE,GAAG,EAAE,CAAC,EACN,eAAe,EAAE,iCAAiC,GACjD,6BAA6B,CAAC,CAAC,CAAC,CAAC;AACpC,wBAAgB,cAAc,CAC5B,CAAC,EACD,CAAC,GAAG,OAAO,EACX,CAAC,SAAS,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,EACzC,OAAO,EAAE,CAAC,GAAG,0BAA0B,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACnD,wBAAgB,cAAc,CAAC,CAAC,EAAE,CAAC,SAAS,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,EACzE,OAAO,EAAE,CAAC,EACV,eAAe,EAAE,iCAAiC,GACjD,OAAO,CAAC,6BAA6B,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pvorona/failable",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Typed success/failure results for expected failures in TypeScript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"failable",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@pvorona/assert": "~0.1.0",
|
|
41
|
-
"@pvorona/not-implemented": "~0.0.1"
|
|
41
|
+
"@pvorona/not-implemented": "~0.0.1",
|
|
42
|
+
"@pvorona/types": "^0.0.0"
|
|
42
43
|
}
|
|
43
44
|
}
|