Created
October 22, 2014 23:26
-
-
Save lxe/1eb495fb5ea9dd0e63b7 to your computer and use it in GitHub Desktop.
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
| // | |
| // 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