Skip to content

Instantly share code, notes, and snippets.

@nrstott
Created September 27, 2011 22:08
Show Gist options
  • Save nrstott/1246406 to your computer and use it in GitHub Desktop.
Save nrstott/1246406 to your computer and use it in GitHub Desktop.
function ForEachStream(forEachable) {
if (!(this instanceof ForEachStream)) return new ForEachStream(forEachable);
Stream.call(this);
var self = this;
this.fd = null;
this.readable = true;
this.writeable = false;
this.paused = false;
process.nextTick(function() {
var p = forEachable.forEach(function(data) {
self.emit('data', data);
});
Q.when(p, function() {
self.emit('end');
});
});
};
require('util').inherits(ForEachStream, Stream);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment