How to use the on function from events

Find comprehensive JavaScript events.on code examples handpicked from public code repositorys.

172
173
174
175
176
177
178
179
180
181
const emitter = new NodeEventTarget();
const interval = setInterval(() => {
  emitter.dispatchEvent(new Event('foo'));
}, 0);
let count = 0;
for await (const [ item ] of on(emitter, 'foo')) {
  count++;
  strictEqual(item.type, 'foo');
  if (count > 5) {
    break;
fork icon0
star icon0
watch icon0