-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelloworld.js
75 lines (60 loc) · 1.52 KB
/
helloworld.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
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
//1
console.log("Hello world!");
//2
function main_function(another_function, value) {
another_function(value);
}
main_function(function (param) {
console.log(param)
}, "Hello World!");
main_function(param => console.log(param), "Hi nigga!");
main_function(() => console.log(), "Hi jigga!");
//3
//4
console.log('1');
setTimeout(callback, 5000);
console.log('2');
setTimeout(callback, 5000);
console.log('3');
setTimeout(callback, 5000);
function callback() {
console.log('Callback called!');
}
//5
const ownmodule = require('./ownmodule');
ownmodule.relay();
ownmodule.longjump();
ownmodule.hi();
//8
const fs = require('fs');
fs.readFile('input', function (err, data) {
if (err) {
console.log(err);
} else {
console.log("Async data is- " + data);
}
});
let data = fs.readFileSync('input');
console.log("Sync data is- " + data);
console.log("End of testing.");
//9
let readableStream = fs.createReadStream('input');
let data1 = "";
// readableStream.setEncoding('UTF8');
readableStream.on('data', function (chunk) {
data1 += chunk
});
readableStream.on('end', function () {
console.log(data1);
});
let writeData = "Hey there, try at least 1vid everyday";
let writeableStream = fs.createWriteStream('output');
writeableStream.write(writeData);
writeableStream.end();
writeableStream.on('finish', function () {
console.log("Write completed");
});
//10
let readableStream1 = fs.createReadStream('in');
let writeableStream1 = fs.createWriteStream('out');
readableStream1.pipe(writeableStream1);