-
Notifications
You must be signed in to change notification settings - Fork 0
/
10-fs-aync.js
29 lines (28 loc) · 942 Bytes
/
10-fs-aync.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
const {readFile, writeFile} = require('fs');
console.log('start');
readFile('./content/first.txt', (err, result) => {
if(err){
console.log(err);
return;
}
const first = result;
})
readFile('./content/second.txt', (err, result) => {
if(err){
console.log(err);
return;
}
const second = result;
})
writeFile('./content/result-async.txt', 'here is the result of async or asynchronoous file storage',(err, result) => {
if(err){
console.log(err);
return;
}
console.log('done with the task');
})
console.log('remaining execution');
/* here we can profvie other encodings as well like for example
1. 'ascii' : Interpret the file contents as ASCII-encoded text.
2. 'utf16le': Interpret the file contents as 16-bit Unicode text in little-endian byte order.
3. 'latin1' : Interpret the file contents as ISO-8859-1 (also known as Latin-1) encoded text.