How to stop reading from a ReadableStream?
the
break
stops the for loop, but it doesnt exit? because it only logs the user
after the readable
stream is completed. i dont want to wait for the stream to complete/end, i want to get user
immidiately after break
is called.
here readable
is ReadableStream
1 Reply
In this case you probably need to do manual iteration instead of using a for-of loop.
See an example here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators
I imagine it'll be like the following but with some
await
's
Iterators and generators - JavaScript | MDN
Iterators and Generators bring the concept of iteration directly into the core language and provide a mechanism for customizing the behavior of for...of loops.