This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const minifyCSS = (css) => css.replace(/\n/g, '').replace(/\s\s+/g, ' ') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* author: Dan Abromov | |
*/ | |
const { Component, createElement } = require('react') | |
const storeShape = require('../utils/storeShape') | |
const shallowEqual = require('../utils/shallowEqual') | |
const wrapActionCreators = require('../utils/wrapActionCreators') | |
const isPlainObject = require('lodash/isPlainObject') | |
const hoistStatics = require('hoist-non-react-statics') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setInterval(function gameloop() { | |
update(); | |
render(); | |
}, 30); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
entry: "./src/index.tsx", | |
output: { | |
filename: "bundle.js" | |
}, | |
resolve: { | |
// Add '.ts' and '.tsx' as a resolvable extension. | |
extensions: ["", ".webpack.js", ".web.js", ".ts", ".tsx", ".js"] | |
}, | |
module: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function *gen() { | |
var f1 = 0; | |
var f2 = 1; | |
yield f1; | |
yield f2; | |
while (true) { | |
yield f1 + f2; | |
[f1, f2] = [f2, f1 + f2]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var login = async(function* (username, password, session) { | |
var user = yield getUser(username); | |
var hash = yield crypto.hashAsync(password + user.salt); | |
if (user.hash !== hash) { | |
throw new Error('Incorrect password'); | |
} | |
session.setUser(user); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function addTwoResult(a, b) { | |
var first = await resolveAfter2Seconds(a); | |
var second = await resolveAfter2Seconds(b); | |
return first + second; | |
} | |
// is equivalent to | |
function *addTwoResult(a, b) { | |
var first = yield resolveAfter2Seconds(a); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function *count() { | |
var x = 1; | |
while (true) { | |
yield x++; | |
} | |
} | |
var gen = count() | |
// you could infinitely call gen.next() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function *makeGenerator() { | |
yield 1; | |
yield 3; | |
yield 5; | |
} | |
var gen = makeGenerator(); | |
gen.next() // { done: false, value: 1 } | |
gen.next() // { done: false, value: 3 } | |
gen.next() // { done: false, value: 5 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function resolveAfter2Seconds(x) { | |
return new Promise(resolve => { | |
setTimeout(() => { | |
resolve(x); | |
}, 2000); | |
}); | |
} | |
async function addTwoResult(a, b) { | |
var first = await resolveAfter2Seconds(a); | |
var second = await resolveAfter2Seconds(b); |