try-catch-util 1.0.3 → 1.0.6

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/index.ts"],
3
+ "sources": ["../../src/index.ts"],
4
4
  "sourcesContent": ["export type Success<T> = { result: T; error?: never };\nexport type Failure<E> = { result?: never; error: E };\nexport type Result<T, E extends Error = Error> = Success<T> | Failure<E>;\n\n/**\n * Executes a synchronous or asynchronous function and returns a typed result object.\n *\n * Successful executions resolve with `{ result }`, while thrown errors resolve with\n * `{ error }`. If a string is thrown, it is converted into an `Error` instance.\n *\n * @param input - Function to execute safely.\n * @returns A promise containing either the function result or the captured error.\n */\nexport async function tryCatch<T, E extends Error = Error>(input: () => Promise<T> | T): Promise<Result<T, E>> {\n try {\n const result = await input();\n return { result };\n } catch (e) {\n const error = typeof e === 'string' ? (new Error(String(e)) as E) : (e as E);\n return { error };\n }\n}\n"],
5
5
  "mappings": "4dAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,GAaA,eAAsBI,EAAqCC,EAAoD,CAC7G,GAAI,CAEF,MAAO,CAAE,OADM,MAAMA,EAAM,CACX,CAClB,OAASC,EAAG,CAEV,MAAO,CAAE,MADK,OAAOA,GAAM,SAAY,IAAI,MAAM,OAAOA,CAAC,CAAC,EAAWA,CACtD,CACjB,CACF,CARsBC,EAAAH,EAAA",
6
6
  "names": ["index_exports", "__export", "tryCatch", "__toCommonJS", "tryCatch", "input", "e", "__name"]
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/index.ts"],
3
+ "sources": ["../../src/index.ts"],
4
4
  "sourcesContent": ["export type Success<T> = { result: T; error?: never };\nexport type Failure<E> = { result?: never; error: E };\nexport type Result<T, E extends Error = Error> = Success<T> | Failure<E>;\n\n/**\n * Executes a synchronous or asynchronous function and returns a typed result object.\n *\n * Successful executions resolve with `{ result }`, while thrown errors resolve with\n * `{ error }`. If a string is thrown, it is converted into an `Error` instance.\n *\n * @param input - Function to execute safely.\n * @returns A promise containing either the function result or the captured error.\n */\nexport async function tryCatch<T, E extends Error = Error>(input: () => Promise<T> | T): Promise<Result<T, E>> {\n try {\n const result = await input();\n return { result };\n } catch (e) {\n const error = typeof e === 'string' ? (new Error(String(e)) as E) : (e as E);\n return { error };\n }\n}\n"],
5
5
  "mappings": "+EAaA,eAAsBA,EAAqCC,EAAoD,CAC7G,GAAI,CAEF,MAAO,CAAE,OADM,MAAMA,EAAM,CACX,CAClB,OAASC,EAAG,CAEV,MAAO,CAAE,MADK,OAAOA,GAAM,SAAY,IAAI,MAAM,OAAOA,CAAC,CAAC,EAAWA,CACtD,CACjB,CACF,CARsBC,EAAAH,EAAA",
6
6
  "names": ["tryCatch", "input", "e", "__name"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "try-catch-util",
3
- "version": "1.0.3",
3
+ "version": "1.0.6",
4
4
  "description": "A simple util to wrap sync/async functions and handle errors type-safely.",
5
5
  "keywords": [
6
6
  "try catch",
@@ -14,14 +14,14 @@
14
14
  "url": "https://github.com/raghurana/tryCatch"
15
15
  },
16
16
  "type": "module",
17
- "main": "./dist/index.cjs",
18
- "module": "./dist/index.js",
17
+ "main": "./dist/cjs/index.cjs",
18
+ "module": "./dist/esm/index.js",
19
19
  "types": "./dist/index.d.ts",
20
20
  "exports": {
21
21
  ".": {
22
22
  "types": "./dist/index.d.ts",
23
- "import": "./dist/index.js",
24
- "require": "./dist/index.cjs"
23
+ "import": "./dist/esm/index.js",
24
+ "require": "./dist/cjs/index.cjs"
25
25
  }
26
26
  },
27
27
  "files": [
@@ -35,8 +35,7 @@
35
35
  "check": "biome check .",
36
36
  "test": "jest",
37
37
  "build": "tsc --build --noEmit && tsx esbuild.config.ts",
38
- "prepublishOnly": "npm run build && npm test",
39
- "publish": "npm version patch && npm publish"
38
+ "prepublishOnly": "npm run build && npm test"
40
39
  },
41
40
  "devDependencies": {
42
41
  "@biomejs/biome": "^2.4.16",
File without changes
File without changes