{"id":16490539,"url":"https://github.com/dave-wind/babel-await-add-catch","last_synced_at":"2025-04-06T14:26:19.952Z","repository":{"id":174889505,"uuid":"459135259","full_name":"dave-wind/babel-await-add-catch","owner":"dave-wind","description":"babel-plugin ast async await try-catch","archived":false,"fork":false,"pushed_at":"2022-02-16T08:55:10.000Z","size":41,"stargazers_count":4,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-02-12T20:33:59.607Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dave-wind.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-14T11:31:02.000Z","updated_at":"2022-11-01T05:44:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"79cbf5f3-0ed2-4706-b399-1cd0e412bdd9","html_url":"https://github.com/dave-wind/babel-await-add-catch","commit_stats":null,"previous_names":["dave-wind/babel-await-add-catch"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dave-wind%2Fbabel-await-add-catch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dave-wind%2Fbabel-await-add-catch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dave-wind%2Fbabel-await-add-catch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dave-wind%2Fbabel-await-add-catch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dave-wind","download_url":"https://codeload.github.com/dave-wind/babel-await-add-catch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247494220,"owners_count":20947840,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T13:48:21.507Z","updated_at":"2025-04-06T14:26:19.910Z","avatar_url":"https://github.com/dave-wind.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Babel-Await-Add-Catch\n\u003e Babel plugin helps automatically add try catch and console when encountering await\n\n#### Install\n```js\n npm install babel-await-add-catch --D\n```\n\n#### Use\n```js\nVia .babelrc.js or babel.config.js or babel-loader:\n\n{\n  \"plugins\": [[\"babel-await-add-catch\", options]]\n}\n\n\nbabel.config.js:\n\nmodule.exports = {\n    \"plugins\": [\n        [\n            require('babel-await-add-catch'),\n            {\n                \"exclude\": ['exclude'],\n                \"include\": ['index','index2'],\n                \"customLog\": 'My name is Dave Jones'\n            }\n        ]\n    ]\n};\n\n```\n\n#### options\n\u003e options need to be an object.\n```js\n{\n    \"exclude\": [], // default: [\"node_modules\"]  // 不被编译的文件\n     \"include\": [], // babel 编译 需要的 js文件\n     \"customLog\": '' // default： \"catch error---\"  // 自定义log string \n}\n```\n\n#### Example\n\u003e From\n```js\nconst demo = async () =\u003e {\n    var dddd = 2;\n    var b = await handlePromise();\n    return dddd + b;\n}\n```\n\u003e To\n```js\nconst demo = async () =\u003e {\n  var $_b;\n  var dddd = 2;\n\n  try {\n    $_b = await handlePromise();\n  } catch (e) {\n    console.log(\"handlePromise catch error---\", e);\n  }\n\n  return dddd + $_b;\n};\n\n```\n#### 实现思路 \n\u003e 见 issues\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdave-wind%2Fbabel-await-add-catch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdave-wind%2Fbabel-await-add-catch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdave-wind%2Fbabel-await-add-catch/lists"}