go-go-try 2.0.1 → 2.0.2

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.
Files changed (3) hide show
  1. package/index.d.ts +1 -1
  2. package/index.js +2 -1
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- declare type ResultTuple<T> = [string?, T?];
1
+ declare type ResultTuple<T> = [string, undefined] | [undefined, T];
2
2
  export default function goTry<T>(value: (() => T) | PromiseLike<T>): ResultTuple<T> | PromiseLike<ResultTuple<T>>;
3
3
  export {};
package/index.js CHANGED
@@ -22,8 +22,9 @@ function getErrorMessage(error) {
22
22
  return toErrorWithMessage(error).message;
23
23
  }
24
24
  export default function goTry(value) {
25
+ let unwrappedValue;
25
26
  try {
26
- const unwrappedValue = typeof value === 'function' ? value() : value;
27
+ unwrappedValue = typeof value === 'function' ? value() : value;
27
28
  if (pIsPromise(unwrappedValue)) {
28
29
  return Promise.resolve(unwrappedValue)
29
30
  .then((value) => [undefined, value])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "go-go-try",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "Tries to execute a sync/async function, returns a result tuple",
5
5
  "license": "MIT",
6
6
  "repository": "thelinuxlich/go-go-try",