Update ES6

This commit is contained in:
Rico Sta. Cruz 2017-08-28 00:01:37 +08:00
parent 64898b046e
commit 4160473ff7
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
2 changed files with 26 additions and 21 deletions

View File

@ -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

36
es6.md
View File

@ -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,19 +281,18 @@ 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 () { ```
}
```js
export const pi = 3.14159
// aka: module.exports.pi = ··· // aka: module.exports.pi = ···
export var pi = 3.14159
``` ```
`export` is the new `module.exports`. `export` is the new `module.exports`.
@ -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++ }
} }