Skip to content

Commit f6fe5cc

Browse files
authored
Merge pull request #300 from sumn2u/issue-299-fixes
Issue 299 fixes
2 parents 340b21c + 5343013 commit f6fe5cc

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

en/file-system/README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ In this example, you are using the `fs.readFile` function to read data from the
1616

1717
```javascript
1818
const fs= require('fs');
19-
//async
20-
//non blokcing i/0 thats why runs at last as ti takes moer time
19+
//asynchronous, non-blocking I/O that's why this runs last, as it takes more time
20+
2121
fs.readFile('test.txt','utf8',(err,data) => {
2222
console.log(err,data)
2323
})
@@ -29,7 +29,7 @@ Here, you use fs.writeFile to write data to the 'test.txt' file asynchronously.
2929

3030
```javascript
3131
fs.writeFile("test.txt","mahima is good girl", () => {
32-
console.log("This runs after writting in a file: written to file")
32+
console.log("This runs after writing in a file: written to file")
3333
})
3434
```
3535

@@ -41,7 +41,7 @@ Synchronous I/O operations block the execution of the program until the operatio
4141
The `fs.readFileSync` function is used for synchronous file reading. It blocks the execution until the entire file is read, and then it continues with the rest of the code. This is generally not recommended because it can cause the program to become unresponsive during the file read.
4242

4343
```javascript
44-
const a=fs.readFileSync("test.txt") //nodejs intetntionally blocks
44+
const a=fs.readFileSync("test.txt") //nodejs intentionally blocks
4545
console.log(a.toString())
4646
console.log("At last")
4747
```
@@ -52,9 +52,8 @@ console.log("At last")
5252

5353

5454
```javascript
55-
fs.writeFileSync("test.txt","mahima is good girl",() => {
56-
console.log("This is sync: intentionally process is blocked ")
57-
})
55+
fs.writeFileSync("test.txt","mahima is good girl", 'utf8')
56+
console.log("This is sync: the process is intentionally blocked ")
5857

5958
```
6059
Node.js provides both synchronous and asynchronous file I/O options. Asynchronous I/O is typically preferred for better performance and responsiveness, while synchronous I/O is used only when necessary and with caution, as it can block the program's execution.

0 commit comments

Comments
 (0)