wez/telnetjs — pull request #2 by ggrossman (2014-12-04 23:38:02+00:00)
Title: Make option negotiation more customizable, export telnet protocol constants

Hi! Thanks for writing wez-telnet!

The current code always sends a `WONT` response for all options when a `DO` or `DONT` is received from the remote side. I wanted to support echo mode in my appilcation, so this was an obstacle. I think if an event listener is registered for `do` or `dont`, this default behavior should be skipped so that the event listener can supply its own custom options negotiation behavior.

The other change I made is to export all the command and options constants so that application code can access them. If you do write your own option negotiation, it's helpful to have constants like `OPT_ECHO` exported from the `telnet` module; otherwise, you have to declare the constants again in your application code. I toyed with exporting them in sub-objects, e.g. `telnet.Options.ECHO` but that seemed too verbose. So, I exported them all at top-level; for example, `telnet.OPT_ECHO` and `telnet.WILL` which is nice and concise.