Skip to content

Instantly share code, notes, and snippets.

@lxe
Created October 22, 2014 23:26
Show Gist options
  • Select an option

  • Save lxe/1eb495fb5ea9dd0e63b7 to your computer and use it in GitHub Desktop.

Select an option

Save lxe/1eb495fb5ea9dd0e63b7 to your computer and use it in GitHub Desktop.
//
// This: (2 spaces, closures)
//
parallel([
function doSomeAsyncStuff (cb) {
var fns = a.map(function (el) {
return function (cb) {
createElementOfSomeSort({
foo: el
}, cb);
}
});
each(fns, cb)
},
// ...
]);
//
// vs this:
// (4 spaces, mostly flat)
//
function aFunctionToCall (el, cb) {
createElementOfSomeSort({
foo: el
}, cb);
}
function mapElementToFunction (el) {
return aFunctionToCall.bind(null, el);
}
function doSomeAsyncStuff (cb) {
var fns = a.map(mapElementToFunction);
each(fns, cb)
}
parallel([
doSomeAsyncStuff
// ...
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment