start new:
tmux
start new with session name:
tmux new -s myname
let slice = Array.prototype.slice; | |
let str = s => slice.call(s) | |
let unstr = cs => cs.reduce((c, cs) => c + cs, "") | |
let concat = xss => xss.reduce((xs, ys) => xs.concat(ys), []) | |
let id = x => x | |
let negate = x => -x | |
let add = (x,y) => x + y | |
let sub = (x,y) => x - y | |
// type Parser a = () -> [Char] -> a |
/* jshint esnext:true */ | |
/** | |
* "Producer-Consumer" implementation using generators. | |
* @see http://en.wikipedia.org/wiki/Deterministic_concurrency#Comparison_with_generators | |
*/ | |
var SIZE = 3, | |
queue = newQueue(); |
// array utils | |
// ================================================================================================= | |
const combine = (...arrays) => [].concat(...arrays); | |
const compact = arr => arr.filter(Boolean); | |
const contains = (() => Array.prototype.includes | |
? (arr, value) => arr.includes(value) | |
: (arr, value) => arr.some(el => el === value) |
@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).
Here we go with the explanations:
(function(x, f = () => x) {
/* jshint esnext:true */ | |
// native generators | |
function* random() { | |
var i = 0; | |
while(i++ < 1e5) { | |
yield Math.random(); | |
} | |
} |
const loop = (() => { | |
const recur = (callback, count, i=0) => { | |
if (i == count-1) return callback(i); | |
callback(i); | |
return recur(callback, count, i+1); | |
}; | |
return (callback, count) => { | |
if (count > 0) return recur(callback, count); | |
}; | |
})(); |
Many languages support "expression-only" semantics, allowing to use any construct in an expression position.
NOTE: the difference between expressions and statements is that the former produce a value, while the later don't.
For example, Ruby's if
-expression:
x = 10
In React universal application, there is problem when render client-side only components like Devtools, fetching components and webpack style require (require css) Two solution for this.
check js is running on browser
use webpack also on serverside, or if you are using requirejs, you can map client modules to null
But serverside build look like overkill to me, I choose dynamic module import. However in es6, import doesn't support dynamic import. So you should use commonjs require for it.
Doing require extensions correctly is essential, because:
nyc
need it to reliably supply coverage information that takes into account sourcemaps from upstream transforms.