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

43 lines
610 B
Markdown

# babel-plugin-syntax-throw-expressions
Allow parsing of Throw Expressions:
```js
function test(param = throw new Error('required!')) {
const test = param === true || throw new Error('Falsey!');
}
```
## Installation
```sh
npm install --save-dev babel-plugin-syntax-throw-expressions
```
## Usage
### Via `.babelrc` (Recommended)
**.babelrc**
```json
{
"plugins": ["syntax-throw-expressions"]
}
```
### Via CLI
```sh
babel --plugins syntax-throw-expressions script.js
```
### Via Node API
```javascript
require("babel-core").transform("code", {
plugins: ["syntax-throw-expressions"]
});
```