{"name":"@putout/plugin-try-catch","version":"4.0.0","type":"commonjs","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"🐊Putout plugin adds ability to apply try-catch","homepage":"https://github.com/coderaiser/putout/tree/master/packages/plugin-try-catch#readme","main":"lib/index.js","release":false,"tag":false,"changelog":false,"repository":{"type":"git","url":"git://github.com/coderaiser/putout.git"},"scripts":{"test":"madrun test","watch:test":"madrun watch:test","lint":"madrun lint","fresh:lint":"madrun fresh:lint","lint:fresh":"madrun lint:fresh","fix:lint":"madrun fix:lint","coverage":"madrun coverage","report":"madrun report"},"dependencies":{},"keywords":["putout","putout-plugin","plugin","try-catch","try-to-catch"],"devDependencies":{"@putout/test":"^11.0.0","c8":"^10.0.0","eslint":"^9.0.0","eslint-plugin-n":"^17.0.0","eslint-plugin-putout":"^22.0.0","lerna":"^6.0.1","madrun":"^10.0.0","nodemon":"^3.0.1"},"peerDependencies":{"putout":">=36"},"license":"MIT","engines":{"node":">=16"},"publishConfig":{"access":"public"},"_id":"@putout/plugin-try-catch@4.0.0","gitHead":"1634b7d6b69b1f2632c6b24199c4dba9e4fa5146","bugs":{"url":"https://github.com/coderaiser/putout/issues"},"_nodeVersion":"20.16.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-ucJ0Qo8imalzjHsW/TmiEo//gqA/J6kEQbLY6nRlLsD/GeK9GehtMRwJCmTHgofsjXWUTDL5q6b8Xq3c3X4D/g==","shasum":"27f111ebfc1e632091ac7d4d3d7da91f07eb7bfb","tarball":"http://registry-npm.ywwl.com/@putout/plugin-try-catch/download/@putout/plugin-try-catch-4.0.0.tgz","fileCount":11,"unpackedSize":11680,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD35YfC1GzZ3kZmMucZpCxGiAsirMPiOiK+L7AP9KqRsgIgCf3inAR5NGOjSWYI/IrDvdDDtJj4V32Tm8JAsv8Rokg="}],"size":3705,"noattachment":false,"key":"/@putout/plugin-try-catch/-/@putout/plugin-try-catch-4.0.0.tgz"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/plugin-try-catch_4.0.0_1724223684769_0.5474229133310013"},"_hasShrinkwrap":false,"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## Rule\n\n```json\n{\n    \"rules\": {\n        \"try-catch/await\": \"on\",\n        \"try-catch/args\": \"on\",\n        \"try-catch/declare\": \"on\",\n        \"try-catch/expand-arguments\": \"on\",\n        \"try-catch/sync\": \"on\",\n        \"try-catch/async\": \"on\"\n    }\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## 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## 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## 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-arguments\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## License\n\nMIT\n","publish_time":1724223684930,"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"_cnpm_publish_time":1724223684930,"dist-tags":{"latest":"8.2.0"}}