Utility to resolve EventEmitters as a promise
npm install event-emitter-promisify




By default promisifyEventEmitter returns a promise which resolves to undefined if the end event is called, and rejects if the error event is called.
``ts
import { promisifyEventEmitter } from 'event-emitter-promisify'
const stream = new Readable();
stream.push(null);
await promisifyEventEmitter(stream.on('data', () => {}));
`
The return value on end can also be customized. For instance:
`ts``
export default function arrayifyStream
const array: T[] = [];
return promisifyEventEmitter(stream.on('data', data => array.push(data)), array);
}