{"name":"@isaacs/catcher","version":"1.0.0","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.0","gitHead":"1ff19aa73146fb27c39aec47520b6e0be0604194","_nodeVersion":"20.8.0","_npmVersion":"10.1.0","dist":{"integrity":"sha512-EkPCg6VcThEepegfWel1cA9WdN4Km4EE+ZuyZRlnHN40aZvbdB1g/WeB6i/PnMzaJchJ8HPuL0pTi7mHhdCYTA==","shasum":"ffcd2d340428d768185edc337b8b05329bb2df14","tarball":"http://registry-npm.ywwl.com/@isaacs/catcher/download/@isaacs/catcher-1.0.0.tgz","fileCount":13,"unpackedSize":29843,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC+4x6wdryaqFeNj2IQWGNAr3oj+aCUSkffMyONqYihsAIgLK0bLoQWp4vwQd2eBwlJP+GbdPBdsbw98fmJtMM945s="}],"size":4786,"noattachment":false,"key":"/@isaacs/catcher/-/@isaacs/catcher-1.0.0.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.0_1698701443267_0.3168542803609591"},"_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":1698701443523,"_cnpm_publish_time":1698701443523,"dist-tags":{"latest":"1.0.4"}}