Created
December 21, 2019 08:51
-
-
Save slikts/d2ce739b98a9854573b374923a4e8167 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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