@nodeart/event_emitter
TypeScript icon, indicating that this package has built-in type declarations

1.2.3 • Public • Published

bitHound Overall Score bitHound Dependencies bitHound Code

Methods:

const EventEmitter = require('@nodeart/event_emitter');
const events = new EventEmitter();
events.on('eventName', ...fns)
      .once('eventName', ...fns)
      .off('eventName', ...fns)
      .emit('eventName', {
          ctx: true
      }, ...args)
      .times('eventName2', 3, ...fns)
      .offAll();

const inherited = {};

// reset prototype
EventEmitter
    .inherit(inherited)
    .on('smth', ...fns);
    
const extended = {};

// add EventEmitter functionality as mixin
EventEmitter
    .extend(extended)
    .on('smth', ...fns);

// One can remove some functions from listeners array by passing them to .off method,
// but to remove all listeners event use .off with eventName only;

Package Sidebar

Install

npm i @nodeart/event_emitter

Weekly Downloads

1

Version

1.2.3

License

MIT

Unpacked Size

8.19 kB

Total Files

6

Last publish

Collaborators

  • ivan-tymoshenko
  • nodeartio
  • ivan_prodaiko_94