{"name":"@isaacs/catcher","version":"1.0.1","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.1","gitHead":"f9c09b1a05148907bcedd00a15154a00d15903c9","_nodeVersion":"20.8.0","_npmVersion":"10.1.0","dist":{"integrity":"sha512-sNwND+XNOBj1mRFb3IhcppWmNVZOyoqFNl9t5T01oJoGWYDvj4164CTJOR+a/xSjxofC/2kz/PDyz0B7byg7fA==","shasum":"3e75764e6189883245d00fdd801d19eb1e97bb6e","tarball":"http://registry-npm.ywwl.com/@isaacs/catcher/download/@isaacs/catcher-1.0.1.tgz","fileCount":13,"unpackedSize":31145,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDwk71ThW1SSShUrX/GaCcU8FIxjniwIP4l5C5x/FySqwIgGNTSvl+ZRivOscMzXrtVW/2LniW7f7xiia2b1YpGxnw="}],"size":5436,"noattachment":false,"key":"/@isaacs/catcher/-/@isaacs/catcher-1.0.1.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.1_1698771328763_0.2449260522573724"},"_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":1698771329040,"_cnpm_publish_time":1698771329040,"dist-tags":{"latest":"1.0.4"}}