Async iterators make reading streams really easy. Already in Babel. Demo: https://babeljs.io/repl/#?babili=false&evaluate=true&lineWrap=false&presets=es2017%2Cstage-0&experimental=true&loose=false&spec=false&code=async%20function%20streamingRead()%20%7B%0A%20%20const%20response%20%3D%20await%20fetch('https%3A%2F%2Fhtml.spec.whatwg.org')%3B%0A%20%20const%20reader%20%3D%20response.body.getReader()%3B%0A%20%20%0A%20%20for%20await%20(const%20value%20of%20reader)%20%7B%0A%20%20%20%20console.log(%60Read%20%24%7Bvalue.length%7D%20bytes%60)%3B%0A%20%20%7D%0A%7D%0A%0A%2F%2F%20polyfill%20for%20readable%20streams%20to%20be%20async%20iterables%0Anew%20ReadableStream().getReader().constructor.prototype%5BSymbol.asyncIterator%5D%20%3D%20async%20function*%20readLines(path)%20%7B%0A%20%20while%20(true)%20%7B%0A%20%20%20%20const%20%7Bdone%2C%20value%7D%20%3D%20await%20this.read()%3B%0A%20%20%20%20if%20(done)%20return%3B%0A%20%20%20%20yield%20value%3B%0A%20%20%7D%0A%7D%3B%0A%0AstreamingRead()%3B …pic.twitter.com/3TRt9adaCj
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.