A wrapper around event emitters that returns a bluerbird promise resolved or rejected when certain events are fired.
Last updated 4 months ago by f0x52 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @f0x52/bluebird-events 
SYNC missed versions from official npm registry.


to fix package.json errors, untill https://github.com/toddbluhm/bluebird-events/pull/26 gets merged

Travis CI Coverage Status npm npm License TS-Standard - Typescript Standard Style Guide Dependabot badge


This package wraps an event emitter object and returns a bluebird promise that is either resolved, or rejected based on what events are fired from the emitter.

Note: Bluebird-Events v2.x is NOT backwards compatible with v1.x see changelog for details


npm install bluebird-events

Optionally run tests:

npm test


import { promisify } from 'bluebird-events'

const someEmitter = new TestEmitter()

const promise = promisify(someEmitter, {
  resolve: 'success-event-name',
  reject: ['error-event-name', 'error-event-name-2']

// Will resolve the promise

// Will reject the promise with the given error
someEmitter.emit('error-event-name', new Error('Some Error Occurred!'))


promisify(emitter, events)

emitter[Object] - Some object that can emit events (usually inherited from Events.EventEmitter)

events[Object] - Contains a mapping of events to listen for

events.resolve[String, Array of Strings, or Boolean] - The name for the event that will cause the promise to resolve (defaults to: 'finish')

events.reject[String, Array of Strings, or Boolean] - The name for the event that will cause the promise to reject (defaults to: 'error')

Returns - a bluebird promise

Note: To disable listening for all resolve or reject events (including default and custom events) just pass in false for the resolve/reject value.

// This promise cannot be resolve successfully via an emitted event
// But it can be rejected via the default 'error' event
promisify(emitter, { resolve: false })


This library is dependent upon bluebird, but because bluebird is so common, there is no need to install it multiple times so bluebird is declared as a peerDependency

Note: bluebird is also declared as a devDependency for running the test suite


???? Contributing Guide

I welcome all pull requests. Please make sure you add appropriate test cases for any features added. Before opening a PR please make sure to run the following scripts:

  • npm run lint checks for code errors and format according to ts-standard
  • npm test make sure all tests pass
  • npm run test-cover make sure the coverage has not decreased from current master

Current Tags

  • 3.0.2                                ...           latest (4 months ago)

1 Versions

  • 3.0.2                                ...           4 months ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
Dev Dependencies (16)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |