Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mcollina/events.on
Ponyfill for events.on for Node.js 10.x
https://github.com/mcollina/events.on
Last synced: 13 days ago
JSON representation
Ponyfill for events.on for Node.js 10.x
- Host: GitHub
- URL: https://github.com/mcollina/events.on
- Owner: mcollina
- License: other
- Created: 2020-07-29T09:38:56.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-07-31T08:31:44.000Z (over 4 years ago)
- Last Synced: 2024-12-25T10:05:26.542Z (15 days ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# events.on
Ponyfill for events.on for Node.js 10.x.
Use Node.js core implementation if available.
See [Node.js own docs](
https://nodejs.org/dist/latest-v12.x/docs/api/events.html#events_events_on_emitter_eventname)
for more details.## Install
```
npm i events.on
```## Example
```js
const on = require('events.on')const ee = new EventEmitter()
process.nextTick(() => {
ee.emit('foo', 'bar')
// 'bar' is a spurious event, we are testing
// that it does not show up in the iterable
ee.emit('bar', 24)
ee.emit('foo', 42)
})const iterable = on(ee, 'foo')
for await (const event of iterable) {
console.log(event)// this loop never ends, to end you need to break
// break
}
```## License
MIT