0.1.0 • Published 8 years ago

proment v0.1.0

Weekly downloads
2
License
ISC
Repository
github
Last release
8 years ago

proment

Build Status

Make promises from events.

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