Skip to content

Commit a9f1acc

Browse files
authored
add: Core module (#6)
1 parent 4a6f9f2 commit a9f1acc

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

4. Core Module/app.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Core module
2+
// File system
3+
const fs = require("node:fs");
4+
5+
// Write string to file synchronous
6+
// try {
7+
// fs.writeFileSync("data/testSynchronous.txt", "Hello World Synchronous");
8+
// } catch (error) {
9+
// console.log(error.message);
10+
// }
11+
12+
// Write string to file asynchronous
13+
// fs.writeFile(
14+
// "data/testAsynchronous.txt",
15+
// "Hello World from asynchronous",
16+
// (e) => {
17+
// console.log(e);
18+
// }
19+
// );
20+
21+
// Read the content of the file Synchronous
22+
// const data = fs.readFileSync("data/testSynchronous.txt", "utf-8");
23+
24+
// console.log(data);
25+
26+
// Read the content of the file Asynchronous
27+
fs.readFile("data/testAsynchronous.txt", "utf-8", (err, data) => {
28+
if (err) throw err;
29+
30+
console.log(data);
31+
});
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello World from asynchronous
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello World Synchronous

0 commit comments

Comments
 (0)