Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial commit

  • Loading branch information...
commit 27df75f9a899f3066403618c15378e831e52dd62 0 parents
@themasch authored
Showing with 36 additions and 0 deletions.
  1. +36 −0 tee.js
36 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;
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.