retuple 1.0.0-next.20 → 1.0.0-next.22

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 CHANGED
@@ -12,7 +12,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
12
12
  };
13
13
  var _ResultAsync_inner, _a, _ResultRetry_f, _ResultRetry_promise, _ResultRetry_times, _ResultRetry_attempt, _ResultRetry_aborted, _ResultRetry_abort, _ResultRetry_getDelay, _ResultRetry_handler;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.RetupleArrayMethodUnavailableError = exports.RetupleInvalidUnionError = exports.RetupleCaughtValueError = exports.RetupleExpectFailed = exports.RetupleUnwrapErrFailed = exports.RetupleUnwrapFailed = void 0;
15
+ exports.RetupleInvalidUnionError = exports.RetupleCaughtValueError = exports.RetupleExpectFailed = exports.RetupleUnwrapErrFailed = exports.RetupleUnwrapFailed = void 0;
16
16
  exports.Result = Result;
17
17
  exports.Ok = Ok;
18
18
  exports.Err = Err;
@@ -84,19 +84,6 @@ class RetupleInvalidUnionError extends Error {
84
84
  }
85
85
  }
86
86
  exports.RetupleInvalidUnionError = RetupleInvalidUnionError;
87
- /**
88
- * ## Retuple Array Method Unavailable Error
89
- *
90
- * This error is thrown when calling a built-in array method from a `Result`.
91
- */
92
- class RetupleArrayMethodUnavailableError extends Error {
93
- constructor(value, method) {
94
- super(`Built in array method '${method}' should not be called directly from ` +
95
- "a Result, convert the Result to a tuple first");
96
- this.value = value;
97
- }
98
- }
99
- exports.RetupleArrayMethodUnavailableError = RetupleArrayMethodUnavailableError;
100
87
  /**
101
88
  * ## Result
102
89
  *
@@ -805,6 +792,13 @@ class ResultAsync {
805
792
  return res;
806
793
  }));
807
794
  }
795
+ /**
796
+ * The same as {@link Retuple.$flatten|$flatten} except it returns
797
+ * {@link ResultAsync}.
798
+ */
799
+ $flatten() {
800
+ return new ResultAsync(__classPrivateFieldGet(this, _ResultAsync_inner, "f").then((res) => res.$flatten()));
801
+ }
808
802
  /**
809
803
  * The same as {@link Retuple.$promise|$promise}.
810
804
  */
package/dist/index.d.cts CHANGED
@@ -59,15 +59,6 @@ export declare class RetupleInvalidUnionError extends Error {
59
59
  value: unknown;
60
60
  constructor(value: unknown);
61
61
  }
62
- /**
63
- * ## Retuple Array Method Unavailable Error
64
- *
65
- * This error is thrown when calling a built-in array method from a `Result`.
66
- */
67
- export declare class RetupleArrayMethodUnavailableError extends Error {
68
- value: unknown[];
69
- constructor(value: unknown[], method: Exclude<keyof any[] & string, "length">);
70
- }
71
62
  /**
72
63
  * ## Result
73
64
  *
@@ -320,6 +311,11 @@ declare class ResultAsync<T, E> {
320
311
  * - returns {@link ResultAsync}.
321
312
  */
322
313
  $tapErr(this: ResultAsync<T, E>, f: (err: E) => any): ResultAsync<T, E>;
314
+ /**
315
+ * The same as {@link Retuple.$flatten|$flatten} except it returns
316
+ * {@link ResultAsync}.
317
+ */
318
+ $flatten<U, F>(this: ResultAsync<Result<U, F>, E>): ResultAsync<U, E | F>;
323
319
  /**
324
320
  * The same as {@link Retuple.$promise|$promise}.
325
321
  */
package/dist/index.d.ts CHANGED
@@ -59,15 +59,6 @@ export declare class RetupleInvalidUnionError extends Error {
59
59
  value: unknown;
60
60
  constructor(value: unknown);
61
61
  }
62
- /**
63
- * ## Retuple Array Method Unavailable Error
64
- *
65
- * This error is thrown when calling a built-in array method from a `Result`.
66
- */
67
- export declare class RetupleArrayMethodUnavailableError extends Error {
68
- value: unknown[];
69
- constructor(value: unknown[], method: Exclude<keyof any[] & string, "length">);
70
- }
71
62
  /**
72
63
  * ## Result
73
64
  *
@@ -320,6 +311,11 @@ declare class ResultAsync<T, E> {
320
311
  * - returns {@link ResultAsync}.
321
312
  */
322
313
  $tapErr(this: ResultAsync<T, E>, f: (err: E) => any): ResultAsync<T, E>;
314
+ /**
315
+ * The same as {@link Retuple.$flatten|$flatten} except it returns
316
+ * {@link ResultAsync}.
317
+ */
318
+ $flatten<U, F>(this: ResultAsync<Result<U, F>, E>): ResultAsync<U, E | F>;
323
319
  /**
324
320
  * The same as {@link Retuple.$promise|$promise}.
325
321
  */
package/dist/index.js CHANGED
@@ -73,18 +73,6 @@ export class RetupleInvalidUnionError extends Error {
73
73
  this.value = value;
74
74
  }
75
75
  }
76
- /**
77
- * ## Retuple Array Method Unavailable Error
78
- *
79
- * This error is thrown when calling a built-in array method from a `Result`.
80
- */
81
- export class RetupleArrayMethodUnavailableError extends Error {
82
- constructor(value, method) {
83
- super(`Built in array method '${method}' should not be called directly from ` +
84
- "a Result, convert the Result to a tuple first");
85
- this.value = value;
86
- }
87
- }
88
76
  /**
89
77
  * ## Result
90
78
  *
@@ -793,6 +781,13 @@ class ResultAsync {
793
781
  return res;
794
782
  }));
795
783
  }
784
+ /**
785
+ * The same as {@link Retuple.$flatten|$flatten} except it returns
786
+ * {@link ResultAsync}.
787
+ */
788
+ $flatten() {
789
+ return new ResultAsync(__classPrivateFieldGet(this, _ResultAsync_inner, "f").then((res) => res.$flatten()));
790
+ }
796
791
  /**
797
792
  * The same as {@link Retuple.$promise|$promise}.
798
793
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "retuple",
3
- "version": "1.0.0-next.20",
3
+ "version": "1.0.0-next.22",
4
4
  "scripts": {
5
5
  "test": "vitest",
6
6
  "lint": "eslint . --ext .ts -c eslint.config.mjs --fix",