Skip to content

Commit b34b119

Browse files
committed
Add an example with async/await and async iterators
1 parent 532bdae commit b34b119

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

JavaScript/8-promises.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
const fs = require('fs');
4+
5+
const main = async () => {
6+
const stream = fs.createReadStream('./8-promises.js', 'utf8');
7+
for await (const chunk of stream) {
8+
console.log(chunk);
9+
}
10+
11+
const data = await fs.promises.readFile('./8-promises.js', 'utf8');
12+
console.log(data);
13+
};
14+
15+
main().catch(console.error);

0 commit comments

Comments
 (0)