UNPKG

944 BMarkdownView Raw
1# babel-plugin-transform-exponentiation-operator
2
3> Compile exponentiation operator to ES5
4
5## Example
6
7```js
8// x ** y
9
10let squared = 2 ** 2;
11// same as: 2 * 2
12
13let cubed = 2 ** 3;
14// same as: 2 * 2 * 2
15
16
17// x **= y
18
19let a = 2;
20a **= 2;
21// same as: a = a * a;
22
23let b = 3;
24b **= 3;
25// same as: b = b * b * b;
26```
27
28## Installation
29
30```sh
31npm install --save-dev babel-plugin-transform-exponentiation-operator
32```
33
34## Usage
35
36### Via `.babelrc` (Recommended)
37
38**.babelrc**
39
40```json
41{
42 "plugins": ["transform-exponentiation-operator"]
43}
44```
45
46### Via CLI
47
48```sh
49babel --plugins transform-exponentiation-operator script.js
50```
51
52### Via Node API
53
54```javascript
55require("babel-core").transform("code", {
56 plugins: ["transform-exponentiation-operator"]
57});
58```
59
60## References
61
62* [Proposal: Exponentiation Operator](https://github.com/rwaldron/exponentiation-operator)
63* [Spec: Exponential Operator](https://rwaldron.github.io/exponentiation-operator/)