1 |
3a515b92
|
cagy
|
# babel-plugin-transform-es2015-parameters
|
2 |
|
|
|
3 |
|
|
> Compile ES2015 default and rest parameters to ES5
|
4 |
|
|
|
5 |
|
|
This plugin transforms ES2015 parameters to ES5, this includes:
|
6 |
|
|
|
7 |
|
|
- Destructuring parameters
|
8 |
|
|
- Default parameters
|
9 |
|
|
- Rest parameters
|
10 |
|
|
|
11 |
|
|
## Installation
|
12 |
|
|
|
13 |
|
|
```sh
|
14 |
|
|
npm install --save-dev babel-plugin-transform-es2015-parameters
|
15 |
|
|
```
|
16 |
|
|
|
17 |
|
|
## Caveats
|
18 |
|
|
|
19 |
|
|
Default parameters desugar into `let` declarations to retain proper semantics. If this is
|
20 |
|
|
not supported in your environment then you'll need the
|
21 |
|
|
[transform-block-scoping](http://babeljs.io/docs/plugins/transform-es2015-block-scoping) plugin.
|
22 |
|
|
|
23 |
|
|
## Usage
|
24 |
|
|
|
25 |
|
|
### Via `.babelrc` (Recommended)
|
26 |
|
|
|
27 |
|
|
**.babelrc**
|
28 |
|
|
|
29 |
|
|
```json
|
30 |
|
|
{
|
31 |
|
|
"plugins": ["transform-es2015-parameters"]
|
32 |
|
|
}
|
33 |
|
|
```
|
34 |
|
|
|
35 |
|
|
### Via CLI
|
36 |
|
|
|
37 |
|
|
```sh
|
38 |
|
|
babel --plugins transform-es2015-parameters script.js
|
39 |
|
|
```
|
40 |
|
|
|
41 |
|
|
### Via Node API
|
42 |
|
|
|
43 |
|
|
```javascript
|
44 |
|
|
require("babel-core").transform("code", {
|
45 |
|
|
plugins: ["transform-es2015-parameters"]
|
46 |
|
|
});
|
47 |
|
|
```
|