Last active
October 13, 2024 08:53
-
-
Save pshaddel/e552c1635f8120dcf3c716056d6fd72b to your computer and use it in GitHub Desktop.
node_read_file_sync
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'); | |
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 = fs.readFileSync('./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