retuple 1.0.0-next.13 → 1.0.0-next.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +301 -203
- package/dist/index.d.cts +254 -509
- package/dist/index.d.ts +254 -509
- package/dist/index.js +299 -199
- package/dist/symbol.cjs +38 -0
- package/dist/symbol.d.cts +36 -0
- package/dist/symbol.d.ts +36 -0
- package/dist/symbol.js +35 -0
- package/package.json +12 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
import { ResultLikeSymbol } from "./symbol.js";
|
|
1
2
|
export type Ok = typeof Ok;
|
|
2
3
|
export type Err = typeof Err;
|
|
3
4
|
export type Result<T, E> = (OkTuple<T> | ErrTuple<E>) & Retuple<T, E>;
|
|
4
|
-
export
|
|
5
|
+
export type ResultLike<T, E> = {
|
|
6
|
+
[ResultLikeSymbol](): Result<T, E>;
|
|
7
|
+
};
|
|
8
|
+
export { type ResultAsync, type ResultRetry };
|
|
9
|
+
export interface ResultRetryController<E> {
|
|
10
|
+
error: E;
|
|
11
|
+
attempt: number;
|
|
12
|
+
abort: () => void;
|
|
13
|
+
}
|
|
5
14
|
/**
|
|
6
15
|
* ## Retuple Unwrap Failed
|
|
7
16
|
*
|
|
@@ -30,16 +39,6 @@ export declare class RetupleExpectFailed<const E = unknown> extends Error {
|
|
|
30
39
|
value: E;
|
|
31
40
|
constructor(value: E);
|
|
32
41
|
}
|
|
33
|
-
/**
|
|
34
|
-
* ## Retuple Expect Failed
|
|
35
|
-
*
|
|
36
|
-
* An error which occurs when calling `$flatten` on `Ok`, when the value
|
|
37
|
-
* contained in the `Ok` is not an `Ok` or `Err`.
|
|
38
|
-
*/
|
|
39
|
-
export declare class RetupleFlattenFailed<const T = unknown> extends Error {
|
|
40
|
-
value: T;
|
|
41
|
-
constructor(value: T);
|
|
42
|
-
}
|
|
43
42
|
/**
|
|
44
43
|
* ## Retuple Thrown Value Error
|
|
45
44
|
*
|
|
@@ -47,21 +46,10 @@ export declare class RetupleFlattenFailed<const T = unknown> extends Error {
|
|
|
47
46
|
* thrown error or rejected value is not an instance of `Error`, and when no
|
|
48
47
|
* map error function is provided.
|
|
49
48
|
*/
|
|
50
|
-
export declare class
|
|
49
|
+
export declare class RetupleCaughtValueError extends Error {
|
|
51
50
|
value: unknown;
|
|
52
51
|
constructor(value: unknown);
|
|
53
52
|
}
|
|
54
|
-
/**
|
|
55
|
-
* ## Retuple Invalid Result Error
|
|
56
|
-
*
|
|
57
|
-
* This error is thrown when attempting to construct a `Result` from a tuple,
|
|
58
|
-
* when neither index 0 or 1 are null or undefined. In this case, it is
|
|
59
|
-
* impossible to determine whether the result should be `Ok` or `Err`.
|
|
60
|
-
*/
|
|
61
|
-
export declare class RetupleInvalidResultError extends Error {
|
|
62
|
-
value: unknown[];
|
|
63
|
-
constructor(value: unknown[]);
|
|
64
|
-
}
|
|
65
53
|
/**
|
|
66
54
|
* ## Retuple Invalid Union Error
|
|
67
55
|
*
|
|
@@ -88,19 +76,38 @@ export declare class RetupleArrayMethodUnavailableError extends Error {
|
|
|
88
76
|
*
|
|
89
77
|
* @TODO
|
|
90
78
|
*/
|
|
91
|
-
export declare function Result<
|
|
79
|
+
export declare function Result<T, E>(resultLike: ResultLike<T, E>): Result<T, E>;
|
|
92
80
|
export declare namespace Result {
|
|
93
|
-
var Ok: typeof import(".").Ok;
|
|
94
|
-
var Err: typeof import(".").Err;
|
|
95
|
-
var $
|
|
96
|
-
var $
|
|
97
|
-
var $
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
var $
|
|
102
|
-
|
|
103
|
-
|
|
81
|
+
var Ok: typeof import("./index.js").Ok;
|
|
82
|
+
var Err: typeof import("./index.js").Err;
|
|
83
|
+
var $from: <T, E>(result: ResultLike<T, E>) => Result<T, E>;
|
|
84
|
+
var $resolve: <T, E>(result: ResultLikeAwaitable<T, E>) => ResultAsync<T, E>;
|
|
85
|
+
var $nonNullable: {
|
|
86
|
+
<const T>(value: T): Result<NonNullable<T>, true>;
|
|
87
|
+
<const T, E>(value: T, error: () => E): Result<NonNullable<T>, E>;
|
|
88
|
+
};
|
|
89
|
+
var $truthy: {
|
|
90
|
+
<const T>(value: T): Result<Truthy<T>, true>;
|
|
91
|
+
<const T, E>(value: T, error: () => E): Result<Truthy<T>, E>;
|
|
92
|
+
};
|
|
93
|
+
var $fromUnion: <U extends ObjectUnionOk<any> | ObjectUnionErr<any>>(union: U) => Result<U extends ObjectUnionOk<infer T> ? T : never, U extends ObjectUnionErr<infer E> ? E : never>;
|
|
94
|
+
var $safe: {
|
|
95
|
+
<T>(f: () => Awaited<T>): Result<T, Error>;
|
|
96
|
+
<T, E>(f: () => Awaited<T>, mapError: (err: unknown) => E): Result<T, E>;
|
|
97
|
+
};
|
|
98
|
+
var $safeAsync: {
|
|
99
|
+
<T>(f: () => T | PromiseLike<T>): ResultAsync<T, Error>;
|
|
100
|
+
<T, E>(f: () => T | PromiseLike<T>, mapError: (err: unknown) => E): ResultAsync<T, E>;
|
|
101
|
+
};
|
|
102
|
+
var $safePromise: {
|
|
103
|
+
<T>(promise: PromiseLike<T>): ResultAsync<T, Error>;
|
|
104
|
+
<T, E>(promise: PromiseLike<T>, mapError: (err: unknown) => E): ResultAsync<T, E>;
|
|
105
|
+
};
|
|
106
|
+
var $retry: <T, E>(f: () => ResultLike<T, E> | PromiseLike<ResultLike<T, E>>) => ResultRetry<T, E>;
|
|
107
|
+
var $safeRetry: {
|
|
108
|
+
<T>(f: () => T | PromiseLike<T>): ResultRetry<T, Error>;
|
|
109
|
+
<T, E>(f: () => T | PromiseLike<T>, mapError: (err: unknown) => E): ResultRetry<T, E>;
|
|
110
|
+
};
|
|
104
111
|
}
|
|
105
112
|
/**
|
|
106
113
|
* Create a new {@link Result} with the `Ok` variant. When called without
|
|
@@ -144,314 +151,6 @@ export declare function Ok<const T>(val: T): Result<T, never>;
|
|
|
144
151
|
*/
|
|
145
152
|
export declare function Err(): Result<never, void>;
|
|
146
153
|
export declare function Err<const E>(err: E): Result<never, E>;
|
|
147
|
-
/**
|
|
148
|
-
* @TODO
|
|
149
|
-
*/
|
|
150
|
-
declare function resolve<T, E>(result: Retuple<T, E> | PromiseLike<Retuple<T, E>>): ResultAsync<T, E>;
|
|
151
|
-
/**
|
|
152
|
-
* Construct a {@link Result} from a value. If the value is neither null or
|
|
153
|
-
* undefined, the result is `Ok`.
|
|
154
|
-
*
|
|
155
|
-
* Otherwise, the result is `Err` containing:
|
|
156
|
-
|
|
157
|
-
* - the returned value from the error function when provided;
|
|
158
|
-
* - or `true` otherwise.
|
|
159
|
-
*
|
|
160
|
-
* @example
|
|
161
|
-
*
|
|
162
|
-
* ```ts
|
|
163
|
-
* const result: Result<User, Error> = Result.$nonNullable(
|
|
164
|
-
* users.find((user) => user.id === currentUserId),
|
|
165
|
-
* () => new Error("User not found"),
|
|
166
|
-
* );
|
|
167
|
-
* ```
|
|
168
|
-
*
|
|
169
|
-
* @example
|
|
170
|
-
*
|
|
171
|
-
* ```ts
|
|
172
|
-
* const [err, value] = Result.$nonNullable("test");
|
|
173
|
-
*
|
|
174
|
-
* assert.equal(err, undefined);
|
|
175
|
-
* assert.equal(value, "test");
|
|
176
|
-
* ```
|
|
177
|
-
*
|
|
178
|
-
* @example
|
|
179
|
-
*
|
|
180
|
-
* ```ts
|
|
181
|
-
* const [err, value] = Result.$nonNullable(null);
|
|
182
|
-
*
|
|
183
|
-
* assert.equal(err, true);
|
|
184
|
-
* assert.equal(value, undefined);
|
|
185
|
-
* ```
|
|
186
|
-
*
|
|
187
|
-
* @example
|
|
188
|
-
*
|
|
189
|
-
* ```ts
|
|
190
|
-
* const [err, value] = Result.$nonNullable(null, () => "error");
|
|
191
|
-
*
|
|
192
|
-
* assert.equal(err, "error");
|
|
193
|
-
* assert.equal(value, undefined);
|
|
194
|
-
* ```
|
|
195
|
-
*/
|
|
196
|
-
declare function nonNullable<const T>(value: T): Result<NonNullable<T>, true>;
|
|
197
|
-
declare function nonNullable<const T, E>(value: T, error: () => E): Result<NonNullable<T>, E>;
|
|
198
|
-
/**
|
|
199
|
-
* Construct a {@link Result} from a value. If the value is truthy, the result
|
|
200
|
-
* is `Ok`.
|
|
201
|
-
*
|
|
202
|
-
* Otherwise, the result is `Err` containing:
|
|
203
|
-
*
|
|
204
|
-
* - the returned value from the error function when provided;
|
|
205
|
-
* - or `true` otherwise.
|
|
206
|
-
*
|
|
207
|
-
* @example
|
|
208
|
-
*
|
|
209
|
-
* ```ts
|
|
210
|
-
* const result: Result<string, Error> = Result.$truthy(
|
|
211
|
-
* username.trim(),
|
|
212
|
-
* () => new Error("Username is empty"),
|
|
213
|
-
* );
|
|
214
|
-
* ```
|
|
215
|
-
*
|
|
216
|
-
* @example
|
|
217
|
-
*
|
|
218
|
-
* ```ts
|
|
219
|
-
* const [err, value] = Result.$truthy("test");
|
|
220
|
-
*
|
|
221
|
-
* assert.equal(err, undefined);
|
|
222
|
-
* assert.equal(value, "test");
|
|
223
|
-
* ```
|
|
224
|
-
*
|
|
225
|
-
* @example
|
|
226
|
-
*
|
|
227
|
-
* ```ts
|
|
228
|
-
* const [err, value] = Result.$truthy("");
|
|
229
|
-
*
|
|
230
|
-
* assert.equal(err, true);
|
|
231
|
-
* assert.equal(value, undefined);
|
|
232
|
-
* ```
|
|
233
|
-
*
|
|
234
|
-
* @example
|
|
235
|
-
*
|
|
236
|
-
* ```ts
|
|
237
|
-
* const [err, value] = Result.$truthy(0, () => "error");
|
|
238
|
-
*
|
|
239
|
-
* assert.equal(err, "error");
|
|
240
|
-
* assert.equal(value, undefined);
|
|
241
|
-
* ```
|
|
242
|
-
*/
|
|
243
|
-
declare function truthy<const T>(value: T): Result<Truthy<T>, true>;
|
|
244
|
-
declare function truthy<const T, E>(value: T, error: () => E): Result<Truthy<T>, E>;
|
|
245
|
-
/**
|
|
246
|
-
* @TODO
|
|
247
|
-
*/
|
|
248
|
-
declare function union<U extends ObjectUnionOk<any> | ObjectUnionErr<any>>(union: U): Result<U extends ObjectUnionOk<infer T> ? T : never, U extends ObjectUnionErr<infer E> ? E : never>;
|
|
249
|
-
/**
|
|
250
|
-
* Construct a {@link Result} from a synchronous function call. If the function
|
|
251
|
-
* returns without throwing, the result is `Ok`.
|
|
252
|
-
*
|
|
253
|
-
* Otherwise, the result is `Err` containing (in priority order):
|
|
254
|
-
*
|
|
255
|
-
* - the returned value from the map error function when provided;
|
|
256
|
-
* - the thrown error when it is an instance of `Error`;
|
|
257
|
-
* - `RetupleThrownValueError` when a non `Error` instance is thrown.
|
|
258
|
-
*
|
|
259
|
-
* @example
|
|
260
|
-
*
|
|
261
|
-
* ```ts
|
|
262
|
-
* const result: Result<URL, Error> = Result.$safe(
|
|
263
|
-
* () => new URL(user.url),
|
|
264
|
-
* () => new Error("Invalid URL"),
|
|
265
|
-
* );
|
|
266
|
-
* ```
|
|
267
|
-
*
|
|
268
|
-
* @example
|
|
269
|
-
*
|
|
270
|
-
* ```ts
|
|
271
|
-
* const [err, value] = Result.$safe(() => "test");
|
|
272
|
-
*
|
|
273
|
-
* assert.equal(err, undefined);
|
|
274
|
-
* assert.equal(value, "test");
|
|
275
|
-
* ```
|
|
276
|
-
*
|
|
277
|
-
* @example
|
|
278
|
-
*
|
|
279
|
-
* ```ts
|
|
280
|
-
* const [err, value] = Result.$safe(
|
|
281
|
-
* () => {
|
|
282
|
-
* throw new Error("throws");
|
|
283
|
-
* },
|
|
284
|
-
* () => "error",
|
|
285
|
-
* );
|
|
286
|
-
*
|
|
287
|
-
* assert.equal(err, "error");
|
|
288
|
-
* assert.equal(value, undefined);
|
|
289
|
-
* ```
|
|
290
|
-
*
|
|
291
|
-
* @example
|
|
292
|
-
*
|
|
293
|
-
* ```ts
|
|
294
|
-
* const [err, value] = Result.$safe(
|
|
295
|
-
* () => {
|
|
296
|
-
* throw new Error("throws")
|
|
297
|
-
* },
|
|
298
|
-
* );
|
|
299
|
-
*
|
|
300
|
-
* assert(err instanceof Error && err.message === "throws");
|
|
301
|
-
* assert.equal(value, undefined);
|
|
302
|
-
* ```
|
|
303
|
-
*
|
|
304
|
-
* @example
|
|
305
|
-
*
|
|
306
|
-
* ```ts
|
|
307
|
-
* const [err, value] = Result.$safe(() => {
|
|
308
|
-
* throw "non error";
|
|
309
|
-
* });
|
|
310
|
-
*
|
|
311
|
-
* assert(err instanceof RetupleThrownValueError && err.value === "non error");
|
|
312
|
-
* assert.equal(value, undefined);
|
|
313
|
-
*/
|
|
314
|
-
declare function safe<T>(f: () => Awaited<T>): Result<T, Error>;
|
|
315
|
-
declare function safe<T, E>(f: () => Awaited<T>, mapError: (err: unknown) => E): Result<T, E>;
|
|
316
|
-
/**
|
|
317
|
-
* Construct a {@link ResultAsync} from a function call. If the function returns
|
|
318
|
-
* without throwing, and any promise returned resolves, the result is `Ok`.
|
|
319
|
-
*
|
|
320
|
-
* Otherwise, the result is `Err` containing (in priority order):
|
|
321
|
-
*
|
|
322
|
-
* - the returned value from the map error function when provided;
|
|
323
|
-
* - the thrown/rejected error when it is an instance of `Error`;
|
|
324
|
-
* - `RetupleThrownValueError` when throwing/rejecting with a non `Error`.
|
|
325
|
-
*
|
|
326
|
-
* @example
|
|
327
|
-
*
|
|
328
|
-
* ```ts
|
|
329
|
-
* const result: Result<Response, Error> = await Result.$safeAsync(
|
|
330
|
-
* () => fetch("http://example.com/api"),
|
|
331
|
-
* () => new Error("Fetch failed"),
|
|
332
|
-
* );
|
|
333
|
-
* ```
|
|
334
|
-
*
|
|
335
|
-
* @example
|
|
336
|
-
*
|
|
337
|
-
* ```ts
|
|
338
|
-
* const [err, value] = await Result.$safeAsync(async () => "test");
|
|
339
|
-
*
|
|
340
|
-
* assert.equal(err, undefined);
|
|
341
|
-
* assert.equal(value, "test");
|
|
342
|
-
* ```
|
|
343
|
-
*
|
|
344
|
-
* @example
|
|
345
|
-
*
|
|
346
|
-
* ```ts
|
|
347
|
-
* const [err, value] = await Result.$safeAsync(
|
|
348
|
-
* async () => {
|
|
349
|
-
* throw new Error("throws");
|
|
350
|
-
* },
|
|
351
|
-
* () => "error",
|
|
352
|
-
* );
|
|
353
|
-
*
|
|
354
|
-
* assert.equal(err, "error");
|
|
355
|
-
* assert.equal(value, undefined);
|
|
356
|
-
* ```
|
|
357
|
-
*
|
|
358
|
-
* @example
|
|
359
|
-
*
|
|
360
|
-
* ```ts
|
|
361
|
-
* const [err, value] = await Result.$safeAsync(
|
|
362
|
-
* async () => {
|
|
363
|
-
* throw new Error("throws")
|
|
364
|
-
* },
|
|
365
|
-
* );
|
|
366
|
-
*
|
|
367
|
-
* assert(err instanceof Error && err.message === "throws");
|
|
368
|
-
* assert.equal(value, undefined);
|
|
369
|
-
* ```
|
|
370
|
-
*
|
|
371
|
-
* @example
|
|
372
|
-
*
|
|
373
|
-
* ```ts
|
|
374
|
-
* const [err, value] = await Result.$safeAsync(async () => {
|
|
375
|
-
* throw "non error";
|
|
376
|
-
* });
|
|
377
|
-
*
|
|
378
|
-
* assert(err instanceof RetupleThrownValueError && err.value === "non error");
|
|
379
|
-
* assert.equal(value, undefined);
|
|
380
|
-
*/
|
|
381
|
-
declare function safeAsync<T>(f: () => T | PromiseLike<T>): ResultAsync<T, Error>;
|
|
382
|
-
declare function safeAsync<T, E>(f: () => T | PromiseLike<T>, mapError: (err: unknown) => E): ResultAsync<T, E>;
|
|
383
|
-
/**
|
|
384
|
-
* Construct a {@link Result} from a promise. If the promise resolves, the
|
|
385
|
-
* result is `Ok`.
|
|
386
|
-
*
|
|
387
|
-
* Otherwise, the result is `Err` containing (in priority order):
|
|
388
|
-
*
|
|
389
|
-
* - the returned value from the map error function when provided;
|
|
390
|
-
* - the rejected error when it is an instance of `Error`;
|
|
391
|
-
* - `RetupleThrownValueError` when rejecting with a non `Error`.
|
|
392
|
-
*
|
|
393
|
-
* @example
|
|
394
|
-
*
|
|
395
|
-
* ```ts
|
|
396
|
-
* const result: Result<Response, Error> = await Result.$safePromise(
|
|
397
|
-
* fetch("http://example.com/api"),
|
|
398
|
-
* () => new Error("Fetch failed"),
|
|
399
|
-
* );
|
|
400
|
-
* ```
|
|
401
|
-
*
|
|
402
|
-
* @example
|
|
403
|
-
*
|
|
404
|
-
* ```ts
|
|
405
|
-
* const [err, value] = await Result.$safePromise(Promise.resolve("test"));
|
|
406
|
-
*
|
|
407
|
-
* assert.equal(err, undefined);
|
|
408
|
-
* assert.equal(value, "test");
|
|
409
|
-
* ```
|
|
410
|
-
*
|
|
411
|
-
* @example
|
|
412
|
-
*
|
|
413
|
-
* ```ts
|
|
414
|
-
* const [err, value] = await Result.$safePromise(
|
|
415
|
-
* Promise.reject(new Error("rejects")),
|
|
416
|
-
* () => "error",
|
|
417
|
-
* );
|
|
418
|
-
*
|
|
419
|
-
* assert.equal(err, "error");
|
|
420
|
-
* assert.equal(value, undefined);
|
|
421
|
-
* ```
|
|
422
|
-
*
|
|
423
|
-
* @example
|
|
424
|
-
*
|
|
425
|
-
* ```ts
|
|
426
|
-
* const [err, value] = await Result.$safePromise(
|
|
427
|
-
* Promise.reject(new Error("rejects")),
|
|
428
|
-
* );
|
|
429
|
-
*
|
|
430
|
-
* assert(err instanceof Error && err.message === "rejects");
|
|
431
|
-
* assert.equal(value, undefined);
|
|
432
|
-
* ```
|
|
433
|
-
*
|
|
434
|
-
* @example
|
|
435
|
-
*
|
|
436
|
-
* ```ts
|
|
437
|
-
* const [err, value] = await Result.$safeAsync(
|
|
438
|
-
* Promise.reject("non error"),
|
|
439
|
-
* );
|
|
440
|
-
*
|
|
441
|
-
* assert(err instanceof RetupleThrownValueError && err.value === "non error");
|
|
442
|
-
* assert.equal(value, undefined);
|
|
443
|
-
*/
|
|
444
|
-
declare function safePromise<T>(promise: PromiseLike<T>): ResultAsync<T, Error>;
|
|
445
|
-
declare function safePromise<T, E>(promise: PromiseLike<T>, mapError: (err: unknown) => E): ResultAsync<T, E>;
|
|
446
|
-
/**
|
|
447
|
-
* @TODO
|
|
448
|
-
*/
|
|
449
|
-
declare function retry<T, E>(f: () => Retuple<T, E> | PromiseLike<Retuple<T, E>>): ResultRetry<T, E>;
|
|
450
|
-
/**
|
|
451
|
-
* @TODO
|
|
452
|
-
*/
|
|
453
|
-
declare function safeRetry<T>(f: () => T | PromiseLike<T>): ResultRetry<T, Error>;
|
|
454
|
-
declare function safeRetry<T, E>(f: () => T | PromiseLike<T>, mapError: (err: unknown) => E): ResultRetry<T, E>;
|
|
455
154
|
/**
|
|
456
155
|
* ## RetupleArray
|
|
457
156
|
*
|
|
@@ -462,8 +161,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
462
161
|
/**
|
|
463
162
|
* ## Method not available
|
|
464
163
|
*
|
|
465
|
-
* Built-in array methods not available on
|
|
466
|
-
* to a tuple using `$tuple()` first.
|
|
164
|
+
* Built-in array methods not available on {@link Result} types.
|
|
467
165
|
*
|
|
468
166
|
* @deprecated
|
|
469
167
|
*/
|
|
@@ -471,8 +169,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
471
169
|
/**
|
|
472
170
|
* ## Method not available
|
|
473
171
|
*
|
|
474
|
-
* Built-in array methods not available on
|
|
475
|
-
* to a tuple using `$tuple()` first.
|
|
172
|
+
* Built-in array methods not available on {@link Result} types.
|
|
476
173
|
*
|
|
477
174
|
* @deprecated
|
|
478
175
|
*/
|
|
@@ -480,8 +177,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
480
177
|
/**
|
|
481
178
|
* ## Method not available
|
|
482
179
|
*
|
|
483
|
-
* Built-in array methods not available on
|
|
484
|
-
* to a tuple using `$tuple()` first.
|
|
180
|
+
* Built-in array methods not available on {@link Result} types.
|
|
485
181
|
*
|
|
486
182
|
* @deprecated
|
|
487
183
|
*/
|
|
@@ -489,8 +185,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
489
185
|
/**
|
|
490
186
|
* ## Method not available
|
|
491
187
|
*
|
|
492
|
-
* Built-in array methods not available on
|
|
493
|
-
* to a tuple using `$tuple()` first.
|
|
188
|
+
* Built-in array methods not available on {@link Result} types.
|
|
494
189
|
*
|
|
495
190
|
* @deprecated
|
|
496
191
|
*/
|
|
@@ -498,8 +193,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
498
193
|
/**
|
|
499
194
|
* ## Method not available
|
|
500
195
|
*
|
|
501
|
-
* Built-in array methods not available on
|
|
502
|
-
* to a tuple using `$tuple()` first.
|
|
196
|
+
* Built-in array methods not available on {@link Result} types.
|
|
503
197
|
*
|
|
504
198
|
* @deprecated
|
|
505
199
|
*/
|
|
@@ -507,8 +201,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
507
201
|
/**
|
|
508
202
|
* ## Method not available
|
|
509
203
|
*
|
|
510
|
-
* Built-in array methods not available on
|
|
511
|
-
* to a tuple using `$tuple()` first.
|
|
204
|
+
* Built-in array methods not available on {@link Result} types.
|
|
512
205
|
*
|
|
513
206
|
* @deprecated
|
|
514
207
|
*/
|
|
@@ -516,8 +209,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
516
209
|
/**
|
|
517
210
|
* ## Method not available
|
|
518
211
|
*
|
|
519
|
-
* Built-in array methods not available on
|
|
520
|
-
* to a tuple using `$tuple()` first.
|
|
212
|
+
* Built-in array methods not available on {@link Result} types.
|
|
521
213
|
*
|
|
522
214
|
* @deprecated
|
|
523
215
|
*/
|
|
@@ -525,8 +217,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
525
217
|
/**
|
|
526
218
|
* ## Method not available
|
|
527
219
|
*
|
|
528
|
-
* Built-in array methods not available on
|
|
529
|
-
* to a tuple using `$tuple()` first.
|
|
220
|
+
* Built-in array methods not available on {@link Result} types.
|
|
530
221
|
*
|
|
531
222
|
* @deprecated
|
|
532
223
|
*/
|
|
@@ -534,8 +225,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
534
225
|
/**
|
|
535
226
|
* ## Method not available
|
|
536
227
|
*
|
|
537
|
-
* Built-in array methods not available on
|
|
538
|
-
* to a tuple using `$tuple()` first.
|
|
228
|
+
* Built-in array methods not available on {@link Result} types.
|
|
539
229
|
*
|
|
540
230
|
* @deprecated
|
|
541
231
|
*/
|
|
@@ -543,8 +233,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
543
233
|
/**
|
|
544
234
|
* ## Method not available
|
|
545
235
|
*
|
|
546
|
-
* Built-in array methods not available on
|
|
547
|
-
* to a tuple using `$tuple()` first.
|
|
236
|
+
* Built-in array methods not available on {@link Result} types.
|
|
548
237
|
*
|
|
549
238
|
* @deprecated
|
|
550
239
|
*/
|
|
@@ -552,8 +241,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
552
241
|
/**
|
|
553
242
|
* ## Method not available
|
|
554
243
|
*
|
|
555
|
-
* Built-in array methods not available on
|
|
556
|
-
* to a tuple using `$tuple()` first.
|
|
244
|
+
* Built-in array methods not available on {@link Result} types.
|
|
557
245
|
*
|
|
558
246
|
* @deprecated
|
|
559
247
|
*/
|
|
@@ -561,8 +249,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
561
249
|
/**
|
|
562
250
|
* ## Method not available
|
|
563
251
|
*
|
|
564
|
-
* Built-in array methods not available on
|
|
565
|
-
* to a tuple using `$tuple()` first.
|
|
252
|
+
* Built-in array methods not available on {@link Result} types.
|
|
566
253
|
*
|
|
567
254
|
* @deprecated
|
|
568
255
|
*/
|
|
@@ -570,8 +257,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
570
257
|
/**
|
|
571
258
|
* ## Method not available
|
|
572
259
|
*
|
|
573
|
-
* Built-in array methods not available on
|
|
574
|
-
* to a tuple using `$tuple()` first.
|
|
260
|
+
* Built-in array methods not available on {@link Result} types.
|
|
575
261
|
*
|
|
576
262
|
* @deprecated
|
|
577
263
|
*/
|
|
@@ -579,8 +265,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
579
265
|
/**
|
|
580
266
|
* ## Method not available
|
|
581
267
|
*
|
|
582
|
-
* Built-in array methods not available on
|
|
583
|
-
* to a tuple using `$tuple()` first.
|
|
268
|
+
* Built-in array methods not available on {@link Result} types.
|
|
584
269
|
*
|
|
585
270
|
* @deprecated
|
|
586
271
|
*/
|
|
@@ -588,8 +273,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
588
273
|
/**
|
|
589
274
|
* ## Method not available
|
|
590
275
|
*
|
|
591
|
-
* Built-in array methods not available on
|
|
592
|
-
* to a tuple using `$tuple()` first.
|
|
276
|
+
* Built-in array methods not available on {@link Result} types.
|
|
593
277
|
*
|
|
594
278
|
* @deprecated
|
|
595
279
|
*/
|
|
@@ -597,8 +281,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
597
281
|
/**
|
|
598
282
|
* ## Method not available
|
|
599
283
|
*
|
|
600
|
-
* Built-in array methods not available on
|
|
601
|
-
* to a tuple using `$tuple()` first.
|
|
284
|
+
* Built-in array methods not available on {@link Result} types.
|
|
602
285
|
*
|
|
603
286
|
* @deprecated
|
|
604
287
|
*/
|
|
@@ -606,8 +289,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
606
289
|
/**
|
|
607
290
|
* ## Method not available
|
|
608
291
|
*
|
|
609
|
-
* Built-in array methods not available on
|
|
610
|
-
* to a tuple using `$tuple()` first.
|
|
292
|
+
* Built-in array methods not available on {@link Result} types.
|
|
611
293
|
*
|
|
612
294
|
* @deprecated
|
|
613
295
|
*/
|
|
@@ -615,8 +297,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
615
297
|
/**
|
|
616
298
|
* ## Method not available
|
|
617
299
|
*
|
|
618
|
-
* Built-in array methods not available on
|
|
619
|
-
* to a tuple using `$tuple()` first.
|
|
300
|
+
* Built-in array methods not available on {@link Result} types.
|
|
620
301
|
*
|
|
621
302
|
* @deprecated
|
|
622
303
|
*/
|
|
@@ -624,8 +305,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
624
305
|
/**
|
|
625
306
|
* ## Method not available
|
|
626
307
|
*
|
|
627
|
-
* Built-in array methods not available on
|
|
628
|
-
* to a tuple using `$tuple()` first.
|
|
308
|
+
* Built-in array methods not available on {@link Result} types.
|
|
629
309
|
*
|
|
630
310
|
* @deprecated
|
|
631
311
|
*/
|
|
@@ -633,8 +313,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
633
313
|
/**
|
|
634
314
|
* ## Method not available
|
|
635
315
|
*
|
|
636
|
-
* Built-in array methods not available on
|
|
637
|
-
* to a tuple using `$tuple()` first.
|
|
316
|
+
* Built-in array methods not available on {@link Result} types.
|
|
638
317
|
*
|
|
639
318
|
* @deprecated
|
|
640
319
|
*/
|
|
@@ -642,8 +321,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
642
321
|
/**
|
|
643
322
|
* ## Method not available
|
|
644
323
|
*
|
|
645
|
-
* Built-in array methods not available on
|
|
646
|
-
* to a tuple using `$tuple()` first.
|
|
324
|
+
* Built-in array methods not available on {@link Result} types.
|
|
647
325
|
*
|
|
648
326
|
* @deprecated
|
|
649
327
|
*/
|
|
@@ -651,8 +329,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
651
329
|
/**
|
|
652
330
|
* ## Method not available
|
|
653
331
|
*
|
|
654
|
-
* Built-in array methods not available on
|
|
655
|
-
* to a tuple using `$tuple()` first.
|
|
332
|
+
* Built-in array methods not available on {@link Result} types.
|
|
656
333
|
*
|
|
657
334
|
* @deprecated
|
|
658
335
|
*/
|
|
@@ -660,8 +337,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
660
337
|
/**
|
|
661
338
|
* ## Method not available
|
|
662
339
|
*
|
|
663
|
-
* Built-in array methods not available on
|
|
664
|
-
* to a tuple using `$tuple()` first.
|
|
340
|
+
* Built-in array methods not available on {@link Result} types.
|
|
665
341
|
*
|
|
666
342
|
* @deprecated
|
|
667
343
|
*/
|
|
@@ -669,8 +345,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
669
345
|
/**
|
|
670
346
|
* ## Method not available
|
|
671
347
|
*
|
|
672
|
-
* Built-in array methods not available on
|
|
673
|
-
* to a tuple using `$tuple()` first.
|
|
348
|
+
* Built-in array methods not available on {@link Result} types.
|
|
674
349
|
*
|
|
675
350
|
* @deprecated
|
|
676
351
|
*/
|
|
@@ -678,8 +353,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
678
353
|
/**
|
|
679
354
|
* ## Method not available
|
|
680
355
|
*
|
|
681
|
-
* Built-in array methods not available on
|
|
682
|
-
* to a tuple using `$tuple()` first.
|
|
356
|
+
* Built-in array methods not available on {@link Result} types.
|
|
683
357
|
*
|
|
684
358
|
* @deprecated
|
|
685
359
|
*/
|
|
@@ -687,8 +361,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
687
361
|
/**
|
|
688
362
|
* ## Method not available
|
|
689
363
|
*
|
|
690
|
-
* Built-in array methods not available on
|
|
691
|
-
* to a tuple using `$tuple()` first.
|
|
364
|
+
* Built-in array methods not available on {@link Result} types.
|
|
692
365
|
*
|
|
693
366
|
* @deprecated
|
|
694
367
|
*/
|
|
@@ -696,8 +369,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
696
369
|
/**
|
|
697
370
|
* ## Method not available
|
|
698
371
|
*
|
|
699
|
-
* Built-in array methods not available on
|
|
700
|
-
* to a tuple using `$tuple()` first.
|
|
372
|
+
* Built-in array methods not available on {@link Result} types.
|
|
701
373
|
*
|
|
702
374
|
* @deprecated
|
|
703
375
|
*/
|
|
@@ -705,8 +377,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
705
377
|
/**
|
|
706
378
|
* ## Method not available
|
|
707
379
|
*
|
|
708
|
-
* Built-in array methods not available on
|
|
709
|
-
* to a tuple using `$tuple()` first.
|
|
380
|
+
* Built-in array methods not available on {@link Result} types.
|
|
710
381
|
*
|
|
711
382
|
* @deprecated
|
|
712
383
|
*/
|
|
@@ -714,8 +385,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
714
385
|
/**
|
|
715
386
|
* ## Method not available
|
|
716
387
|
*
|
|
717
|
-
* Built-in array methods not available on
|
|
718
|
-
* to a tuple using `$tuple()` first.
|
|
388
|
+
* Built-in array methods not available on {@link Result} types.
|
|
719
389
|
*
|
|
720
390
|
* @deprecated
|
|
721
391
|
*/
|
|
@@ -723,8 +393,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
723
393
|
/**
|
|
724
394
|
* ## Method not available
|
|
725
395
|
*
|
|
726
|
-
* Built-in array methods not available on
|
|
727
|
-
* to a tuple using `$tuple()` first.
|
|
396
|
+
* Built-in array methods not available on {@link Result} types.
|
|
728
397
|
*
|
|
729
398
|
* @deprecated
|
|
730
399
|
*/
|
|
@@ -732,8 +401,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
732
401
|
/**
|
|
733
402
|
* ## Method not available
|
|
734
403
|
*
|
|
735
|
-
* Built-in array methods not available on
|
|
736
|
-
* to a tuple using `$tuple()` first.
|
|
404
|
+
* Built-in array methods not available on {@link Result} types.
|
|
737
405
|
*
|
|
738
406
|
* @deprecated
|
|
739
407
|
*/
|
|
@@ -741,8 +409,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
741
409
|
/**
|
|
742
410
|
* ## Method not available
|
|
743
411
|
*
|
|
744
|
-
* Built-in array methods not available on
|
|
745
|
-
* to a tuple using `$tuple()` first.
|
|
412
|
+
* Built-in array methods not available on {@link Result} types.
|
|
746
413
|
*
|
|
747
414
|
* @deprecated
|
|
748
415
|
*/
|
|
@@ -750,8 +417,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
750
417
|
/**
|
|
751
418
|
* ## Method not available
|
|
752
419
|
*
|
|
753
|
-
* Built-in array methods not available on
|
|
754
|
-
* to a tuple using `$tuple()` first.
|
|
420
|
+
* Built-in array methods not available on {@link Result} types.
|
|
755
421
|
*
|
|
756
422
|
* @deprecated
|
|
757
423
|
*/
|
|
@@ -759,8 +425,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
759
425
|
/**
|
|
760
426
|
* ## Method not available
|
|
761
427
|
*
|
|
762
|
-
* Built-in array methods not available on
|
|
763
|
-
* to a tuple using `$tuple()` first.
|
|
428
|
+
* Built-in array methods not available on {@link Result} types.
|
|
764
429
|
*
|
|
765
430
|
* @deprecated
|
|
766
431
|
*/
|
|
@@ -768,8 +433,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
768
433
|
/**
|
|
769
434
|
* ## Method not available
|
|
770
435
|
*
|
|
771
|
-
* Built-in array methods not available on
|
|
772
|
-
* to a tuple using `$tuple()` first.
|
|
436
|
+
* Built-in array methods not available on {@link Result} types.
|
|
773
437
|
*
|
|
774
438
|
* @deprecated
|
|
775
439
|
*/
|
|
@@ -777,8 +441,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
777
441
|
/**
|
|
778
442
|
* ## Method not available
|
|
779
443
|
*
|
|
780
|
-
* Built-in array methods not available on
|
|
781
|
-
* to a tuple using `$tuple()` first.
|
|
444
|
+
* Built-in array methods not available on {@link Result} types.
|
|
782
445
|
*
|
|
783
446
|
* @deprecated
|
|
784
447
|
*/
|
|
@@ -786,8 +449,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
786
449
|
/**
|
|
787
450
|
* ## Method not available
|
|
788
451
|
*
|
|
789
|
-
* Built-in array methods not available on
|
|
790
|
-
* to a tuple using `$tuple()` first.
|
|
452
|
+
* Built-in array methods not available on {@link Result} types.
|
|
791
453
|
*
|
|
792
454
|
* @deprecated
|
|
793
455
|
*/
|
|
@@ -795,8 +457,7 @@ declare class RetupleArray<T> extends Array<T> {
|
|
|
795
457
|
/**
|
|
796
458
|
* ## Method not available
|
|
797
459
|
*
|
|
798
|
-
* Built-in array methods not available on
|
|
799
|
-
* to a tuple using `$tuple()` first.
|
|
460
|
+
* Built-in array methods not available on {@link Result} types.
|
|
800
461
|
*
|
|
801
462
|
* @deprecated
|
|
802
463
|
*/
|
|
@@ -835,65 +496,77 @@ declare class ResultAsync<T, E> {
|
|
|
835
496
|
*/
|
|
836
497
|
$unwrapOrElse<U = T>(this: ResultAsync<T, E>, f: () => U): Promise<T | U>;
|
|
837
498
|
/**
|
|
838
|
-
* The same as {@link Retuple.$map|$map}, except it returns
|
|
499
|
+
* The same as {@link Retuple.$map|$map}, except it returns
|
|
500
|
+
* {@link ResultAsync}.
|
|
839
501
|
*/
|
|
840
502
|
$map<U>(this: ResultAsync<T, E>, f: (val: T) => U): ResultAsync<U, E>;
|
|
841
503
|
/**
|
|
842
504
|
* The same as {@link Retuple.$mapErr|$mapErr}, except it returns
|
|
843
|
-
*
|
|
505
|
+
* {@link ResultAsync}.
|
|
844
506
|
*/
|
|
845
507
|
$mapErr<F = E>(this: ResultAsync<T, E>, f: (err: E) => F): ResultAsync<T, F>;
|
|
846
508
|
/**
|
|
847
|
-
* The same as {@link Retuple.$mapOr|$mapOr}, except it returns
|
|
509
|
+
* The same as {@link Retuple.$mapOr|$mapOr}, except it returns
|
|
510
|
+
* {@link ResultAsync}.
|
|
848
511
|
*/
|
|
849
512
|
$mapOr<U, V = U>(this: ResultAsync<T, E>, def: U, f: (val: T) => V): ResultAsync<U | V, never>;
|
|
850
513
|
/**
|
|
851
514
|
* The same as {@link Retuple.$mapOrElse|$mapOrElse}, except it returns
|
|
852
|
-
*
|
|
515
|
+
* {@link ResultAsync}.
|
|
853
516
|
*/
|
|
854
517
|
$mapOrElse<U, V = U>(this: ResultAsync<T, E>, def: (err: E) => U, f: (val: T) => V): ResultAsync<U | V, never>;
|
|
855
518
|
/**
|
|
856
519
|
* The same as {@link Retuple.$andAssertOr|$andAssertOr}, except it:
|
|
857
520
|
*
|
|
858
521
|
* - can also accept a `PromiseLike` default value;
|
|
859
|
-
* - returns
|
|
522
|
+
* - returns {@link ResultAsync}.
|
|
860
523
|
*/
|
|
861
|
-
$andAssertOr<U = T, F = E>(this: ResultAsync<T, E>, def:
|
|
862
|
-
$andAssertOr<U = T, F = E, A extends T = T>(this: ResultAsync<T, E>, def:
|
|
863
|
-
$andAssertOr<U = T, F = E>(this: ResultAsync<T, E>, def:
|
|
524
|
+
$andAssertOr<U = T, F = E>(this: ResultAsync<T, E>, def: ResultLikeAwaitable<U, F>): ResultAsync<Truthy<T> | U, E | F>;
|
|
525
|
+
$andAssertOr<U = T, F = E, A extends T = T>(this: ResultAsync<T, E>, def: ResultLikeAwaitable<U, F>, predicate: (val: T) => val is A): ResultAsync<U | A, E | F>;
|
|
526
|
+
$andAssertOr<U = T, F = E>(this: ResultAsync<T, E>, def: ResultLikeAwaitable<U, F>, condition: (val: T) => unknown): ResultAsync<T | U, E | F>;
|
|
864
527
|
/**
|
|
865
528
|
* The same as {@link Retuple.$andAssertOrElse|$andAssertOrElse}, except it:
|
|
866
529
|
*
|
|
867
530
|
* - can also accept an `async` default function;
|
|
868
|
-
* - returns
|
|
531
|
+
* - returns {@link ResultAsync}.
|
|
869
532
|
*/
|
|
870
|
-
$andAssertOrElse<U = T, F = E>(this: ResultAsync<T, E>, def: (val: T) =>
|
|
871
|
-
$andAssertOrElse<U = T, F = E, A extends T = T>(this: ResultAsync<T, E>, def: (val: T) =>
|
|
872
|
-
$andAssertOrElse<U = T, F = E>(this: ResultAsync<T, E>, def: (val: T) =>
|
|
533
|
+
$andAssertOrElse<U = T, F = E>(this: ResultAsync<T, E>, def: (val: T) => ResultLikeAwaitable<U, F>): ResultAsync<Truthy<T> | U, E | F>;
|
|
534
|
+
$andAssertOrElse<U = T, F = E, A extends T = T>(this: ResultAsync<T, E>, def: (val: T) => ResultLikeAwaitable<U, F>, predicate: (val: T) => val is A): ResultAsync<U | A, E | F>;
|
|
535
|
+
$andAssertOrElse<U = T, F = E>(this: ResultAsync<T, E>, def: (val: T) => ResultLikeAwaitable<U, F>, condition: (val: T) => unknown): ResultAsync<T | U, E | F>;
|
|
873
536
|
/**
|
|
874
537
|
* The same as {@link Retuple.$or|$or}, except it:
|
|
875
538
|
*
|
|
876
539
|
* - can also accept a `PromiseLike` or value;
|
|
877
|
-
* - returns
|
|
540
|
+
* - returns {@link ResultAsync}.
|
|
878
541
|
*/
|
|
879
|
-
$or<U = T, F = E>(this: ResultAsync<T, E>, or:
|
|
542
|
+
$or<U = T, F = E>(this: ResultAsync<T, E>, or: ResultLikeAwaitable<U, F>): ResultAsync<T | U, F>;
|
|
880
543
|
/**
|
|
881
544
|
* The same as {@link Retuple.$orElse|$orElse}, except it:
|
|
882
545
|
*
|
|
883
546
|
* - can also accept an `async` or function;
|
|
884
|
-
* - returns
|
|
547
|
+
* - returns {@link ResultAsync}.
|
|
885
548
|
*/
|
|
886
|
-
$orElse<U = T, F = E>(this: ResultAsync<T, E>, f: (err: E) =>
|
|
549
|
+
$orElse<U = T, F = E>(this: ResultAsync<T, E>, f: (err: E) => ResultLikeAwaitable<U, F>): ResultAsync<T | U, F>;
|
|
887
550
|
/**
|
|
888
551
|
* The same as {@link Retuple.$orSafe|$orSafe}, except it:
|
|
889
552
|
*
|
|
890
553
|
* - can also accept an `async` safe function;
|
|
891
|
-
* - returns
|
|
554
|
+
* - returns {@link ResultAsync}.
|
|
892
555
|
*/
|
|
893
556
|
$orSafe<U = T>(this: ResultAsync<T, E>, f: (err: E) => U | PromiseLike<U>): ResultAsync<T | U, Error>;
|
|
894
557
|
$orSafe<U = T, F = E>(this: ResultAsync<T, E>, f: (err: E) => U | PromiseLike<U>, mapError: (err: unknown) => F): ResultAsync<T | U, F>;
|
|
895
558
|
/**
|
|
896
|
-
* @
|
|
559
|
+
* Returns {@link ResultAsync} based on the outcome of the promise when this
|
|
560
|
+
* result is `Err`.
|
|
561
|
+
*
|
|
562
|
+
* Otherwise, returns `Ok` containing the current contained value.
|
|
563
|
+
*
|
|
564
|
+
* Uses the same strategy as {@link Result.$safePromise}, equivalent to
|
|
565
|
+
* calling:
|
|
566
|
+
*
|
|
567
|
+
* ```ts
|
|
568
|
+
* resultAsync.$orElse(() => Result.$safePromise(...))
|
|
569
|
+
* ```
|
|
897
570
|
*/
|
|
898
571
|
$orSafePromise<U = T>(this: ResultAsync<T, E>, promise: PromiseLike<U>): ResultAsync<T | U, Error>;
|
|
899
572
|
$orSafePromise<U = T, F = E>(this: ResultAsync<T, E>, promise: PromiseLike<U>, mapError: (err: unknown) => F): ResultAsync<T | U, F>;
|
|
@@ -901,33 +574,43 @@ declare class ResultAsync<T, E> {
|
|
|
901
574
|
* The same as {@link Retuple.$and|$and}, except it:
|
|
902
575
|
*
|
|
903
576
|
* - can also accept a `PromiseLike` and value;
|
|
904
|
-
* - returns
|
|
577
|
+
* - returns {@link ResultAsync}.
|
|
905
578
|
*/
|
|
906
|
-
$and<U = T, F = E>(this: ResultAsync<T, E>, and:
|
|
579
|
+
$and<U = T, F = E>(this: ResultAsync<T, E>, and: ResultLikeAwaitable<U, F>): ResultAsync<U, E | F>;
|
|
907
580
|
/**
|
|
908
581
|
* The same as {@link Retuple.$andThen|$andThen}, except it:
|
|
909
582
|
*
|
|
910
583
|
* - can also accept an `async` and function;
|
|
911
|
-
* - returns
|
|
584
|
+
* - returns {@link ResultAsync}.
|
|
912
585
|
*/
|
|
913
|
-
$andThen<U = T, F = E>(this: ResultAsync<T, E>, f: (val: T) =>
|
|
586
|
+
$andThen<U = T, F = E>(this: ResultAsync<T, E>, f: (val: T) => ResultLikeAwaitable<U, F>): ResultAsync<U, E | F>;
|
|
914
587
|
/**
|
|
915
588
|
* The same as {@link Retuple.$andThrough|$andThrough}, except it:
|
|
916
589
|
*
|
|
917
590
|
* - can also accept an `async` through function;
|
|
918
|
-
* - returns
|
|
591
|
+
* - returns {@link ResultAsync}.
|
|
919
592
|
*/
|
|
920
|
-
$andThrough<F = E>(this: ResultAsync<T, E>, f: (val: T) =>
|
|
593
|
+
$andThrough<F = E>(this: ResultAsync<T, E>, f: (val: T) => ResultLikeAwaitable<any, F>): ResultAsync<T, E | F>;
|
|
921
594
|
/**
|
|
922
595
|
* The same as {@link Retuple.$andSafe|$andSafe}, except it:
|
|
923
596
|
*
|
|
924
597
|
* - can also accept an `async` safe function;
|
|
925
|
-
* - returns
|
|
598
|
+
* - returns {@link ResultAsync}.
|
|
926
599
|
*/
|
|
927
600
|
$andSafe<U = T>(this: ResultAsync<T, E>, f: (val: T) => U | PromiseLike<U>): ResultAsync<U, E | Error>;
|
|
928
601
|
$andSafe<U = T, F = E>(this: ResultAsync<T, E>, f: (val: T) => U | PromiseLike<U>, mapError: (err: unknown) => F): ResultAsync<U, E | F>;
|
|
929
602
|
/**
|
|
930
|
-
* @
|
|
603
|
+
* Returns {@link ResultAsync} based on the outcome of the promise when this
|
|
604
|
+
* result is `Ok`.
|
|
605
|
+
*
|
|
606
|
+
* Otherwise, returns `Err` containing the current error value.
|
|
607
|
+
*
|
|
608
|
+
* Uses the same strategy as {@link Result.$safePromise}, equivalent to
|
|
609
|
+
* calling:
|
|
610
|
+
*
|
|
611
|
+
* ```ts
|
|
612
|
+
* resultAsync.$andThen(() => Result.$safePromise(...))
|
|
613
|
+
* ```
|
|
931
614
|
*/
|
|
932
615
|
$andSafePromise<U = T>(this: ResultAsync<T, E>, promise: PromiseLike<U>): ResultAsync<U, E | Error>;
|
|
933
616
|
$andSafePromise<U = T, F = E>(this: ResultAsync<T, E>, promise: PromiseLike<U>, mapError: (err: unknown) => F): ResultAsync<U, E | F>;
|
|
@@ -935,21 +618,21 @@ declare class ResultAsync<T, E> {
|
|
|
935
618
|
* The same as {@link Retuple.$peek|$peek}, except it:
|
|
936
619
|
*
|
|
937
620
|
* - awaits the peek function;
|
|
938
|
-
* - returns
|
|
621
|
+
* - returns {@link ResultAsync}.
|
|
939
622
|
*/
|
|
940
623
|
$peek(this: ResultAsync<T, E>, f: (res: Result<T, E>) => any): ResultAsync<T, E>;
|
|
941
624
|
/**
|
|
942
625
|
* The same as {@link Retuple.$tap|$tap}, except it:
|
|
943
626
|
*
|
|
944
627
|
* - awaits the tap function;
|
|
945
|
-
* - returns
|
|
628
|
+
* - returns {@link ResultAsync}.
|
|
946
629
|
*/
|
|
947
630
|
$tap(this: ResultAsync<T, E>, f: (val: T) => any): ResultAsync<T, E>;
|
|
948
631
|
/**
|
|
949
632
|
* The same as {@link Retuple.$tapErr|$tapErr}, except it:
|
|
950
633
|
*
|
|
951
634
|
* - awaits the tap error function;
|
|
952
|
-
* - returns
|
|
635
|
+
* - returns {@link ResultAsync}.
|
|
953
636
|
*/
|
|
954
637
|
$tapErr(this: ResultAsync<T, E>, f: (err: E) => any): ResultAsync<T, E>;
|
|
955
638
|
/**
|
|
@@ -957,21 +640,12 @@ declare class ResultAsync<T, E> {
|
|
|
957
640
|
*/
|
|
958
641
|
$promise(this: ResultAsync<T, E>): Promise<Result<T, E>>;
|
|
959
642
|
/**
|
|
960
|
-
* The same as {@link Retuple.$
|
|
961
|
-
*/
|
|
962
|
-
$tuple(this: ResultAsync<T, E>): Promise<[err: E | undefined, value: T | undefined]>;
|
|
963
|
-
/**
|
|
964
|
-
* The same as {@link Retuple.$tuple|$iter}, except it returns a `Promise`.
|
|
643
|
+
* The same as {@link Retuple.$iter|$iter}, except it returns a `Promise`.
|
|
965
644
|
*/
|
|
966
645
|
$iter<U>(this: ResultAsync<Iterable<U>, E>): Promise<IterableIterator<U, undefined, unknown>>;
|
|
967
646
|
}
|
|
968
|
-
interface ResultRetryMonitor<E> {
|
|
969
|
-
error: E;
|
|
970
|
-
attempt: number;
|
|
971
|
-
abort: () => void;
|
|
972
|
-
}
|
|
973
647
|
/**
|
|
974
|
-
*
|
|
648
|
+
* ## ResultRetry
|
|
975
649
|
*/
|
|
976
650
|
declare class ResultRetry<T, E> implements PromiseLike<Result<T, E>> {
|
|
977
651
|
#private;
|
|
@@ -980,28 +654,118 @@ declare class ResultRetry<T, E> implements PromiseLike<Result<T, E>> {
|
|
|
980
654
|
private static zero;
|
|
981
655
|
private static delay;
|
|
982
656
|
private static integer;
|
|
983
|
-
constructor(f: () =>
|
|
984
|
-
then<U = Result<T, E>, F = never>(onfulfilled?: ((value: Result<T, E>) => U | PromiseLike<U>) | null | undefined, onrejected?: ((reason: any) => F | PromiseLike<F>) | null | undefined): PromiseLike<U | F>;
|
|
657
|
+
constructor(f: () => ResultLikeAwaitable<T, E>);
|
|
658
|
+
then<U = Result<T, E>, F = never>(this: ResultRetry<T, E>, onfulfilled?: ((value: Result<T, E>) => U | PromiseLike<U>) | null | undefined, onrejected?: ((reason: any) => F | PromiseLike<F>) | null | undefined): PromiseLike<U | F>;
|
|
985
659
|
/**
|
|
986
|
-
*
|
|
660
|
+
* Sets the maximum number of times the retry function can be executed,
|
|
661
|
+
* mutating this `ResultRetry` instance.
|
|
662
|
+
*
|
|
663
|
+
* **The default value is 1 - meaning that unless set, no retries will be
|
|
664
|
+
* attempted.**
|
|
665
|
+
*
|
|
666
|
+
* The retry function can be called up to the maximum number of times until
|
|
667
|
+
* it returns `Ok`. If it never returns `Ok`, the most recent `Err` is
|
|
668
|
+
* returned.
|
|
669
|
+
*
|
|
670
|
+
* This function accepts a positive integer between 1 and 100:
|
|
671
|
+
*
|
|
672
|
+
* - Integers outside of this range are clamped to the nearest valid value;
|
|
673
|
+
* - Any other value (NaN, Infinity, fractions, strings) are treated as 1.
|
|
674
|
+
*
|
|
675
|
+
* @example
|
|
676
|
+
*
|
|
677
|
+
* ```ts
|
|
678
|
+
* // Retry someResultFn up to 3 times until Ok is returned:
|
|
679
|
+
* const result = await Result.$retry(someResultFn).$times(3);
|
|
680
|
+
* ```
|
|
987
681
|
*/
|
|
988
682
|
$times<N extends number>(this: ResultRetry<T, E>, times: NonZero<N> & NonNegativeOrDecimal<N>): ResultRetry<T, E>;
|
|
989
683
|
/**
|
|
990
|
-
*
|
|
684
|
+
* Sets the delay between each retry attempt, mutating this `ResultRetry`
|
|
685
|
+
* instance.
|
|
686
|
+
*
|
|
687
|
+
* - Provide a number of milliseconds to introduce a static delay between
|
|
688
|
+
* attempts;
|
|
689
|
+
* - Provide a function to compute the delay dynamically for each attempt;
|
|
690
|
+
* - If the maximum number of retries is 1, this setting as no effect.
|
|
691
|
+
*
|
|
692
|
+
* **The default value is 0 - meaning that unless set, there will be no delay
|
|
693
|
+
* between attempts.**
|
|
694
|
+
*
|
|
695
|
+
* This function accepts an integer between 0 and 3600000:
|
|
696
|
+
*
|
|
697
|
+
* - Integers outside of this range are clamped to the nearest valid value;
|
|
698
|
+
* - Any other value (NaN, Infinity, fractions, strings) are treated as 0.
|
|
699
|
+
*
|
|
700
|
+
* @example
|
|
701
|
+
*
|
|
702
|
+
* ```ts
|
|
703
|
+
* // Retry someResultFn up to 3 times until Ok is returned,
|
|
704
|
+
* // with a 1 second delay between each invocation:
|
|
705
|
+
* const result = await Result.$retry(someResultFn).$times(3).$delay(1000);
|
|
706
|
+
* ```
|
|
991
707
|
*/
|
|
992
708
|
$delay<N extends number>(this: ResultRetry<T, E>, f: (attempt: number) => NonNegativeOrDecimal<N>): ResultRetry<T, E>;
|
|
993
709
|
$delay<N extends number>(this: ResultRetry<T, E>, ms: NonNegativeOrDecimal<N>): ResultRetry<T, E>;
|
|
994
710
|
/**
|
|
995
|
-
*
|
|
711
|
+
* Sets a handler to be called when an attempt returns `Err`, mutating this
|
|
712
|
+
* `ResultRetry` instance. The handler can be used to capture information
|
|
713
|
+
* about each failure, and to abort early and prevent further retries.
|
|
714
|
+
*
|
|
715
|
+
* The handler function is called with `ResultRetryHandleState`, containing:
|
|
716
|
+
*
|
|
717
|
+
* - **error** - The error value from the last failed attempt;
|
|
718
|
+
* - **attempt** - The attempt number;
|
|
719
|
+
* - **abort** - A function which when called, prevents further retries.
|
|
720
|
+
*
|
|
721
|
+
* @example
|
|
722
|
+
*
|
|
723
|
+
* ```ts
|
|
724
|
+
* // Retry someResultFn up to 3 times until Ok is returned, logging each
|
|
725
|
+
* // attempt and aborting early if the error code is "UNAUTHORIZED".
|
|
726
|
+
* const result = await Result.$retry(someResultFn)
|
|
727
|
+
* .$times(3)
|
|
728
|
+
* .$handle(({ error, attempt, abort }) => {
|
|
729
|
+
* console.info(`Attempt ${attempt} failed: ${error}`);
|
|
730
|
+
* if (error === "UNAUTHORIZED") {
|
|
731
|
+
* abort();
|
|
732
|
+
* }
|
|
733
|
+
* });
|
|
734
|
+
* ```
|
|
996
735
|
*/
|
|
997
|
-
$
|
|
736
|
+
$handle(f: (controller: ResultRetryController<E>) => void): ResultRetry<T, E>;
|
|
998
737
|
/**
|
|
999
|
-
* @
|
|
738
|
+
* Returns {@link ResultAsync} which resolves to this retried {@link Result}.
|
|
739
|
+
*
|
|
740
|
+
* @example
|
|
741
|
+
*
|
|
742
|
+
* ```ts
|
|
743
|
+
* const result: Result<string, SomeError> = await Result
|
|
744
|
+
* .$retry(someResultFn)
|
|
745
|
+
* .$times(3)
|
|
746
|
+
* .$delay(100)
|
|
747
|
+
* .$async()
|
|
748
|
+
* .$andThen((message) => `Success: ${message}`)
|
|
749
|
+
* .$mapErr((code) => new SomeError({ code }));
|
|
750
|
+
* ```
|
|
1000
751
|
*/
|
|
1001
752
|
$async(this: ResultRetry<T, E>): ResultAsync<T, E>;
|
|
753
|
+
/**
|
|
754
|
+
* Returns a `Promise` which resolves to this retried {@link Result}.
|
|
755
|
+
*
|
|
756
|
+
* @example
|
|
757
|
+
*
|
|
758
|
+
* ```ts
|
|
759
|
+
* const promise: Promise<Result<string, Error>> = Result
|
|
760
|
+
* .$retry(someResultFn)
|
|
761
|
+
* .$times(3)
|
|
762
|
+
* .$promise();
|
|
763
|
+
* ```
|
|
764
|
+
*/
|
|
765
|
+
$promise(this: ResultRetry<T, E>): Promise<Result<T, E>>;
|
|
1002
766
|
private drain;
|
|
1003
767
|
}
|
|
1004
|
-
interface Retuple<T, E> extends RetupleArray<T | E | undefined> {
|
|
768
|
+
interface Retuple<T, E> extends RetupleArray<T | E | undefined>, ResultLike<T, E> {
|
|
1005
769
|
/**
|
|
1006
770
|
* Returns true when this result is `Ok`. Acts as a type guard.
|
|
1007
771
|
*
|
|
@@ -1377,9 +1141,9 @@ interface Retuple<T, E> extends RetupleArray<T | E | undefined> {
|
|
|
1377
1141
|
* assert.equal(asserted.$unwrapErr(), "test");
|
|
1378
1142
|
* ```
|
|
1379
1143
|
*/
|
|
1380
|
-
$andAssertOr<U = T, F = E>(this: Result<T, E>, def:
|
|
1381
|
-
$andAssertOr<U = T, F = E, A extends T = T>(this: Result<T, E>, def:
|
|
1382
|
-
$andAssertOr<U = T, F = E>(this: Result<T, E>, def:
|
|
1144
|
+
$andAssertOr<U = T, F = E>(this: Result<T, E>, def: ResultLike<U, F>): Result<Truthy<T> | U, E | F>;
|
|
1145
|
+
$andAssertOr<U = T, F = E, A extends T = T>(this: Result<T, E>, def: ResultLike<U, F>, predicate: (val: T) => val is A): Result<U | A, E | F>;
|
|
1146
|
+
$andAssertOr<U = T, F = E>(this: Result<T, E>, def: ResultLike<U, F>, condition: (val: T) => unknown): Result<T | U, E | F>;
|
|
1383
1147
|
/**
|
|
1384
1148
|
* Performs an assertion when this result is `Ok`:
|
|
1385
1149
|
*
|
|
@@ -1460,9 +1224,9 @@ interface Retuple<T, E> extends RetupleArray<T | E | undefined> {
|
|
|
1460
1224
|
* assert.equal(asserted.$unwrapErr(), "test");
|
|
1461
1225
|
* ```
|
|
1462
1226
|
*/
|
|
1463
|
-
$andAssertOrElse<U = T, F = E>(this: Result<T, E>, def: (val: T) =>
|
|
1464
|
-
$andAssertOrElse<U = T, F = E, A extends T = T>(this: Result<T, E>, def: (val: T) =>
|
|
1465
|
-
$andAssertOrElse<U = T, F = E>(this: Result<T, E>, def: (val: T) =>
|
|
1227
|
+
$andAssertOrElse<U = T, F = E>(this: Result<T, E>, def: (val: T) => ResultLike<U, F>): Result<Truthy<T> | U, E | F>;
|
|
1228
|
+
$andAssertOrElse<U = T, F = E, A extends T = T>(this: Result<T, E>, def: (val: T) => ResultLike<U, F>, predicate: (val: T) => val is A): Result<U | A, E | F>;
|
|
1229
|
+
$andAssertOrElse<U = T, F = E>(this: Result<T, E>, def: (val: T) => ResultLike<U, F>, condition: (val: T) => unknown): Result<T | U, E | F>;
|
|
1466
1230
|
/**
|
|
1467
1231
|
* Returns `Ok` containing the return value of the map function when this
|
|
1468
1232
|
* result is `Ok`.
|
|
@@ -1613,7 +1377,7 @@ interface Retuple<T, E> extends RetupleArray<T | E | undefined> {
|
|
|
1613
1377
|
* );
|
|
1614
1378
|
* ```
|
|
1615
1379
|
*/
|
|
1616
|
-
$or<U = T, F = E>(this: Result<T, E>, or:
|
|
1380
|
+
$or<U = T, F = E>(this: Result<T, E>, or: ResultLike<U, F>): Result<T | U, F>;
|
|
1617
1381
|
/**
|
|
1618
1382
|
* Returns the result returned by the or function, when this result is `Err`.
|
|
1619
1383
|
*
|
|
@@ -1649,10 +1413,10 @@ interface Retuple<T, E> extends RetupleArray<T | E | undefined> {
|
|
|
1649
1413
|
* );
|
|
1650
1414
|
* ```
|
|
1651
1415
|
*/
|
|
1652
|
-
$orElse<U = T, F = E>(this: Result<T, E>, f: (err: E) =>
|
|
1416
|
+
$orElse<U = T, F = E>(this: Result<T, E>, f: (err: E) => ResultLike<U, F>): Result<T | U, F>;
|
|
1653
1417
|
/**
|
|
1654
|
-
* Returns a
|
|
1655
|
-
* result is `Err`.
|
|
1418
|
+
* Returns a {@link Result} based on the outcome of the safe function when
|
|
1419
|
+
* this result is `Err`.
|
|
1656
1420
|
*
|
|
1657
1421
|
* Otherwise, returns `Ok` containing the current ok value.
|
|
1658
1422
|
*
|
|
@@ -1696,7 +1460,7 @@ interface Retuple<T, E> extends RetupleArray<T | E | undefined> {
|
|
|
1696
1460
|
* );
|
|
1697
1461
|
* ```
|
|
1698
1462
|
*/
|
|
1699
|
-
$and<U = T, F = E>(this: Result<T, E>, and:
|
|
1463
|
+
$and<U = T, F = E>(this: Result<T, E>, and: ResultLike<U, F>): Result<U, E | F>;
|
|
1700
1464
|
/**
|
|
1701
1465
|
* Returns the and result, when this result is `Ok`.
|
|
1702
1466
|
*
|
|
@@ -1732,7 +1496,7 @@ interface Retuple<T, E> extends RetupleArray<T | E | undefined> {
|
|
|
1732
1496
|
* );
|
|
1733
1497
|
* ```
|
|
1734
1498
|
*/
|
|
1735
|
-
$andThen<U = T, F = E>(this: Result<T, E>, f: (val: T) =>
|
|
1499
|
+
$andThen<U = T, F = E>(this: Result<T, E>, f: (val: T) => ResultLike<U, F>): Result<U, E | F>;
|
|
1736
1500
|
/**
|
|
1737
1501
|
* Calls the through function when this result is `Ok` and returns:
|
|
1738
1502
|
*
|
|
@@ -1772,23 +1536,24 @@ interface Retuple<T, E> extends RetupleArray<T | E | undefined> {
|
|
|
1772
1536
|
* );
|
|
1773
1537
|
* ```
|
|
1774
1538
|
*/
|
|
1775
|
-
$andThrough<F = E>(this: Result<T, E>, f: (val: T) =>
|
|
1539
|
+
$andThrough<F = E>(this: Result<T, E>, f: (val: T) => ResultLike<any, F>): Result<T, E | F>;
|
|
1776
1540
|
/**
|
|
1777
1541
|
* Returns a result based on the outcome of the safe function when this
|
|
1778
1542
|
* result is `Ok`.
|
|
1779
1543
|
*
|
|
1780
1544
|
* Otherwise, returns `Err` containing the current error value.
|
|
1781
1545
|
*
|
|
1782
|
-
* Uses the same strategy as {@link Result.$safe}, equivalent to calling
|
|
1783
|
-
*
|
|
1546
|
+
* Uses the same strategy as {@link Result.$safe}, equivalent to calling:
|
|
1547
|
+
*
|
|
1548
|
+
* ```ts
|
|
1549
|
+
* result.$andThen(() => Result.$safe(...))
|
|
1550
|
+
* ```
|
|
1784
1551
|
*/
|
|
1785
1552
|
$andSafe<U = T>(this: Result<T, E>, f: (val: T) => U): Result<U, E | Error>;
|
|
1786
1553
|
$andSafe<U = T, F = E>(this: Result<T, E>, f: (val: T) => U, mapError: (err: unknown) => F): Result<U, E | F>;
|
|
1787
1554
|
/**
|
|
1788
|
-
* @
|
|
1789
|
-
|
|
1790
|
-
/**
|
|
1791
|
-
* Calls the peek function and returns `Result` equivalent to this result.
|
|
1555
|
+
* Calls the peek function and returns {@link Result} equivalent to this
|
|
1556
|
+
* result.
|
|
1792
1557
|
*
|
|
1793
1558
|
* @example
|
|
1794
1559
|
*
|
|
@@ -1884,7 +1649,7 @@ interface Retuple<T, E> extends RetupleArray<T | E | undefined> {
|
|
|
1884
1649
|
*/
|
|
1885
1650
|
$tapErr(this: Result<T, E>, f: (err: E) => void): Result<T, E>;
|
|
1886
1651
|
/**
|
|
1887
|
-
* Returns the contained
|
|
1652
|
+
* Returns the contained {@link Result} when this result is `Ok`.
|
|
1888
1653
|
*
|
|
1889
1654
|
* Otherwise returns `Err` containing the current error value.
|
|
1890
1655
|
*
|
|
@@ -1915,7 +1680,7 @@ interface Retuple<T, E> extends RetupleArray<T | E | undefined> {
|
|
|
1915
1680
|
*/
|
|
1916
1681
|
$flatten<U, F>(this: Result<Result<U, F>, E>): Result<U, E | F>;
|
|
1917
1682
|
/**
|
|
1918
|
-
* Returns an equivalent
|
|
1683
|
+
* Returns an equivalent {@link ResultAsync}.
|
|
1919
1684
|
*
|
|
1920
1685
|
* @example
|
|
1921
1686
|
*
|
|
@@ -1949,24 +1714,6 @@ interface Retuple<T, E> extends RetupleArray<T | E | undefined> {
|
|
|
1949
1714
|
* ```
|
|
1950
1715
|
*/
|
|
1951
1716
|
$promise(this: Result<T, E>): Promise<Result<T, E>>;
|
|
1952
|
-
/**
|
|
1953
|
-
* Returns a two-element, standard array tuple equivalent to this result.
|
|
1954
|
-
*
|
|
1955
|
-
* @example
|
|
1956
|
-
*
|
|
1957
|
-
* ```ts
|
|
1958
|
-
* const result = Ok("test");
|
|
1959
|
-
* assert.deepEqual(result.$tuple(), [undefined, "test"]);
|
|
1960
|
-
* ```
|
|
1961
|
-
*
|
|
1962
|
-
* @example
|
|
1963
|
-
*
|
|
1964
|
-
* ```ts
|
|
1965
|
-
* const result = Err("test");
|
|
1966
|
-
* assert.deepEqual(result.$tuple(), ["test", undefined]);
|
|
1967
|
-
* ```
|
|
1968
|
-
*/
|
|
1969
|
-
$tuple(this: Result<T, E>): [err: E | undefined, value: T | undefined];
|
|
1970
1717
|
/**
|
|
1971
1718
|
* Returns an `IterableIterator` over the contained ok value, when this
|
|
1972
1719
|
* result is `Ok`.
|
|
@@ -2013,9 +1760,7 @@ interface Retuple<T, E> extends RetupleArray<T | E | undefined> {
|
|
|
2013
1760
|
}
|
|
2014
1761
|
type OkTuple<T> = [err: undefined, value: T];
|
|
2015
1762
|
type ErrTuple<E> = [err: E, value: undefined];
|
|
2016
|
-
type
|
|
2017
|
-
type ThisErr<E> = ErrTuple<E> & Retuple<never, E>;
|
|
2018
|
-
type RetupleAwaitable<T, E> = Retuple<T, E> | PromiseLike<Retuple<T, E>>;
|
|
1763
|
+
type ResultLikeAwaitable<T, E> = ResultLike<T, E> | PromiseLike<ResultLike<T, E>>;
|
|
2019
1764
|
type ObjectUnionOk<T> = {
|
|
2020
1765
|
success: true;
|
|
2021
1766
|
data: T;
|