Skip to content

Instantly share code, notes, and snippets.

@slikts
Created December 21, 2019 08:51
Show Gist options
  • Save slikts/d2ce739b98a9854573b374923a4e8167 to your computer and use it in GitHub Desktop.
Save slikts/d2ce739b98a9854573b374923a4e8167 to your computer and use it in GitHub Desktop.
import { Readable } from "stream";
import { EventEmitter } from "events";
const eventToStream = (eventType: string, emitter: EventEmitter) => {
const stream = new Readable({
objectMode: true,
read() {}
});
emitter.on(eventType, event => void stream.push(event));
return stream;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment