Stream.prototype.pipe = function(dest, options) {
var source = this;
source.on('data', function (chunk) {
if (dest.writable) {
if (false === dest.write(chunk) && source.pause) {
source.pause();
}
}
});
dest.on('drain', function () {
if (source.readable && source.resume) {
source.resume();
}
});
dest.emit('pipe', source);
// Allow for unix-like usage: A.pipe(B).pipe(C)
return dest;
};