Pretty simple node.js question. I want to extend the stream object to re-chunk the data that is coming in from a remote connection. I'm doing multiple telnets and sending commands to other servers, and they send back responses. It looks something like this.

> Hello, this is a command
This is the response to the command.
Sometimes it pauses here (which triggers the 'data' event prematurely).
But the message isn't over until you see the semicolon
;

What I'd like to do is instead of triggering the 'data' event at the pause, is wait for the ; and trigger a custom 'message' event.

I've read and reread this question, but I don't quite get it yet (partially because it's about a writable stream, and partially because I don't yet grok CoffeeScript).

EDIT: I guess I'm asking two things here:

How do I extend/inherit the stream object that net.CreateConnection uses?

Can I just extend the prototype.write to do a 'split' and re-'emit' each part?

Here's a snip of what I'm doing so far, but the chunking should be part of the stream, not part of the 'data' listener: