mscdex/node-imap — pull request #154 by cristiandouce (2013-01-17 18:49:43+00:00)
Title: Change `EventEmitter` to `Stream` for ".pipe()" and other Stream goodies

As explained in [here](https://github.com/aredridel/node-smtp/pull/5) it becomes handy to have a Stream inherited message. The pipe method can really come handy in much ways.

For example I used it in combination with [mailparser](https://github.com/andris9/mailparser) module like this:

```javascript
//...
imap.fetch(results, {
headers: {
parse: false
},
body: true,
cb: function(fetch) {
fetch.on("message", function(message) {
var parser = new mailparser.MailParser;

parser.on("headers", function(headers) {
return console.log("Message Headers:", headers.received);
});

parser.on("end", function(mail) {
return console.log("Mail:", mail);
});

message.pipe(parser);
});
}
}, function(err) {
imap.logout();
});

//...
```