{"name":"@isaacs/catcher","version":"1.0.4","description":"Call a function and catch any errors it throws","license":"BlueOak-1.0.0","type":"module","scripts":{"preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","prepare":"tshy","pretest":"npm run prepare","presnap":"npm run prepare","test":"tap","snap":"tap","format":"prettier --write . --loglevel warn --cache","typedoc":"typedoc"},"prettier":{"semi":false,"printWidth":70,"tabWidth":2,"useTabs":false,"singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"arrowParens":"avoid","endOfLine":"lf"},"devDependencies":{"prettier":"^2.8.8","tap":"^18.5.3","tshy":"^1.7.0","typedoc":"^0.25.3"},"tshy":{"exports":{"./package.json":"./package.json",".":"./src/index.ts"}},"exports":{"./package.json":"./package.json",".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}}},"main":"./dist/commonjs/index.js","types":"./dist/commonjs/index.d.ts","_id":"@isaacs/catcher@1.0.4","gitHead":"99603baaec9e0f06b604269d910734a0216493ab","_nodeVersion":"20.8.0","_npmVersion":"10.1.0","dist":{"integrity":"sha512-g2klMwbnguClWNnCeQ1zYaDJsvPbIbnjdJPDE0z09MqoejJDZSLK5vIKiClq2Bkg5ubuI8vaN6wfIUi5GYzMVA==","shasum":"fa5aa6fa43d255b9fe32e1e1f40db6623de2c80d","tarball":"http://registry-npm.ywwl.com/@isaacs/catcher/download/@isaacs/catcher-1.0.4.tgz","fileCount":13,"unpackedSize":57614,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIH4Xf5XWXFhvbFJAsnn+DsMIdFiwoGPycSgiG80E2pNRAiAqz++ZGWEb9nT3P05NIM+iuEZJznkHs/5eQbD78W+8vA=="}],"size":6139,"noattachment":false,"key":"/@isaacs/catcher/-/@isaacs/catcher-1.0.4.tgz"},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"directories":{},"maintainers":[{"name":"isaacs","email":"i@izs.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/catcher_1.0.4_1699067258668_0.802872420609541"},"_hasShrinkwrap":false,"readme":"# @isaacs/catcher\n\nCall a function and return a fallback value or undefined if it throws.\n\nCuts out the performance overhead of creating a stack trace, for\ncases where it won't be used anyway.\n\n## USAGE\n\n```js\nimport { catcher, catchWrap } from '@isaacs/catcher'\nimport { functionThatMightThrow } from 'some-module'\n\nconst resultOrUndefined = catcher(functionThatMightThrow)\nconst resultOr99 = catcher(functionThatMightThrow, 99)\n\nconst functionThatDoesNotThrow = catchWrap(functionThatMightThrow)\n// this returns undefined rather than throwing\nconst resultOrUndefined = functionThatDoesNotThrow(123)\n\nconst return99onFailure = catchWrap(functionThatMightThrow, 99)\nconst resultOr99 = return99onFailure(234)\n```\n\nProperly supports types for the returned function if the function\nbeing wrapped has up to 10 overload signatures, adding the type\nof the `caughtValue` (or undefined if not provided) to the return\ntype of each signature. For example:\n\n```ts\nfunction x(): boolean\nfunction x(s: string): string\nfunction x(s?: string) {\n  if (typeof s === 'undefined') return true\n  else if (typeof s === 'string') return s\n  else throw new Error('not a string or undefined')\n}\n\nconst wrapped = catchWrap(x, 99)\nconst b = wrapped()\n//    ^? - boolean | 99\nconst z = wrapped('y')\n//    ^? - string | 99\n```\n\nSee [the typedocs](https://isaacs.github.io/catcher) for detailed\nAPI info.\n","publish_time":1699067258839,"_cnpm_publish_time":1699067258839,"dist-tags":{"latest":"1.0.4"}}