function parseMessage(message) {
    var parsed = {};
    parsed.prefix = "";
    parsed.command = "";
    parsed.parameters = [];
    parsed.body = "";

    // Trim trailing CRLF.
    var crlfIndex = message.indexOf("\r\n");
    if(crlfIndex >= 0) {
      message = message.substring(0, crlfIndex);
    }

    // If leading character is ':', the message starts with a prefix.
    if (message.indexOf(':') == 0) {
      parsed.prefix = message.substring(1, message.indexOf(" "));
      message = message.substring(parsed.prefix.length + 2);

      // Forward past extra whitespace.
      while(message.indexOf(" ") == 0) {
        message = message.substring(1);
      }
    }

    // If there is still a ':', then the message has trailing body.
    var bodyMarker = message.indexOf(':');
    if (bodyMarker >= 0) {
      parsed.body = message.substring(bodyMarker + 1);
      message = message.substring(0, bodyMarker);
    }

    parsed.parameters = message.split(" ");
    parsed.command = parsed.parameters.shift();  // First param is the command.

    return parsed;
  }
IRC Implementation
What follows in a minimal implementation of the IRC protocol.
Only |commands| are currently implemented.