1.0.5 • Published 3 years ago

babel-plugin-catch v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

babel-plugin-catch

Add trycatch to your magic comment

Installlation

npm install babel-plugin-catch or yarn add babel-plugin-catch

Usage

  const test = (num/* catch */) => {

  }
  class Test{
    test(num, num2/* catch */){

    }

    test = (num, num2/* catch */) => {

    }
  }

.babelrc

{
  "plugins": [
    ["babel-plugin-catch", {
      comment?: 'catch',
      catchCode?: (e) => {

      },
      finallyCode?: () =>{

      }
    }]
  ]
}

Via CLI

$ babel --plugins babel-plugin-catch script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["babel-plugin-catch"]
});