Streaming fetches are supported in Chrome, Edge, and Safari, and they look a little like this:
This code is pretty readable thanks to async functions (here's a tutorial if you're unfamiliar with those), but it's still a little clumsy.
Async iterators are available in Chrome Canary if you launch it with the flag
--js-flags=--harmony-async-iteration. Here's how they work, and how we can use them to make streams iterate…
Async iterators work pretty much the same as regular iterators, but they involve promises:
Both types of iterator have a
... read the whole story at jakearchibald.com.
.return() method, which tells the iterator to end early, and do any clean-up it needs to do.