No mention of reduce...
Object.keys(obj)
.map(k => foo(k, obj[k]))
.reduce((a, b) => Object.assign(a, b), {});
that's one of my favorites... break up an object/hash map, do something to each, and reconstruct hash map... assuming `foo(k, v)` returns `{ [k]: bar(v) }`;
map is cool and powerful, but so is reduce.
I know... I work with Windows, Linux and Mac on a daily basis. I was just pointing it out in context as to why that was chosen. It *could* also be thought of as the *home* for the application itself.
I even mentioned that node specifically doesn't do anything with tilde in the fs or path modules, even in a unixy environment.
I'm relatively sure the author has exposure to .Net as the tilde is used as project root the too. It doesn't work out autosub for profile/home in node currently in any of the path or FS modules.
TFA's example doesn't work for server-side fetching, and kind of dismisses the issue... the reality is that one should use methods that work for both, if you're going to have universal rendering, so you don't have weird complicated code to do the same thing in two places.
Two things I always try to enforce in code reviews are the use of map/reduce instead of for-loops when practical, and returning early from functions...
// instead of
fn() {
if (foo) {
//really long code block
} else {
//really short code block
}
}
// this
fn() {
if (!foo) {
// really short code block
return ...;
}
// less nested code case
}
It tends to happen a lot, and the function becomes much more clear when you can get out of it asap instead of deep nested blocks.
Interesting, though would be nice if it were a keyboard character used... it always irks me when frameworks choose an obscure character for things like this.
Glad to see extensible end points for webpack, babel (pending) will also be pretty nice. It's a minor niggle, because there are an ever decreasing number of features outside stage-3 that I'm using.
No mention of reduce... Object.keys(obj) .map(k => foo(k, obj[k])) .reduce((a, b) => Object.assign(a, b), {}); that's one of my favorites... break up an object/hash map, do something to each, and reconstruct hash map... assuming `foo(k, v)` returns `{ [k]: bar(v) }`; map is cool and powerful, but so is reduce.Two things I always try to enforce in code reviews are the use of map/reduce instead of for-loops when practical, and returning early from functions... // instead of fn() { if (foo) { //really long code block } else { //really short code block } } // this fn() { if (!foo) { // really short code block return ...; } // less nested code case } It tends to happen a lot, and the function becomes much more clear when you can get out of it asap instead of deep nested blocks.