1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
| # babel-plugin-transform-es2015-shorthand-properties
|
| > Compile ES2015 shorthand properties to ES5
|
| ## Example
|
| **In**
|
| ```js
| var o = { a, b, c };
| ```
|
| **Out**
|
| ```js
| var o = { a: a, b: b, c: c };
| ```
|
| **In**
|
| ```js
| var cat = {
| getName() {
| return name;
| }
| };
| ```
|
| **Out**
|
| ```js
| var cat = {
| getName: function () {
| return name;
| }
| };
| ```
|
| ## Installation
|
| ```sh
| npm install --save-dev babel-plugin-transform-es2015-shorthand-properties
| ```
|
| ## Usage
|
| ### Via `.babelrc` (Recommended)
|
| **.babelrc**
|
| ```json
| {
| "plugins": ["transform-es2015-shorthand-properties"]
| }
| ```
|
| ### Via CLI
|
| ```sh
| babel --plugins transform-es2015-shorthand-properties script.js
| ```
|
| ### Via Node API
|
| ```javascript
| require("babel-core").transform("code", {
| plugins: ["transform-es2015-shorthand-properties"]
| });
| ```
|
|