Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
themasch committed Apr 14, 2011
0 parents commit 27df75f
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tee.js
@@ -0,0 +1,36 @@
var tee = function(/** streams **/) {
this.streams = [];
for(var x in arguments) {
this.addStream(arguments[x]);
}
};

tee.prototype.addStream = function(s) {
this.streams.push(s);
}

function forward(method) {
tee.prototype[method] = function() {
var args = arguments;
this.streams.forEach(function(s) {
s[method].apply(s, args);
});
};
}

[ "write",
"end",
"destroy",
"destroySoon",
"addListener",
"on",
"once",
"removeListener",
"removeAllListeners",
"setMaxListeners",
"listeners",
"emit" ].forEach(forward);

module.exports = tee;


0 comments on commit 27df75f

Please sign in to comment.