-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasyncFs.js
32 lines (29 loc) · 938 Bytes
/
asyncFs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const {readFile, writeFile} = require('fs');
console.log('Start System');
readFile('./content/almohamady.txt','utf-8', (err, result) => {
var myResult, myResult2;
if (err) {
console.log(err);
return;
} else {
myResult = result;
console.log(result);
readFile('./content/myFolder/test.txt', 'utf-8', (err2, result2) => {
if (err2) {
console.log(err2);
return;
}
myResult2 = result2;
console.log(myResult2);
writeFile( "./content/result-async.txt", `1 : ${myResult} , 2 : ${myResult2}`,{flag: 'a'} , (wErr, wResult) => {
if (wErr){
console.log(wErr);
return;
}
console.log(wResult);
console.log('Done with this task :)');
});
});
}
});
console.log('Done :)');