retuple 1.0.0-next.3 → 1.0.0-next.5
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 +22 -4
- package/dist/index.d.cts +15 -3
- package/dist/index.d.ts +15 -3
- package/dist/index.js +22 -4
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -75,13 +75,13 @@ exports.RetupleThrownValueError = RetupleThrownValueError;
|
|
|
75
75
|
/**
|
|
76
76
|
* ## Retuple Invalid Result Error
|
|
77
77
|
*
|
|
78
|
-
* An error
|
|
79
|
-
*
|
|
80
|
-
*
|
|
78
|
+
* An error thrown when attempting to construct a `Result` from a native tuple,
|
|
79
|
+
* when neither index 0 or 1 are null or undefined. In this case, it is impossible
|
|
80
|
+
* to determine whether the result should be `Ok` or `Err`.
|
|
81
81
|
*/
|
|
82
82
|
class RetupleInvalidResultError extends Error {
|
|
83
83
|
constructor(value) {
|
|
84
|
-
super("Constructing a Result from tuple failed, at least one of the values at index 0 or 1 should be undefined");
|
|
84
|
+
super("Constructing a Result from native tuple failed, at least one of the values at index 0 or 1 should be null or undefined");
|
|
85
85
|
this.value = value;
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -168,6 +168,9 @@ class ResultOk extends Array {
|
|
|
168
168
|
$value() {
|
|
169
169
|
return this[1];
|
|
170
170
|
}
|
|
171
|
+
$ok() {
|
|
172
|
+
return this[1];
|
|
173
|
+
}
|
|
171
174
|
$isOk() {
|
|
172
175
|
return true;
|
|
173
176
|
}
|
|
@@ -281,6 +284,9 @@ class ResultErr extends Array {
|
|
|
281
284
|
$value() {
|
|
282
285
|
return this[0];
|
|
283
286
|
}
|
|
287
|
+
$ok() {
|
|
288
|
+
undefined;
|
|
289
|
+
}
|
|
284
290
|
$isOk() {
|
|
285
291
|
return false;
|
|
286
292
|
}
|
|
@@ -389,12 +395,24 @@ class ResultAsync {
|
|
|
389
395
|
then(onfulfilled, onrejected) {
|
|
390
396
|
return __classPrivateFieldGet(this, _ResultAsync_inner, "f").then(onfulfilled, onrejected);
|
|
391
397
|
}
|
|
398
|
+
/**
|
|
399
|
+
* @TODO
|
|
400
|
+
*/
|
|
401
|
+
async $toNativeTuple() {
|
|
402
|
+
return (await __classPrivateFieldGet(this, _ResultAsync_inner, "f")).$toNativeTuple();
|
|
403
|
+
}
|
|
392
404
|
/**
|
|
393
405
|
* @TODO
|
|
394
406
|
*/
|
|
395
407
|
async $value() {
|
|
396
408
|
return (await __classPrivateFieldGet(this, _ResultAsync_inner, "f")).$value();
|
|
397
409
|
}
|
|
410
|
+
/**
|
|
411
|
+
* @TODO
|
|
412
|
+
*/
|
|
413
|
+
async $ok() {
|
|
414
|
+
return (await __classPrivateFieldGet(this, _ResultAsync_inner, "f")).$ok();
|
|
415
|
+
}
|
|
398
416
|
/**
|
|
399
417
|
* @TODO
|
|
400
418
|
*/
|
package/dist/index.d.cts
CHANGED
|
@@ -49,9 +49,9 @@ export declare class RetupleThrownValueError extends Error {
|
|
|
49
49
|
/**
|
|
50
50
|
* ## Retuple Invalid Result Error
|
|
51
51
|
*
|
|
52
|
-
* An error
|
|
53
|
-
*
|
|
54
|
-
*
|
|
52
|
+
* An error thrown when attempting to construct a `Result` from a native tuple,
|
|
53
|
+
* when neither index 0 or 1 are null or undefined. In this case, it is impossible
|
|
54
|
+
* to determine whether the result should be `Ok` or `Err`.
|
|
55
55
|
*/
|
|
56
56
|
export declare class RetupleInvalidResultError extends Error {
|
|
57
57
|
value: unknown[];
|
|
@@ -125,10 +125,18 @@ declare class ResultAsync<T, E> {
|
|
|
125
125
|
#private;
|
|
126
126
|
constructor(inner: PromiseLike<Result<T, E>>);
|
|
127
127
|
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>;
|
|
128
|
+
/**
|
|
129
|
+
* @TODO
|
|
130
|
+
*/
|
|
131
|
+
$toNativeTuple(this: ResultAsync<T, E>): Promise<OkTuple<T> | ErrTuple<E>>;
|
|
128
132
|
/**
|
|
129
133
|
* @TODO
|
|
130
134
|
*/
|
|
131
135
|
$value(this: ResultAsync<T, E>): Promise<T | E>;
|
|
136
|
+
/**
|
|
137
|
+
* @TODO
|
|
138
|
+
*/
|
|
139
|
+
$ok(this: ResultAsync<T, E>): Promise<T | undefined>;
|
|
132
140
|
/**
|
|
133
141
|
* @TODO
|
|
134
142
|
*/
|
|
@@ -238,6 +246,10 @@ interface Retuple<T, E> {
|
|
|
238
246
|
* @TODO
|
|
239
247
|
*/
|
|
240
248
|
$value(this: Result<T, E>): T | E;
|
|
249
|
+
/**
|
|
250
|
+
* @TODO
|
|
251
|
+
*/
|
|
252
|
+
$ok(this: Result<T, E>): T | undefined;
|
|
241
253
|
/**
|
|
242
254
|
* @TODO
|
|
243
255
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -49,9 +49,9 @@ export declare class RetupleThrownValueError extends Error {
|
|
|
49
49
|
/**
|
|
50
50
|
* ## Retuple Invalid Result Error
|
|
51
51
|
*
|
|
52
|
-
* An error
|
|
53
|
-
*
|
|
54
|
-
*
|
|
52
|
+
* An error thrown when attempting to construct a `Result` from a native tuple,
|
|
53
|
+
* when neither index 0 or 1 are null or undefined. In this case, it is impossible
|
|
54
|
+
* to determine whether the result should be `Ok` or `Err`.
|
|
55
55
|
*/
|
|
56
56
|
export declare class RetupleInvalidResultError extends Error {
|
|
57
57
|
value: unknown[];
|
|
@@ -125,10 +125,18 @@ declare class ResultAsync<T, E> {
|
|
|
125
125
|
#private;
|
|
126
126
|
constructor(inner: PromiseLike<Result<T, E>>);
|
|
127
127
|
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>;
|
|
128
|
+
/**
|
|
129
|
+
* @TODO
|
|
130
|
+
*/
|
|
131
|
+
$toNativeTuple(this: ResultAsync<T, E>): Promise<OkTuple<T> | ErrTuple<E>>;
|
|
128
132
|
/**
|
|
129
133
|
* @TODO
|
|
130
134
|
*/
|
|
131
135
|
$value(this: ResultAsync<T, E>): Promise<T | E>;
|
|
136
|
+
/**
|
|
137
|
+
* @TODO
|
|
138
|
+
*/
|
|
139
|
+
$ok(this: ResultAsync<T, E>): Promise<T | undefined>;
|
|
132
140
|
/**
|
|
133
141
|
* @TODO
|
|
134
142
|
*/
|
|
@@ -238,6 +246,10 @@ interface Retuple<T, E> {
|
|
|
238
246
|
* @TODO
|
|
239
247
|
*/
|
|
240
248
|
$value(this: Result<T, E>): T | E;
|
|
249
|
+
/**
|
|
250
|
+
* @TODO
|
|
251
|
+
*/
|
|
252
|
+
$ok(this: Result<T, E>): T | undefined;
|
|
241
253
|
/**
|
|
242
254
|
* @TODO
|
|
243
255
|
*/
|
package/dist/index.js
CHANGED
|
@@ -60,13 +60,13 @@ export class RetupleThrownValueError extends Error {
|
|
|
60
60
|
/**
|
|
61
61
|
* ## Retuple Invalid Result Error
|
|
62
62
|
*
|
|
63
|
-
* An error
|
|
64
|
-
*
|
|
65
|
-
*
|
|
63
|
+
* An error thrown when attempting to construct a `Result` from a native tuple,
|
|
64
|
+
* when neither index 0 or 1 are null or undefined. In this case, it is impossible
|
|
65
|
+
* to determine whether the result should be `Ok` or `Err`.
|
|
66
66
|
*/
|
|
67
67
|
export class RetupleInvalidResultError extends Error {
|
|
68
68
|
constructor(value) {
|
|
69
|
-
super("Constructing a Result from tuple failed, at least one of the values at index 0 or 1 should be undefined");
|
|
69
|
+
super("Constructing a Result from native tuple failed, at least one of the values at index 0 or 1 should be null or undefined");
|
|
70
70
|
this.value = value;
|
|
71
71
|
}
|
|
72
72
|
}
|
|
@@ -152,6 +152,9 @@ class ResultOk extends Array {
|
|
|
152
152
|
$value() {
|
|
153
153
|
return this[1];
|
|
154
154
|
}
|
|
155
|
+
$ok() {
|
|
156
|
+
return this[1];
|
|
157
|
+
}
|
|
155
158
|
$isOk() {
|
|
156
159
|
return true;
|
|
157
160
|
}
|
|
@@ -265,6 +268,9 @@ class ResultErr extends Array {
|
|
|
265
268
|
$value() {
|
|
266
269
|
return this[0];
|
|
267
270
|
}
|
|
271
|
+
$ok() {
|
|
272
|
+
undefined;
|
|
273
|
+
}
|
|
268
274
|
$isOk() {
|
|
269
275
|
return false;
|
|
270
276
|
}
|
|
@@ -373,12 +379,24 @@ class ResultAsync {
|
|
|
373
379
|
then(onfulfilled, onrejected) {
|
|
374
380
|
return __classPrivateFieldGet(this, _ResultAsync_inner, "f").then(onfulfilled, onrejected);
|
|
375
381
|
}
|
|
382
|
+
/**
|
|
383
|
+
* @TODO
|
|
384
|
+
*/
|
|
385
|
+
async $toNativeTuple() {
|
|
386
|
+
return (await __classPrivateFieldGet(this, _ResultAsync_inner, "f")).$toNativeTuple();
|
|
387
|
+
}
|
|
376
388
|
/**
|
|
377
389
|
* @TODO
|
|
378
390
|
*/
|
|
379
391
|
async $value() {
|
|
380
392
|
return (await __classPrivateFieldGet(this, _ResultAsync_inner, "f")).$value();
|
|
381
393
|
}
|
|
394
|
+
/**
|
|
395
|
+
* @TODO
|
|
396
|
+
*/
|
|
397
|
+
async $ok() {
|
|
398
|
+
return (await __classPrivateFieldGet(this, _ResultAsync_inner, "f")).$ok();
|
|
399
|
+
}
|
|
382
400
|
/**
|
|
383
401
|
* @TODO
|
|
384
402
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "retuple",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.5",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"test": "vitest",
|
|
6
6
|
"lint": "eslint . --ext .ts -c eslint.config.mjs --fix",
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"module": "./dist/index.js",
|
|
14
14
|
"zshy": "./src/index.ts",
|
|
15
15
|
"keywords": [
|
|
16
|
-
"error",
|
|
17
|
-
"handling",
|
|
18
|
-
"safe",
|
|
19
16
|
"result",
|
|
17
|
+
"safe",
|
|
20
18
|
"throw",
|
|
19
|
+
"error",
|
|
20
|
+
"handling",
|
|
21
21
|
"monad"
|
|
22
22
|
],
|
|
23
23
|
"author": "Matthew Wilson",
|