Hi,
I searched the internet and especially read your book about ES6 to solve a problem I have with ES6 generators. Yet I haven't been able to find a solution. May be this community is able to help me.
My scenario: I have a stream and want to push the asynchronously received data into a Generator and also want to use that Generator in a for-of loop as Iterator. So that in the body of the for loop I can process the data. I successfully created an observer generator and separate an iterator Generator. Independently they are working fine, but I can't figure out how to link/combine them.
Pseudo code of what I'm trying to achieve
const stream = fs.createReadStream(myFile)
const genFunc = streamToIterator(stream)
for (const chunk of genFunc()) {
// process the data
}
I was hoping to be able to push (from the stream) the data into an observer generator, which upon next/yield continues the iterator with the data received. I would imagine that it should work, but can't figure out how.Any help is much appreciated. And it case it not obvious, may be a nice extension to your book
thanks a lot
kind regards
Juergen