rocket-connect / for-emit-of

Turn Node.js Events into Async Iterables.
https://www.npmjs.com/package/for-emit-of
MIT License
9 stars 2 forks source link

Break the loop after a timeout #1

Closed danstarns closed 4 years ago

danstarns commented 4 years ago

Example

const iterator = forEmitOf(readStream, {
    timeout: 1000, // ms
});

for await (const chunk of iterator) {
    console.log(chunk);
}

After 1000ms iterator will break.

Farenheith commented 4 years ago

I want to contribute with this one! How do you want it to behave? Did you though that the iterator should just end or it should throw an error if the timeout is reached?

Farenheith commented 4 years ago

I just made a PR that throws an error if the timeout is reached. I hope that's what you was expecting :)