-
-
Save Darkle/10d8045480ebfa33ded0 to your computer and use it in GitHub Desktop.
This file contains 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 process(chunks, index) { | |
var chunk = chunks[index]; | |
if (_.isUndefined(chunk)) { | |
return; | |
}; | |
console.log('doing expensive work ' + _.last(chunk)); | |
_.defer(_.partial(process, chunks, ++index)); | |
} | |
var collection = _.range(10000), | |
chunks = _.chunk(collection, 50); | |
process(chunks, 0); | |
// → | |
// doing expensive work 49 | |
// doing expensive work 99 | |
// doing expensive work 149 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment