Skip to content

Instantly share code, notes, and snippets.

@pshaddel
Last active October 13, 2024 08:53
Show Gist options
  • Save pshaddel/e552c1635f8120dcf3c716056d6fd72b to your computer and use it in GitHub Desktop.
Save pshaddel/e552c1635f8120dcf3c716056d6fd72b to your computer and use it in GitHub Desktop.
node_read_file_sync
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