Skip to content

Instantly share code, notes, and snippets.

@isaacs
Created December 13, 2009 21:35
Show Gist options
  • Save isaacs/255615 to your computer and use it in GitHub Desktop.
Save isaacs/255615 to your computer and use it in GitHub Desktop.
var r = new ReaderStream("/etc/passwd"),
w1 = new WriterStream("/tmp/passwd"),
w2 = new WriterStream("/tmp/passwd2");
r.read();
w1.write(r);
w2.write(w1).addListener("body", function (d) {
sys.debug("wrote: "+d);
}).addListener("complete", function () {
sys.debug("complete!");
});
// or, equivalently, since read() and write() are chainable...
w2.write(w1.write(r.read())).addListener("body", function (d) {
sys.debug("wrote: "+d);
}).addListener("complete", function () {
sys.debug("complete!");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment