@reykjavik/webtools 0.2.0 → 0.2.1

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/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@
4
4
 
5
5
  - ... <!-- Add new lines here. -->
6
6
 
7
+ ## 0.2.1
8
+
9
+ _2024-12-17_
10
+
11
+ - fix: Make typing of failed ResultTuple/ResultTupleObj less ambiguous
12
+
7
13
  ## 0.2.0
8
14
 
9
15
  _2024-12-12_
@@ -24,7 +24,7 @@ type SuccessResult<T> = [error: undefined, result: T] & {
24
24
  error?: undefined;
25
25
  result: T;
26
26
  };
27
- type FailResult<E extends Error> = [error: E] & {
27
+ type FailResult<E extends Error> = [error: E, result?: undefined] & {
28
28
  error: E;
29
29
  result?: undefined;
30
30
  };
@@ -33,7 +33,7 @@ type FailResult<E extends Error> = [error: E] & {
33
33
  *
34
34
  * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#type-resulttuple
35
35
  */
36
- export type ResultTuple<T, E extends Error = Error> = [error: undefined, result: T] | [error: E];
36
+ export type ResultTuple<T, E extends Error = Error> = [error: undefined, result: T] | [error: E, result?: undefined];
37
37
  /**
38
38
  * Discriminated tuple type for a `[error, result]` pair (same as `ResultTuple`)
39
39
  * but with named properties `error` and `result` attached for dev convenience.
package/errorhandling.js CHANGED
@@ -48,7 +48,7 @@ const Fail = (e) => {
48
48
  };
49
49
  function catch_(something) {
50
50
  if (something instanceof Promise) {
51
- return something.then((result) => Success(result), (e) => Fail(e));
51
+ return something.then(Success, (e) => Fail(e));
52
52
  }
53
53
  try {
54
54
  return Success(something());
@@ -24,7 +24,7 @@ type SuccessResult<T> = [error: undefined, result: T] & {
24
24
  error?: undefined;
25
25
  result: T;
26
26
  };
27
- type FailResult<E extends Error> = [error: E] & {
27
+ type FailResult<E extends Error> = [error: E, result?: undefined] & {
28
28
  error: E;
29
29
  result?: undefined;
30
30
  };
@@ -33,7 +33,7 @@ type FailResult<E extends Error> = [error: E] & {
33
33
  *
34
34
  * @see https://github.com/reykjavikcity/webtools/blob/v0.2/README.md#type-resulttuple
35
35
  */
36
- export type ResultTuple<T, E extends Error = Error> = [error: undefined, result: T] | [error: E];
36
+ export type ResultTuple<T, E extends Error = Error> = [error: undefined, result: T] | [error: E, result?: undefined];
37
37
  /**
38
38
  * Discriminated tuple type for a `[error, result]` pair (same as `ResultTuple`)
39
39
  * but with named properties `error` and `result` attached for dev convenience.
@@ -43,7 +43,7 @@ const Fail = (e) => {
43
43
  };
44
44
  function catch_(something) {
45
45
  if (something instanceof Promise) {
46
- return something.then((result) => Success(result), (e) => Fail(e));
46
+ return something.then(Success, (e) => Fail(e));
47
47
  }
48
48
  try {
49
49
  return Success(something());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reykjavik/webtools",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Misc. JS/TS helpers used by Reykjavík City's web dev teams.",
5
5
  "main": "index.js",
6
6
  "repository": "ssh://git@github.com:reykjavikcity/webtools.git",