Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
async function* getStocksStream() {
var reader = new AsyncFileReader(“stocks.txt”);
try {
while(!reader.eof) {
var line = await reader.readLine();
await yield JSON.parse(line);
}
}
finally {
await reader.close();
}
}
(async function() {
for (let line on getStocksStream()) {
console.log( line );
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment