{"_id":"@aarondill/never-throw","name":"@aarondill/never-throw","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.4":{"name":"@aarondill/never-throw","version":"1.0.4","description":"Simplfy Error Handling","keywords":["try","catch","nothrow","never throw","type safe","safe"],"repository":{"type":"git","url":"git+https://github.com/aarondill/never-throw.git"},"license":"MIT","author":{"name":"Aaron Dill"},"main":"dist/neverThrow.js","types":"dist/neverThrow.d.ts","devDependencies":{"@types/jest":"^29.2.5","@types/node":"^18.11.18","@typescript-eslint/eslint-plugin":"^5.48.1","@typescript-eslint/parser":"^5.48.1","eslint":"^8.31.0","jest":"^29.3.1","release-it":"^15.6.0","rimraf":"^3.0.2","sort-package-json":"^2.1.0","ts-jest":"^29.0.3","tsafe":"^1.4.1","typescript":"^4.9.4"},"publishConfig":{"access":"public"},"scripts":{"prebuild":"npm run lint && npm run clean","build":"tsc --build","clean":"rimraf ./dist","prelint":"npm run sort-package","lint":"eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.mts,.cts,.tsx --fix","sort-package":"sort-package-json","test":"jest","prewatch":"npm run clean","watch":"tsc --watch"},"bugs":{"url":"https://github.com/aarondill/never-throw/issues"},"homepage":"https://github.com/aarondill/never-throw#readme","_id":"@aarondill/never-throw@1.0.4","_integrity":"sha512-59kcEYueOO8C56cPdKdyUUi2yOqMDbes2BwloqJFqBFu2YURXRiGrKO+YWfJcB92ATo08imMO3YAdz7Oo9pKmg==","_resolved":"/tmp/d368041f2884b25101e72997443941ac/aarondill-never-throw-1.0.4.tgz","_from":"file:aarondill-never-throw-1.0.4.tgz","_nodeVersion":"18.14.0","_npmVersion":"9.4.2","dist":{"integrity":"sha512-59kcEYueOO8C56cPdKdyUUi2yOqMDbes2BwloqJFqBFu2YURXRiGrKO+YWfJcB92ATo08imMO3YAdz7Oo9pKmg==","shasum":"c2348d93e88152373d896dbab981899ce52f33b5","tarball":"https://registry.npmjs.org/@aarondill/never-throw/-/never-throw-1.0.4.tgz","fileCount":6,"unpackedSize":8158,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCrLx019aRP8m/4sBJpRbpo2GpEsPu4nlkgUSCXuej/BwIge6GyYvq9Lf/VgZvsSWpn6QOXPp6+BBnzg6Ir44pq6NU="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj5lvkACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpseQ//fQd3iIdecnmHzLtixaEcJUAtQ7jY3NOb+bQVoLNyfyjjZJLD\r\niAudYqv7v6UHZcavWYcFZoNk6v4idVDs8/6oO8OYDePgrXNZVVwOP/H8/P7c\r\nV8OkXYcjNNloxz05LxJVdoIklMJVU8djwd7qOih8N2poWRm5u5+liKGoGygk\r\nx6BekHttASyDfCXpteLQJ19nvzrLpcznx+POqwUVb1Jl/lH64M8t5Dzxa7in\r\nUVJdzvmprh0nkDG8cR7RtqCBk2WMZEn0llGdbYrJgXFVgjscklVwxMMQ+wuv\r\nvvSCIMkMPcpKX2gkuyWqW1KQeDEV6yNWEqnWHbEiAavAh6dFGV4y68A7PIyB\r\nofKuPiK/JEdawmLhuroqvYZba9RSeyi27I9RKARPgkea+s5Esi22d/2tgoYl\r\n2Ov3AQirKxMhpEoxH/ZLPvr2KCAj8dNBE5Mhy1/i7bVmLj6OcfoqqnaMiTO2\r\ntr85LECvDW7JMOkg/arbGa9fpU9BTzvdfy1b6B3ivLM0hjWt2QOZEkxnw7J8\r\nt7MVC2szThhcRrsONDrHZ2oapZMWIfZktbLyJ71zXLCtXht1oFBsZOpGOOtP\r\nIcmYJNx8zO2SwBNPimrIu8b6oFMla56FyrR99H32QjJJlKu2mQcmO9yg1odg\r\nC5YYdU+9KJVQYlicoJQrXLNH8rPEJKhsCzM=\r\n=7xNI\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"aarondill","email":"AaronDill309@gmail.com"},"directories":{},"maintainers":[{"name":"aarondill","email":"AaronDill309@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/never-throw_1.0.4_1676041188167_0.9570124021801623"},"_hasShrinkwrap":false}},"time":{"created":"2023-02-10T14:59:48.084Z","1.0.4":"2023-02-10T14:59:48.346Z","modified":"2023-02-10T14:59:48.486Z"},"maintainers":[{"name":"aarondill","email":"AaronDill309@gmail.com"}],"description":"Simplfy Error Handling","homepage":"https://github.com/aarondill/never-throw#readme","keywords":["try","catch","nothrow","never throw","type safe","safe"],"repository":{"type":"git","url":"git+https://github.com/aarondill/never-throw.git"},"author":{"name":"Aaron Dill"},"bugs":{"url":"https://github.com/aarondill/never-throw/issues"},"license":"MIT","readme":"# neverThrow.js\n\nSimplify error handling!\n\n## Usage:\n\nimport the named functions\n(The neverThrow function can also be imported through the default import):\n\n```javascript\nimport { neverThrow, neverThrowAsync } from \"@aarondill/never-throw\";\n```\n\nCall `foo` with error handling\n\n```js\nconst result = neverThrow(foo);\n\n// Pass arguments to foo:\nconst result = neverThrow(foo, 1, 2, 3);\n\n// Using an async function:\nconst result = await neverThrowAsync(bar, 1, 2, 3);\n//                   ^ Returns a promise\n```\n\nReturns an object with 'return' or 'error' depending on if the function threw.\nExample output:\n\n```js\nconsole.log(neverThrow(x=>x, \"Hello, world!\"));\n{\n    isErr: false,\n    return: \"Hello, world!\",\n    args: [\"Hello, world!\"],\n    function: x=>x,\n}\n```\n\nIf an error is thrown:\n\n```js\n// Throws a string!!\nconsole.log(neverThrow(function(x){throw x}, \"Hello, world!\"));\n{\n    isErr: true,\n    err: Error(\"Hello, world!\"),\n    args: [\"Hello, world!\"],\n    function: function(x){throw x},\n}\n```\n\n## Notes:\n\n- If no value is returned, 'return' will be `undefined`\n- `function` is the same function as was passed in\n- Any non-error value thrown will be converted to an error by `Error(String(thrownError))`\n- No mutation will be done on any value passed in.\n\n## Typescript\n\n### Exported Types:\n\n- BaseReturn - The return value, without 'err' or 'success' properties\n- Err - The object return when an error is thrown\n- Success - The object returned when no error is thrown\n- AwaitedSuccess - Success returned from `neverThrowAsync`, equivalent to Success\n- AwaitedErr - Error returned from `neverThrowAsync`, equivalent to Err\n\n### Note:\n\n```typescript\nif (result.isErr === true) result is Success\nelse result is Err\n```\n","readmeFilename":"README.md"}