-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNe.js
More file actions
92 lines (74 loc) · 2 KB
/
Ne.js
File metadata and controls
92 lines (74 loc) · 2 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*const {readFile} = require('fs')
console.log('First task')
readFile('./HomeWork/content/second.txt','utf8', (err,result) => {
if (err) {
console.log(err)
return
}
console.log(result)
console.log('Compleated task one')
})
console.log('Next task')
console.log('first')
setInterval(() => {
console.log('second')
}, 2000);
console.log('third')
const http = require('http')
const server = http.createServer((req,res)=>{
console.log('First')
res.end('Hi All')
})
server.listen(5000,()=>{
console.log('Hi')
})
const http = require('http')
const server = http.createServer((req,res)=>{
if (req.url==='/') {
res.end('Welcome to our first web page')
return
}
if (req.url==='/about') {
for (let i= 0; i< 100; i++) {
for (let j = 0; j < array.length; j++) {
console.log(`${i},${j}`)
}
}
res.end('Hellow')
return
}})
server.listen(5000,()=>{
console.log('Hi')
})*/
const {readFile,writeFile}=require('fs')
const { start } = require('repl')
const util = require('util')
const readFilePromise = util.promisify(readFile)
const writeFilePromise = util.promisify(writeFile)
/*const getText = (path)=>{
return new Promise((resolve,reject)=>{
readFile(path,'utf8',(err,data)=>{
if(err){
reject(err)
}
else{
resolve(data)
}
})
})
}
getText('./HomeWork/content/first.txt')
.then((result)=>console.log(result))
.catch((err)=>console.log(err))*/
const Start = async ()=>{
try{
const first = await readFilePromise('./HomeWork/content/first.txt','utf8')
const second = await readFilePromise('./HomeWork/content/second.txt','utf8')
await writeFilePromise('./HomeWork/content/result_await.txt',`Write : ${first}, ${second}`)
console.log(first)
console.log(second)
}catch(error){
console.log(error)
}
}
start()