Skip to content

Instantly share code, notes, and snippets.

@dsheiko
Last active June 13, 2016 09:50
Show Gist options
  • Save dsheiko/3248342d16adfd952e060907d2bc4c49 to your computer and use it in GitHub Desktop.
Save dsheiko/3248342d16adfd952e060907d2bc4c49 to your computer and use it in GitHub Desktop.
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