Created
April 10, 2011 01:56
-
-
Save aseemk/911975 to your computer and use it in GitHub Desktop.
Testing support for using Streamline.js with Underscore.js.
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
// streamline.options = { "callback": "_cb" } | |
var _ = require('underscore'); | |
var array = [1, 2, 3]; | |
function process(item, _cb) { | |
// simulate async task | |
setTimeout(_cb, 1000); | |
return item; | |
} | |
_.each(array, function (item, i, array, _cb) { | |
// this unfortunately doesn't "block" like you would expect it to, | |
// because underscore doesn't actually pass or call the async callback. | |
console.log(process(item, _cb)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment