retuple 1.0.0-next.31 → 1.0.0-next.32

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
@@ -601,9 +601,9 @@ class ResultOk extends Array {
601
601
  $mapErr() {
602
602
  return this;
603
603
  }
604
- $mapErrMatching() {
605
- return this;
606
- }
604
+ // $mapErrMatching(this: ThisOk<T>): ThisOk<T> {
605
+ // return this;
606
+ // }
607
607
  $mapOr(_def, f) {
608
608
  return Ok(f(this[1]));
609
609
  }
@@ -790,15 +790,18 @@ class ResultErr extends Array {
790
790
  $mapErr(f) {
791
791
  return Err(f(this[0]));
792
792
  }
793
- $mapErrMatching({ classes, with: f }) {
794
- const err = this[0];
795
- for (const ctor of classes) {
796
- if (err instanceof ctor) {
797
- return Err(f(err));
798
- }
799
- }
800
- return this;
801
- }
793
+ // $mapErrMatching<F, C extends new (...args: any[]) => Error>(
794
+ // this: Result<T, E>,
795
+ // { classes, with: f }: MapErrMatchingParams<F, C>,
796
+ // ): Result<never, E | F> {
797
+ // const err = this[0];
798
+ // for (const ctor of classes) {
799
+ // if (err instanceof ctor) {
800
+ // return Err(f(err as InstanceType<C>));
801
+ // }
802
+ // }
803
+ // return this as Result<never, E>;
804
+ // }
802
805
  $mapOr(def) {
803
806
  return Ok(def);
804
807
  }
@@ -1012,12 +1015,17 @@ class ResultAsync {
1012
1015
  : res;
1013
1016
  }));
1014
1017
  }
1015
- /**
1016
- * @TODO
1017
- */
1018
- $mapErrMatching(params) {
1019
- return new ResultAsync(__classPrivateFieldGet(this, _ResultAsync_inner, "f").then(async (res) => res.$mapErrMatching(params)));
1020
- }
1018
+ // /**
1019
+ // * @TODO
1020
+ // */
1021
+ // $mapErrMatching<F, C extends new (...args: any[]) => Error>(
1022
+ // this: ResultAsync<T, E>,
1023
+ // params: MapErrMatchingParams<F, C>,
1024
+ // ): ResultAsync<T, E | F> {
1025
+ // return new ResultAsync(
1026
+ // this.#inner.then(async (res) => res.$mapErrMatching(params)),
1027
+ // );
1028
+ // }
1021
1029
  /**
1022
1030
  * The same as {@link Retuple.$mapOr|$mapOr}, except it returns
1023
1031
  * {@link ResultAsync}.
package/dist/index.d.cts CHANGED
@@ -265,10 +265,6 @@ declare class ResultAsync<T, E> {
265
265
  * {@link ResultAsync}.
266
266
  */
267
267
  $mapErr<F = E>(this: ResultAsync<T, E>, f: (err: E) => F): ResultAsync<T, F>;
268
- /**
269
- * @TODO
270
- */
271
- $mapErrMatching<F, C extends new (...args: any[]) => Error>(this: ResultAsync<T, E>, params: MapErrMatchingParams<F, C>): ResultAsync<T, E | F>;
272
268
  /**
273
269
  * The same as {@link Retuple.$mapOr|$mapOr}, except it returns
274
270
  * {@link ResultAsync}.
@@ -1022,13 +1018,6 @@ interface Retuple<T, E> extends ResultLike<T, E> {
1022
1018
  * ```
1023
1019
  */
1024
1020
  $mapErr<F = E>(this: Result<T, E>, f: (err: E) => F): Result<T, F>;
1025
- /**
1026
- * @TODO
1027
- */
1028
- $mapErrMatching<F, C extends new (...args: any[]) => Error>(this: Result<T, E>, mapper: {
1029
- classes: [C, ...C[]];
1030
- with: (err: InstanceType<C>) => F;
1031
- }): Result<T, E | F>;
1032
1021
  /**
1033
1022
  * Returns `Ok` containing the return value of the map function when this
1034
1023
  * result is `Ok`.
@@ -1638,10 +1627,6 @@ type CollectOk<TResults extends Record<string, ResultLikeAwaitable<any, any>>> =
1638
1627
  [K in keyof TResults]: TResults[K] extends ResultLikeAwaitable<infer T, any> ? T : never;
1639
1628
  } & {};
1640
1629
  type CollectErr<TResults extends Record<string, ResultLikeAwaitable<any, any>>> = TResults[keyof TResults] extends ResultLikeAwaitable<any, infer E> ? E : never;
1641
- interface MapErrMatchingParams<F, C extends new (...args: any[]) => Error> {
1642
- classes: [C, ...C[]];
1643
- with: (err: InstanceType<C>) => F;
1644
- }
1645
1630
  type Truthy<T> = Exclude<T, false | null | undefined | 0 | 0n | "">;
1646
1631
  type Falsey<T> = Extract<T, false | null | undefined | 0 | 0n | "">;
1647
1632
  type NonZero<N extends number> = N & (`${N}` extends "0" ? never : N);
package/dist/index.d.ts CHANGED
@@ -265,10 +265,6 @@ declare class ResultAsync<T, E> {
265
265
  * {@link ResultAsync}.
266
266
  */
267
267
  $mapErr<F = E>(this: ResultAsync<T, E>, f: (err: E) => F): ResultAsync<T, F>;
268
- /**
269
- * @TODO
270
- */
271
- $mapErrMatching<F, C extends new (...args: any[]) => Error>(this: ResultAsync<T, E>, params: MapErrMatchingParams<F, C>): ResultAsync<T, E | F>;
272
268
  /**
273
269
  * The same as {@link Retuple.$mapOr|$mapOr}, except it returns
274
270
  * {@link ResultAsync}.
@@ -1022,13 +1018,6 @@ interface Retuple<T, E> extends ResultLike<T, E> {
1022
1018
  * ```
1023
1019
  */
1024
1020
  $mapErr<F = E>(this: Result<T, E>, f: (err: E) => F): Result<T, F>;
1025
- /**
1026
- * @TODO
1027
- */
1028
- $mapErrMatching<F, C extends new (...args: any[]) => Error>(this: Result<T, E>, mapper: {
1029
- classes: [C, ...C[]];
1030
- with: (err: InstanceType<C>) => F;
1031
- }): Result<T, E | F>;
1032
1021
  /**
1033
1022
  * Returns `Ok` containing the return value of the map function when this
1034
1023
  * result is `Ok`.
@@ -1638,10 +1627,6 @@ type CollectOk<TResults extends Record<string, ResultLikeAwaitable<any, any>>> =
1638
1627
  [K in keyof TResults]: TResults[K] extends ResultLikeAwaitable<infer T, any> ? T : never;
1639
1628
  } & {};
1640
1629
  type CollectErr<TResults extends Record<string, ResultLikeAwaitable<any, any>>> = TResults[keyof TResults] extends ResultLikeAwaitable<any, infer E> ? E : never;
1641
- interface MapErrMatchingParams<F, C extends new (...args: any[]) => Error> {
1642
- classes: [C, ...C[]];
1643
- with: (err: InstanceType<C>) => F;
1644
- }
1645
1630
  type Truthy<T> = Exclude<T, false | null | undefined | 0 | 0n | "">;
1646
1631
  type Falsey<T> = Extract<T, false | null | undefined | 0 | 0n | "">;
1647
1632
  type NonZero<N extends number> = N & (`${N}` extends "0" ? never : N);
package/dist/index.js CHANGED
@@ -587,9 +587,9 @@ class ResultOk extends Array {
587
587
  $mapErr() {
588
588
  return this;
589
589
  }
590
- $mapErrMatching() {
591
- return this;
592
- }
590
+ // $mapErrMatching(this: ThisOk<T>): ThisOk<T> {
591
+ // return this;
592
+ // }
593
593
  $mapOr(_def, f) {
594
594
  return Ok(f(this[1]));
595
595
  }
@@ -776,15 +776,18 @@ class ResultErr extends Array {
776
776
  $mapErr(f) {
777
777
  return Err(f(this[0]));
778
778
  }
779
- $mapErrMatching({ classes, with: f }) {
780
- const err = this[0];
781
- for (const ctor of classes) {
782
- if (err instanceof ctor) {
783
- return Err(f(err));
784
- }
785
- }
786
- return this;
787
- }
779
+ // $mapErrMatching<F, C extends new (...args: any[]) => Error>(
780
+ // this: Result<T, E>,
781
+ // { classes, with: f }: MapErrMatchingParams<F, C>,
782
+ // ): Result<never, E | F> {
783
+ // const err = this[0];
784
+ // for (const ctor of classes) {
785
+ // if (err instanceof ctor) {
786
+ // return Err(f(err as InstanceType<C>));
787
+ // }
788
+ // }
789
+ // return this as Result<never, E>;
790
+ // }
788
791
  $mapOr(def) {
789
792
  return Ok(def);
790
793
  }
@@ -998,12 +1001,17 @@ class ResultAsync {
998
1001
  : res;
999
1002
  }));
1000
1003
  }
1001
- /**
1002
- * @TODO
1003
- */
1004
- $mapErrMatching(params) {
1005
- return new ResultAsync(__classPrivateFieldGet(this, _ResultAsync_inner, "f").then(async (res) => res.$mapErrMatching(params)));
1006
- }
1004
+ // /**
1005
+ // * @TODO
1006
+ // */
1007
+ // $mapErrMatching<F, C extends new (...args: any[]) => Error>(
1008
+ // this: ResultAsync<T, E>,
1009
+ // params: MapErrMatchingParams<F, C>,
1010
+ // ): ResultAsync<T, E | F> {
1011
+ // return new ResultAsync(
1012
+ // this.#inner.then(async (res) => res.$mapErrMatching(params)),
1013
+ // );
1014
+ // }
1007
1015
  /**
1008
1016
  * The same as {@link Retuple.$mapOr|$mapOr}, except it returns
1009
1017
  * {@link ResultAsync}.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "retuple",
3
- "version": "1.0.0-next.31",
3
+ "version": "1.0.0-next.32",
4
4
  "scripts": {
5
5
  "test": "vitest",
6
6
  "lint": "eslint . --ext .ts -c eslint.config.mjs --fix",