-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile.js
48 lines (39 loc) · 1.2 KB
/
file.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
const { error } = require("console");
const fs = require("fs");
const os =require('os');
// Sync Blocking
// fs.writeFileSync('./test.txt','Hey There! I am JS Developer')
// Async Non-Blocking
// fs.writeFile('./test.txt','Hey There! I am JS Developer Async',(err) => {});
// const result =fs.readFileSync('./contacts.txt',"utf-8" );
// console.log(result);
// fs.readFile("./contacts.txt","utf-8",(err,result) => {
// if (err){
// console.log("Error",err);
// }else{
// console.log(result);
// }
// });
// fs.appendFileSync('./test.txt',new Date().getDate().toLocaleString());
// fs.appendFileSync('./test.txt', `${Date.now()} Hey There\n`);
// fs.cpSync('./test.txt','./copy.txt');
// Delete File
// fs.unlinkSync('./copy.txt');
// console.log(fs.statSync('./test.txt'));
// Blocking....
// const result =fs.readFileSync('./contacts.txt',"utf-8");
// console.log(result);
// console.log("1");
// Non-Blocking.....
// fs.readFile("./contacts.txt","utf-8",(err,result) => {
// if (err){
// console.log("Error",err);
// }else{
// console.log(result);
// }
// });
// console.log("2");
// console.log("3");
// console.log("4");
// console.log("5");
console.log(os.cpus().length);