It's all about fulfilling contracts.
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.gitignore
.travis.yml
README.md
hitman.js
package.json

README.md

hitman

Build Status

It's all about fulfilling contracts.

Happy path (works just like an EventEmitter):

  var Hitman = require('hitman').Hitman;

  var emitter = new Hitman(['1', '2']);

  emitter.on('1', function() {
    console.log('hello world');
  });

  emitter.emit('1');

Wrapping an external EventEmitter:

  var Hitman       = require('hitman').Hitman,
      EventEmitter = require('events').EventEmitter;

  var ext_emitter = new EventEmitter(),
      emitter = new Hitman(['1', '2'], { emitter: ext_emitter });

  emitter.on('1', function() {
    console.log('hello world');
  });

  emitter.emit('1');

Both of the following examples will throw an error:

  var Hitman = require('hitman').Hitman;

  var emitter = new Hitman(['1', '2']);

  emitter.on('3', function() {
    console.log('hello world');
  });
  var Hitman = require('hitman').Hitman;

  var emitter = new Hitman(['1', '2']);

  emitter.emit('3');