proment
v0.1.0
Published
Make promises from events.
Downloads
5
Readme
proment
Make promises from events.
- small
- works with EventEmitter and the DOM.
- written in ES5
- optional timeout
Getting started
npm install proment
const proment = require('proment')
or
<script src="node_modules/proment/index.js"></script>
var proment = window.proment
Usage
// DOM
proment(document, 'DOMContentLoaded')()
.then()
.catch()
// EventEmitter
proment(emitter, 'connect')()
.then()
.catch()
// multiple events
proment(target, ['connect', 'open'])()
.then()
.catch()
// errors
proment(target, ['connect', 'open'], ['error', 'close'])()
.then()
.catch()
// timeout
proment(target, 'open', 123)()
.then()
.catch()
// choose Promise implementation
proment(target, 'open', bluebird)()
.then()
.catch()
// multiple options
proment(target, 'open', {timeout: 123, Promise: bluebird})()
.then()
.catch()
Test
npm test