npm

Bring the best of OSS JavaScript development to your projects with npm Orgs - private packages & team management tools.Learn more »

once-then

1.1.0 • Public • Published

once-then

Add onceThen to your emitter to convert an event to a Promise.

npm version Build Status Coverage Status dependencies Status

Installation

npm install --save once-then

Usage

const EventEmitter = require('events').EventEmitter;
const onceThen = require('once-then');

onceThen works with the NodeJS event emitter or any events implementation that has its once method backwards compatible with NodeJS events.

const emitter = new EventEmitter();
 
onceThen(emitter, 'myEventName').then(() => {
  //
});
 
emitter.emit('myEventName');

Register

Register onceThen on an object.

onceThen.register(EventEmitter.prototype);
 
const emitter = new EventEmitter();
 
emitter.onceThen('myEventName').then(() => {
  //
});
 
emitter.emit('myEventName');

install

npm i once-then

Downloadsweekly downloads

17

version

1.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability