Socket
Book a DemoInstallSign in
Socket

maxhoffmann-emitter

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

maxhoffmann-emitter

event emitter built with the frozen closure pattern

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Emitter

Event emitter implementation using the “frozen closure” pattern as described by Douglas Crockford. Heavily inspired by component/emitter.

Browser support: ES5 compatible browsers (IE9+)

Installation

npm install maxhoffmann/emitter --save

Usage

var Emitter = require('maxhoffmann-emitter');

var emitter = Emitter();

emitter.on('eventName', listener);
emitter.once('eventName', listener); // only listen once

emitter.off('eventName', listener); // remove specific listener
emitter.off('eventName'); // remove all listeners of this event
emitter.off(); // remove all listeners

emitter.trigger('eventName', arg1, arg2…); // arguments are optional

emitter.hasListeners('eventName');
emitter.hasListeners(); // returns true if any listeners are added

Note: This library is built with webpack to the UMD format. You can therefore use it with common.js and amd loaders or as a global variable.

Testing

  • cd into directory
  • run npm test

Development

npm run build to create a minimized and UMD format compatible version of the source file.

LICENSE

The MIT License

FAQs

Package last updated on 11 Aug 2014

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