retuple 1.0.0-next.30 → 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,6 +601,9 @@ class ResultOk extends Array {
601
601
  $mapErr() {
602
602
  return this;
603
603
  }
604
+ // $mapErrMatching(this: ThisOk<T>): ThisOk<T> {
605
+ // return this;
606
+ // }
604
607
  $mapOr(_def, f) {
605
608
  return Ok(f(this[1]));
606
609
  }
@@ -787,6 +790,18 @@ class ResultErr extends Array {
787
790
  $mapErr(f) {
788
791
  return Err(f(this[0]));
789
792
  }
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
+ // }
790
805
  $mapOr(def) {
791
806
  return Ok(def);
792
807
  }
@@ -1000,6 +1015,17 @@ class ResultAsync {
1000
1015
  : res;
1001
1016
  }));
1002
1017
  }
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
+ // }
1003
1029
  /**
1004
1030
  * The same as {@link Retuple.$mapOr|$mapOr}, except it returns
1005
1031
  * {@link ResultAsync}.
package/dist/index.js CHANGED
@@ -587,6 +587,9 @@ class ResultOk extends Array {
587
587
  $mapErr() {
588
588
  return this;
589
589
  }
590
+ // $mapErrMatching(this: ThisOk<T>): ThisOk<T> {
591
+ // return this;
592
+ // }
590
593
  $mapOr(_def, f) {
591
594
  return Ok(f(this[1]));
592
595
  }
@@ -773,6 +776,18 @@ class ResultErr extends Array {
773
776
  $mapErr(f) {
774
777
  return Err(f(this[0]));
775
778
  }
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
+ // }
776
791
  $mapOr(def) {
777
792
  return Ok(def);
778
793
  }
@@ -986,6 +1001,17 @@ class ResultAsync {
986
1001
  : res;
987
1002
  }));
988
1003
  }
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
+ // }
989
1015
  /**
990
1016
  * The same as {@link Retuple.$mapOr|$mapOr}, except it returns
991
1017
  * {@link ResultAsync}.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "retuple",
3
- "version": "1.0.0-next.30",
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",