Socket
Book a DemoInstallSign in
Socket

make-emitter

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

make-emitter

event emitter constructor factory

latest
Source
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

make-emitter

Build Status

An event emitter constructor factory. Save ~3 lines of code with each use!

api

function makeEmitter([object methods])

require('make-emitter') returns the function makeEmitter

The function make-emitter returns a constructor function for a new object which inherits from EventEmitter. Optionall you can supply a hash of methods which will be added to the prototype of the new Constructor.

example - old and busted:

var EventEmitter = require('events').EventEmitter;
var util = require('util');

var CustomEmitter = function() {
  EventEmitter.call(this);
};

util.inherits(CustomEmitter, EventEmitter);

CustomEmitter.prototype.explode = function() {
  this.emit('boom');
};

example - with make-emitter;

var emitter = require('make-emitter');
var CustomEmitter = emitter({
  explode: function() {
    this.emit('boom');
  }
});

incredible.

install

npm install make-emitter

test

npm test

license

MIT

Keywords

EventEmitter

FAQs

Package last updated on 26 Feb 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts