I'd like to know if is it possible to create a readable stream in some way with the data emitted by an EventEmitter.
For example, I have a RandomNumberGenerator that inherits from EventEmitter that has this function:
emitData: =>
clearTimeout @timeout
return unless @running
data = _.chain @types
.map (type) => [type, @chance[type]() if @chance[type]]
.object()
.value()
@emit "data", data
@timeout = setTimeout @emitData, @interval
So in another file, I can write:
numberGenerator.on 'data', (data) ->
console.log(data)
Now I'd like to pipe this generated numbers in another stream. Is there a way to do so?