Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/allain/promise-event-before
A tool that returns a promise that resolves if an EventEmitter emits an event before the given timeout
https://github.com/allain/promise-event-before
Last synced: 16 days ago
JSON representation
A tool that returns a promise that resolves if an EventEmitter emits an event before the given timeout
- Host: GitHub
- URL: https://github.com/allain/promise-event-before
- Owner: allain
- License: mit
- Created: 2015-09-18T21:36:39.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-09-18T21:43:23.000Z (over 9 years ago)
- Last Synced: 2024-12-21T02:41:33.232Z (about 1 month ago)
- Language: JavaScript
- Size: 133 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# promise-event-before
A tool that returns a promise that resolves if an EventEmitter emits an event before the given timeout
## Installation
```bash
npm install promise-event-before
```## Usage
```js
var diceRollEmitter = ...var eventBefore = require('promise-event-before');
eventBefore(emitter, 'rolled', 1000).then(function(roll) {
console.log('dice roll:', roll);
}, function(err) {
console.error(err);
});
```## API
### eventBefore(emitter, eventName, timeout) : Promise
#### emitter
an EventEmitter to inspect#### eventName
the event name to wait for#### timeout
the number of milliseconds to wait before declaring the Promise rejected