erk

RFC-compliant IRC protocol lib

npm install erk
1 downloads in the last week
22 downloads in the last month

erk

erk is

  • useful for working with the IRC protocol
  • leveraging the powerful PEG.js parser generator for JavaScript
  • fully compliant with IRC Message Format RFC 2812 (Section 2.3.1)
  • implemented using node.js streams
  • supported by an exhaustive test suite

erk is not

  • a standalone bot/client

PEG.js parser

erk currently depends on features that have not been published in the publicly released pegjs-0.7.0. Developers should note that the current dependency is installing pegjs via dmajda/pegjs#master.

After editing peg/parser.pegjs, it needs to be rebuilt!

$ npm run-script peg

Streams

connect erk to your application using the I/O streams.

erk.Parser — converts an IRC-formatted string to an erk.Message

var erk = require("erk"),
    stream = require("stream");

// create a new parser
var parser = new erk.Parser();

// create a dummie output stream
var output = new stream.PassThrough({objectMode: true});

output.on("data", function(message) {
  console.log(JSON.stringify(message));
});

// connect to output
parser.pipe(output);

// write a message
parser.write("PING :irc.freenode.net\r\n");

// empty fields pruned from output
//=> {"command":"PING","parameters":["irc.freenode.net"]}

erk.Composer — converts a JavaScript object to an IRC-formatted message

var erk = require("erk");

// create a new composer
var composer = new erk.Composer();

// connect to output
composer.pipe(process.stdout);

// write a message
composer.write({command: "PONG", parameters: ["irc.freenode.net"]});

//=> PONG irc.freenode.net

TODO
  • make compatible with pegjs-0.8.0

Tests

Any contributions will require tests to support them. Run the tests!

$ npm test

Note: running this command will automatically rebuild the PEG.js parser.

npm loves you