Update ES6
This commit is contained in:
parent
64898b046e
commit
4160473ff7
|
@ -32,10 +32,11 @@
|
||||||
|
|
||||||
// Line highlight
|
// Line highlight
|
||||||
.line-highlight {
|
.line-highlight {
|
||||||
|
transform: translate3d(0, 1px, 0);
|
||||||
background: linear-gradient(
|
background: linear-gradient(
|
||||||
to right,
|
to right,
|
||||||
rgba($base-b, 0.05) 75%,
|
rgba($base-c, 0.05) 25%,
|
||||||
rgba($base-b, 0));
|
rgba($base-c, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Line highlight ranges
|
// Line highlight ranges
|
||||||
|
|
42
es6.md
42
es6.md
|
@ -131,7 +131,7 @@ function greet({ name, greeting }) {
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
greet({ name: "Larry", greeting: "Ahoy" })
|
greet({ name: 'Larry', greeting: 'Ahoy' })
|
||||||
```
|
```
|
||||||
|
|
||||||
Supports for matching arrays and objects.
|
Supports for matching arrays and objects.
|
||||||
|
@ -159,7 +159,7 @@ function fn(x, ...y) {
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// Spread
|
// Spread
|
||||||
fn(...[1,2,3]) // same as fn(1,2,3)
|
fn(...[1, 2, 3]) // same as fn(1, 2, 3)
|
||||||
```
|
```
|
||||||
|
|
||||||
Default, rest, spread.
|
Default, rest, spread.
|
||||||
|
@ -197,7 +197,7 @@ Objects
|
||||||
|
|
||||||
```js
|
```js
|
||||||
module.exports = { hello, bye }
|
module.exports = { hello, bye }
|
||||||
// Same as `module.exports = { hello: hello, bye: bye }`
|
// Same as: module.exports = { hello: hello, bye: bye }
|
||||||
```
|
```
|
||||||
|
|
||||||
See: [Object literal enhancements](http://babeljs.io/docs/learn-es2015/#enhanced-object-literals)
|
See: [Object literal enhancements](http://babeljs.io/docs/learn-es2015/#enhanced-object-literals)
|
||||||
|
@ -210,7 +210,7 @@ const App = {
|
||||||
console.log('running')
|
console.log('running')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Same as `App = { start: function () {···} }`
|
// Same as: App = { start: function () {···} }
|
||||||
```
|
```
|
||||||
{: data-line="2"}
|
{: data-line="2"}
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ let event = 'click'
|
||||||
let handlers = {
|
let handlers = {
|
||||||
['on' + event]: true
|
['on' + event]: true
|
||||||
}
|
}
|
||||||
// Same as `handlers = { 'onclick': true }`
|
// Same as: handlers = { 'onclick': true }
|
||||||
```
|
```
|
||||||
{: data-line="3"}
|
{: data-line="3"}
|
||||||
|
|
||||||
|
@ -251,23 +251,28 @@ Modules
|
||||||
### Imports
|
### Imports
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// aka: require('···')
|
|
||||||
import 'helpers'
|
import 'helpers'
|
||||||
|
// aka: require('···')
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// aka: Express = require('···').default || require('···')
|
|
||||||
import Express from 'express'
|
import Express from 'express'
|
||||||
|
// aka: Express = require('···').default || require('···')
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// aka: indent = require('···').indent
|
|
||||||
import { indent } from 'helpers'
|
import { indent } from 'helpers'
|
||||||
|
// aka: indent = require('···').indent
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
import * as Helpers from 'helpers'
|
||||||
|
// aka: Helpers = require('···')
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// aka: indent = require('···').indentSpaces
|
|
||||||
import { indentSpaces as indent } from 'helpers'
|
import { indentSpaces as indent } from 'helpers'
|
||||||
|
// aka: indent = require('···').indentSpaces
|
||||||
```
|
```
|
||||||
|
|
||||||
`import` is the new `require()`.
|
`import` is the new `require()`.
|
||||||
|
@ -276,22 +281,21 @@ See: [Module imports](http://babeljs.io/docs/learn-es2015/#modules)
|
||||||
### Exports
|
### Exports
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
export default function () { ··· }
|
||||||
// aka: module.exports.default = ···
|
// aka: module.exports.default = ···
|
||||||
export default function () {
|
|
||||||
// ···
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
export function mymethod () { ··· }
|
||||||
// aka: module.exports.mymethod = ···
|
// aka: module.exports.mymethod = ···
|
||||||
export function mymethod () {
|
|
||||||
}
|
|
||||||
|
|
||||||
// aka: module.exports.pi = ···
|
|
||||||
export var pi = 3.14159
|
|
||||||
```
|
```
|
||||||
|
|
||||||
`export` is the new `module.exports`.
|
```js
|
||||||
|
export const pi = 3.14159
|
||||||
|
// aka: module.exports.pi = ···
|
||||||
|
```
|
||||||
|
|
||||||
|
`export` is the new `module.exports`.
|
||||||
See: [Module exports](http://babeljs.io/docs/learn-es2015/#modules)
|
See: [Module exports](http://babeljs.io/docs/learn-es2015/#modules)
|
||||||
|
|
||||||
Generators
|
Generators
|
||||||
|
@ -300,7 +304,7 @@ Generators
|
||||||
### Generators
|
### Generators
|
||||||
|
|
||||||
```js
|
```js
|
||||||
function* idMaker() {
|
function* idMaker () {
|
||||||
var id = 0
|
var id = 0
|
||||||
while (true) { yield id++ }
|
while (true) { yield id++ }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue