Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

@async-generator/emitter-on

1.0.3 • Public • Published

returns an that iterates eventName events emitted by the emitter

This is a ponyfill for NodeJS's EventEmitter.on

installation

> npm i @async-generator/emitter-on

usage

const on = require("@async-generator/emitter-on");
 
const emitter = new EventEmitter();
 
for await (const item of on(emitter, "data")) {
  console.log(item); // will log { id: 1 }, { id: 2 } etc.
}
 
// somewhere else in your code
emitter.emit("data", { id: 1 });
emitter.emit("data", { id: 2 });
emitter.emit("data", { id: 3 });
emitter.emit("data", { id: 4 });

Install

npm i @async-generator/emitter-on

DownloadsWeekly Downloads

5

Version

1.0.3

License

MIT

Unpacked Size

3.21 kB

Total Files

5

Last publish

Collaborators

  • avatar