{"name":"@putout/plugin-try-catch","version":"5.0.0","keywords":["putout","putout-plugin","plugin","try-catch","try-to-catch"],"author":{"url":"https://github.com/coderaiser","name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"license":"MIT","_id":"@putout/plugin-try-catch@5.0.0","maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-try-catch#readme","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"tag":false,"dist":{"shasum":"4b3f537963cdd8a67d08892eadf17381c32bb2a5","tarball":"http://registry-npm.ywwl.com/@putout/plugin-try-catch/download/@putout/plugin-try-catch-5.0.0.tgz","fileCount":11,"integrity":"sha512-EEE0nfcoH6/TQi4Ffm4mjohHKmW4tOr3Mu+S4r4OEkm0VjHrwjp8ljkoWiCViQqhuKj+z6Xndj1wKQWQ5JNyyQ==","signatures":[{"sig":"MEYCIQCFHiWU1s9OGkrGbUlDBhuMQ49ulevDL+uIS9fXmnMNnwIhAJpvpLzFUmdFCyjmljuDtqk1PPgse/IViGggAyZlK85C","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11739,"size":3749,"noattachment":false,"key":"/@putout/plugin-try-catch/-/@putout/plugin-try-catch-5.0.0.tgz"},"main":"lib/index.js","type":"module","engines":{"node":">=20"},"gitHead":"774395853e5282b18963187d2de8d638a05221fa","release":false,"scripts":{"lint":"madrun lint","test":"madrun test","report":"madrun report","coverage":"madrun coverage","fix:lint":"madrun fix:lint","fresh:lint":"madrun fresh:lint","lint:fresh":"madrun lint:fresh","watch:test":"madrun watch:test"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"changelog":false,"repository":{"url":"git+https://github.com/coderaiser/putout.git","type":"git"},"_npmVersion":"11.1.0","description":"🐊Putout plugin adds ability to apply try-catch","directories":{},"_nodeVersion":"22.14.0","dependencies":{},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.0.0","eslint":"^9.0.0","madrun":"^11.0.0","nodemon":"^3.0.1","@putout/test":"^13.0.0","eslint-plugin-n":"^17.0.0","@putout/eslint-flat":"^3.0.0","eslint-plugin-putout":"^26.0.0"},"peerDependencies":{"putout":">=39"},"_npmOperationalInternal":{"tmp":"tmp/plugin-try-catch_5.0.0_1743025310803_0.987510516204887","host":"s3://npm-registry-packages-npm-production"},"readme":"# @putout/plugin-try-catch [![NPM version][NPMIMGURL]][NPMURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-try-catch.svg?style=flat&longCache=true\n[NPMURL]: https://npmjs.org/package/@putout/plugin-try-catch \"npm\"\n\n> The `try...catch` statement marks a `try` block and a `catch` block. If the code in the `try` block throws an exception then the code in the `catch` block will be executed.\n>\n> (c) MDN\n\n🐊[**Putout**](https://github.com/coderaiser/putout) plugin adds support of:\n\n- ✅ [try-catch](https://github.com/coderaiser/try-catch)\n- ✅ [try-to-catch](https://github.com/coderaiser/try-to-catch)\n\nWhich are drastically simplifies [`try...catch`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch) blocks.\n\n## Install\n\n```\nnpm i @putout/plugin-try-catch\n```\n\n## Rules\n\n- ✅ [apply-destructuring](#apply-destructuring);\n- ✅ [args](#args);\n- ✅ [async](#async);\n- ✅ [await](#await);\n- ✅ [declare](#declare);\n- ✅ [expand-args](#expand-args);\n- ✅ [sync](#sync);\n\n## Rule\n\n```json\n{\n    \"rules\": {\n        \"try-catch/await\": \"on\",\n        \"try-catch/args\": \"on\",\n        \"try-catch/apply-destructuring\": \"on\",\n        \"try-catch/declare\": \"on\",\n        \"try-catch/expand-args\": \"on\",\n        \"try-catch/sync\": \"on\",\n        \"try-catch/async\": \"on\"\n    }\n}\n```\n\n## apply-destructuring\n\nCheckout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/3356a8971b6ef8dcc7f35d09f0670576/6690425625bfa8df47db2e9afdd3e7490e15c6c0).\n\n### ❌ Example of incorrect code\n\n```js\nimport {tryCatch} from 'try-catch';\nimport {tryToCatch} from 'try-to-catch';\n```\n\n### ✅ Example of correct code\n\n```js\nimport {tryCatch} from 'try-catch';\nimport {tryToCatch} from 'try-to-catch';\n```\n\n## args\n\n### ❌ Example of incorrect code\n\n```js\ntryCatch(send('hello'));\n```\n\n### ✅ Example of correct code\n\n```js\ntryCatch(send, 'hello');\n```\n\n## async\n\n### ❌ Example of incorrect code\n\n```js\ntry {\n    await send('hello');\n} catch(error) {}\n```\n\n### ✅ Example of correct code\n\n```js\nimport {tryToCatch} from 'try-catch';\n\nconst [error] = await tryToCatch(send, 'hello');\n```\n\n## await\n\n### ❌ Example of incorrect code\n\n```js\nawait tryCatch(a, b);\ntryToCatch(a, b);\n```\n\n### ✅ Example of correct code\n\n```js\nawait tryToCatch(a, b);\n```\n\n## declare\n\n### ❌ Example of incorrect code\n\n```js\nconst [error] = tryCatch(fs.readFileSync, 'hello.txt');\n```\n\n### ✅ Example of correct code\n\n```js\nimport {tryCatch} from 'try-catch';\n\nconst [error] = tryCatch(fs.readFileSync, 'hello.txt');\n```\n\n## expand-args\n\n### ❌ Example of incorrect code\n\n```js\nimport {tryCatch} from 'try-catch';\n\ntest('some message', (t) => {\n    const fn = () => copymitter('/hello');\n    const [error] = tryCatch(fn);\n    \n    t.equal(error.message, 'to should be a string!');\n    t.end();\n});\n```\n\n### ✅ Example of correct code\n\n```js\nimport {tryCatch} from 'try-catch';\n\ntest('some message', (t) => {\n    const [error] = tryCatch(copymitter, '/hello');\n    \n    t.equal(error.message, 'to should be a string!');\n    t.end();\n});\n```\n\n## sync\n\n### ❌ Example of incorrect code\n\n```js\ntry {\n    log('hello');\n} catch(error) {}\n```\n\n### ✅ Example of correct code\n\n```js\nimport {tryCatch} from 'try-catch';\n\nconst [error] = tryCatch(log, 'hello');\n```\n\n## License\n\nMIT\n","publish_time":1743025311166,"_cnpm_publish_time":1743025311166,"dist-tags":{"latest":"8.2.0"}}