1 |
3a515b92
|
cagy
|
# babel-plugin-transform-es2015-literals
|
2 |
|
|
|
3 |
|
|
> Compile ES2015 unicode string and number literals to ES5
|
4 |
|
|
|
5 |
|
|
## Example
|
6 |
|
|
|
7 |
|
|
**In**
|
8 |
|
|
|
9 |
|
|
```js
|
10 |
|
|
var b = 0b11; // binary integer literal
|
11 |
|
|
var o = 0o7; // octal integer literal
|
12 |
|
|
const u = 'Hello\u{000A}\u{0009}!'; // unicode string literals, newline and tab
|
13 |
|
|
```
|
14 |
|
|
|
15 |
|
|
**Out**
|
16 |
|
|
|
17 |
|
|
```js
|
18 |
|
|
var b = 3; // binary integer literal
|
19 |
|
|
var o = 7; // octal integer literal
|
20 |
|
|
const u = 'Hello\n\t!'; // unicode string literals, newline and tab
|
21 |
|
|
```
|
22 |
|
|
|
23 |
|
|
## Installation
|
24 |
|
|
|
25 |
|
|
```sh
|
26 |
|
|
npm install --save-dev babel-plugin-transform-es2015-literals
|
27 |
|
|
```
|
28 |
|
|
|
29 |
|
|
## Usage
|
30 |
|
|
|
31 |
|
|
### Via `.babelrc` (Recommended)
|
32 |
|
|
|
33 |
|
|
**.babelrc**
|
34 |
|
|
|
35 |
|
|
```json
|
36 |
|
|
{
|
37 |
|
|
"plugins": ["transform-es2015-literals"]
|
38 |
|
|
}
|
39 |
|
|
```
|
40 |
|
|
|
41 |
|
|
### Via CLI
|
42 |
|
|
|
43 |
|
|
```sh
|
44 |
|
|
babel --plugins transform-es2015-literals script.js
|
45 |
|
|
```
|
46 |
|
|
|
47 |
|
|
### Via Node API
|
48 |
|
|
|
49 |
|
|
```javascript
|
50 |
|
|
require("babel-core").transform("code", {
|
51 |
|
|
plugins: ["transform-es2015-literals"]
|
52 |
|
|
});
|
53 |
|
|
```
|