Last active
October 13, 2024 08:50
-
-
Save pshaddel/cf846ba565cffea1319d287b69143acf to your computer and use it in GitHub Desktop.
node_read_file_promise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs').promises; | |
async function read_file_1() { | |
try { | |
// get the number of times we should repeat the read operation | |
const repeat = process.argv[2] || 1; | |
for (let i = 0; i < repeat; i++) { | |
const data = await fs.readFile('./hello.txt', 'utf8'); | |
console.log(data); | |
} | |
} catch (err) { | |
console.error(err); | |
} | |
} | |
read_file_1(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment