Skip to content

Instantly share code, notes, and snippets.

@aseemk
Created April 10, 2011 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aseemk/911975 to your computer and use it in GitHub Desktop.
Save aseemk/911975 to your computer and use it in GitHub Desktop.
Testing support for using Streamline.js with Underscore.js.
// 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