Created
September 27, 2011 22:08
-
-
Save nrstott/1246406 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 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