{"_id":"@isaacs/catcher","_rev":"1760178","name":"@isaacs/catcher","description":"Call a function and catch any errors it throws","dist-tags":{"latest":"1.0.4"},"maintainers":[{"name":"isaacs","email":"i@izs.me"}],"time":{"modified":"2026-11-23T18:59:31.000Z","created":"2023-10-30T21:30:43.523Z","1.0.4":"2023-11-04T03:07:38.839Z","1.0.3":"2023-10-31T20:32:39.377Z","1.0.2":"2023-10-31T17:22:24.536Z","1.0.1":"2023-10-31T16:55:29.040Z","1.0.0":"2023-10-30T21:30:43.523Z"},"users":{},"versions":{"1.0.4":{"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,"publish_time":1699067258839,"_cnpm_publish_time":1699067258839},"1.0.3":{"name":"@isaacs/catcher","version":"1.0.3","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.3","gitHead":"b0fcdff400b2cc4f763f241a3487253629f844a7","_nodeVersion":"20.8.0","_npmVersion":"10.1.0","dist":{"integrity":"sha512-+PQ8rDYeq2DithkWmsBf+uF4d8ckaQDBTnqLwjI9D4iEg4pUFppnXvjx4jOZ5xvdc4Dv2b3S5gkgxyjnMRiDMQ==","shasum":"f5901d1613df9ce72d8c87d37d63e02785ed6352","tarball":"http://registry-npm.ywwl.com/@isaacs/catcher/download/@isaacs/catcher-1.0.3.tgz","fileCount":13,"unpackedSize":33304,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIE+TL4HprZYWYAlD88zd3GjR00aFq4Wcbk3jfYy6FZN2AiAHcDXt9fkFaml7LWTRn55Ta2yTA/IXMsEDLtteC1dr1A=="}],"size":5626,"noattachment":false,"key":"/@isaacs/catcher/-/@isaacs/catcher-1.0.3.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.3_1698784359159_0.7773344732335525"},"_hasShrinkwrap":false,"publish_time":1698784359377,"_cnpm_publish_time":1698784359377},"1.0.2":{"name":"@isaacs/catcher","version":"1.0.2","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.2","gitHead":"b1307f63d7186c0dce316e704fd3d380dbd24d61","_nodeVersion":"20.8.0","_npmVersion":"10.1.0","dist":{"integrity":"sha512-KOw4ri4ALrX+y/1NHqEw5AUVkDKswddNdPOzHr2vXKUtDv3MH5DLj/BJ7+GYgTA6rEETdMoT90N9bicALMtM8A==","shasum":"2c4fb79d893da416003f66739aca06b14c9697ac","tarball":"http://registry-npm.ywwl.com/@isaacs/catcher/download/@isaacs/catcher-1.0.2.tgz","fileCount":13,"unpackedSize":33303,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBdEJ1mSFnFGiAF97Rf8MIEzJwjjrYJVGZxO1XARHS4uAiAy2R1tlmaUssz/bSwx0+mF+4DyidCgHnhc0VJ9Fufxpw=="}],"size":5632,"noattachment":false,"key":"/@isaacs/catcher/-/@isaacs/catcher-1.0.2.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.2_1698772944325_0.28522882949706196"},"_hasShrinkwrap":false,"publish_time":1698772944536,"_cnpm_publish_time":1698772944536},"1.0.1":{"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,"publish_time":1698771329040,"_cnpm_publish_time":1698771329040},"1.0.0":{"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,"publish_time":1698701443523,"_cnpm_publish_time":1698701443523}},"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","_attachments":{},"license":"BlueOak-1.0.0"}