@mrpelz/misc-utils 5.4.0 → 5.5.0

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.
@@ -0,0 +1,2 @@
1
+ export declare const safeAsync: <T>(promise: Promise<T> | T) => Promise<[undefined, T] | [Error, undefined]>;
2
+ //# sourceMappingURL=async.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../src/async.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,GAAU,CAAC,EAC/B,SAAS,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,KACtB,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAgB7C,CAAC"}
package/dist/async.js ADDED
@@ -0,0 +1,18 @@
1
+ export const safeAsync = async (promise) => {
2
+ try {
3
+ const result = await promise;
4
+ return [undefined, result];
5
+ }
6
+ catch (error) {
7
+ if (error instanceof Error) {
8
+ return [error, undefined];
9
+ }
10
+ return [
11
+ new Error('safeAsync encountered non-error value being thrown', {
12
+ cause: error,
13
+ }),
14
+ undefined,
15
+ ];
16
+ }
17
+ };
18
+ //# sourceMappingURL=async.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async.js","sourceRoot":"","sources":["../src/async.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAC5B,OAAuB,EACuB,EAAE;IAChD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC;QAC7B,OAAO,CAAC,SAAS,EAAE,MAAM,CAAU,CAAC;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,OAAO,CAAC,KAAK,EAAE,SAAS,CAAU,CAAC;QACrC,CAAC;QAED,OAAO;YACL,IAAI,KAAK,CAAC,oDAAoD,EAAE;gBAC9D,KAAK,EAAE,KAAK;aACb,CAAC;YACF,SAAS;SACD,CAAC;IACb,CAAC;AACH,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrpelz/misc-utils",
3
- "version": "5.4.0",
3
+ "version": "5.5.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/mrpelz/utils.git",
@@ -14,6 +14,10 @@
14
14
  "types": "./dist/main.d.ts",
15
15
  "default": "./dist/main.js"
16
16
  },
17
+ "./async": {
18
+ "types": "./dist/async.d.ts",
19
+ "default": "./dist/async.js"
20
+ },
17
21
  "./data": {
18
22
  "types": "./dist/data.d.ts",
19
23
  "default": "./dist/data.js"