-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path12-async.js
More file actions
42 lines (35 loc) · 1.22 KB
/
12-async.js
File metadata and controls
42 lines (35 loc) · 1.22 KB
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
33
34
35
36
37
38
39
40
41
42
const {readFile,writeFile}= require("fs");
const util = require("util");
const readFilePromise = util.promisify(readFile);
const writeFilePromise = util.promisify(writeFile);
const start = async () =>{
const first = await readFilePromise("./content/subfolder/first.txt","utf-8")
const second = await readFilePromise("./content/subfolder/second.txt","utf-8")
await writeFilePromise
("./content/subfolder/result-from12file.txt",
`this is Awesome code ${first} ${second}`,"utf-8"
)
console.log(first);
console.log(second);
}
// const getText=(path)=>{
// readFile(path,"utf-8",(err,data)=>{
// if (err) {
// console.log(err);
// } else {
// console.log(data)}
// })
// };
// getText("./content/subfolder/first.txt")
// .then(result => console.log(result))
// .catch(err=>console.log(err));
// getText("./content/subfolder/second.txt")
// .then(result => console.log(result))
// .catch(err=>console.log(err));
// const start = async () =>{
// const first = await getText("./content/subfolder/first.txt")
// const second = await getText("./content/subfolder/second.txt")
// console.log(first);
// console.log(second);
// }
start()