babel/packages/babel-plugin-transform-throw-expressions
Justin Ridgewell 23f98a753a Add throw expressions (#6325)
* Add throw expressions

Stage 2 proposal: https://github.com/tc39/proposal-throw-expressions

* Update babylon

* Add to stage 2
2017-09-27 16:15:44 -04:00
..
2017-09-27 16:15:44 -04:00
2017-09-27 16:15:44 -04:00
2017-09-27 16:15:44 -04:00
2017-09-27 16:15:44 -04:00
2017-09-27 16:15:44 -04:00

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