2017-10-16 22:49:56 -04:00

757 B

babel-plugin-transform-throw-expressions

This plugin transforms Throw Expressions into an IIFE.

Example

function test(param = throw new Error('required!')) {
  const test = param === true || throw new Error('Falsey!');
}

Installation

npm install --save-dev babel-plugin-transform-throw-expressions

Usage

.babelrc

{
  "plugins": ["transform-throw-expressions"]
}

Via CLI

babel --plugins transform-throw-expressions script.js

Via Node API

require("@babel/core").transform("code", {
  plugins: ["transform-throw-expressions"]
});

References