event-promise
promises for events
Last updated 10 years ago by rschaosid .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install event-promise 
SYNC missed versions from official npm registry.

event-promise

promises for events

usage

once(emitter, event, options)
  • emitter EventEmitter
  • event string
  • options object
  • Returns: promise

example

var once = require('node-event-promise');
var http = require('http');

var request = http.get('http://duckduckgo.com/');

once(request, 'response').then(function(response) {
  // ...
}, function(error) {
  // ...
}).done();

options

  • ignoreErrors boolean

by default, the promise will reject if emitter emits an error first. Set this to true if you want to handle errors yourself.

  • array boolean

if array is true, the promise will resolve to an array of all arguments passed to the event instead of just the first argument. This is only useful if the event is fired with more than one argument, e.g. FSWatcher::change

Current Tags

  • 1.0.0                                ...           latest (9 years ago)

2 Versions

  • 1.0.0                                ...           9 years ago
  • 0.0.1                                ...           10 years ago
Maintainers (1)
Downloads
Total 1
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (0)
None
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE