prawnsalad/KiwiIRC — pull request #415 by M2Ys4U (2013-10-23 20:48:17+00:00)
Title: Refactor parsing/command dispatch using streams

* Split `socketOnData` and `parseIrcLine` functions from `connection.js` into new `IrcParser` class in `parser.js`.

* `IrcParser` is a subclass of `stream.Transform`, in `objectMode` on the readable end.

* `IrcCommands` is now a subclass of `stream.Writable`, in `objectMode`.

* `IrcConnection` is now a subclass of `stream.Writable` AND `EE`, inheriting directly from `stream.Writable` and paracitically from `EE`.

* Added `readable-stream` as an `optionalDepenency` in `package.json` to use the new Streams2 classes.

The raw IRC sockets are now `pipe()`ed directly in to the `IrcParser` object on socket connect, and `error`s emitted by `IrcParser` are now handled and re-emmitted on the `IrcConnection` object.

The `IrcParser` output is also `pipe()`ed directly into the `IrcCommands` object, replacing the old `IrcCommands#dispatch()` method. `IrcCommands#addHandler` and `IrcCommands#addNumeric` now return `this` to enable chaining.

`IrcConnection#write` and `IrcConnection#flushWriteBuffer` now propegates the advisory return value from `stream.Writable.prototype#write`.