We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7c98606 commit de1a68fCopy full SHA for de1a68f
text/chapter9.md
@@ -25,12 +25,12 @@ A convenient way to work with asynchronous code in JavaScript is with [`async` a
25
26
Here is an example of using this technique to copy the contents of one file to another file:
27
28
-``` js
29
-var fs = require('fs');
+```js
+var fsPromises = require('fs').promises;
30
31
async function copyFile(file1, file2) {
32
- let data = await fs.readFile(file1, { encoding: 'utf-8' })
33
- fs.writeFile(file2, data, { encoding: 'utf-8' })
+ let data = await fsPromises.readFile(file1, { encoding: 'utf-8' });
+ fsPromises.writeFile(file2, data, { encoding: 'utf-8' });
34
}
35
36
copyFile('file1.txt', 'file2.txt')
0 commit comments