├── importExport ├── index.js └── moduls.js ├── os_moduls └── os.js ├── path_moduls └── path.js ├── nodes.doc └── index.js /importExport/index.js: -------------------------------------------------------------------------------- 1 | const {name, sub,add}=require("./moduls") 2 | console.log(add(5,5)); 3 | console.log(sub(5,95)); 4 | console.log(name); -------------------------------------------------------------------------------- /importExport/moduls.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | const add=(a,b)=>{ 4 | return a+b 5 | } 6 | const sub=(a,b)=>{ 7 | return a-b 8 | } 9 | const name='kamal' 10 | 11 | 12 | module.exports={add, sub,name} 13 | //single export 14 | //module.exports=add; -------------------------------------------------------------------------------- /os_moduls/os.js: -------------------------------------------------------------------------------- 1 | const os=require("os"); 2 | 3 | 4 | const ram=os.totalmem(); 5 | console.log(`${ram/1024/1024/1024} GB`); 6 | console.log(os.platform()); 7 | console.log(os.hostname()); 8 | console.log(os.userInfo()); 9 | console.log(os.networkInterfaces()); 10 | console.log(os.type()); -------------------------------------------------------------------------------- /path_moduls/path.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | 3 | console.log(path.parse("D:/Web/server/node js/1st/path_moduls/path.js")); 4 | 5 | console.log(path.basename("D:/Web/server/node js/1st/path_moduls/path.js")); 6 | const myPath=path.parse("D:/Web/server/node js/1st/path_moduls/path.js"); 7 | console.log("myPath "+myPath.name); -------------------------------------------------------------------------------- /nodes.doc: -------------------------------------------------------------------------------- 1 | const fs =require("fs"); 2 | 3 | 4 | var writeFileSync ="1. writeFileSync : if file not exist then its create a file and push the text and if file is exxist then its only replace all text" 5 | //fs.writeFileSync('read.txt', writeFileSync); 6 | 7 | var appendFileSync="2. appendFileSync : its map/append a new text in existing file" 8 | //fs.appendFileSync('read.txt',appendFileSync) 9 | 10 | 11 | var Buffer="its by-default showing Buffer format text like binary text"; 12 | var readFileSync="3. readFileSync : its help to read existing file.." 13 | 14 | 15 | /* const buf_Data=fs.readFileSync("read.txt") 16 | //now we have need to convert Buffer to string format 17 | org_Data=buf_Data.toString(); 18 | console.log(org_Data); 19 | */ 20 | 21 | var renameSync="this functions help to rename existing file" 22 | fs.renameSync("readWrite.txt", "nodes.doc"); 23 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | 3 | 4 | 5 | //var writeFileSync ="1. writeFileSync : if file not exist then its create a file and push the text and if file is exxist then its only replace all text" 6 | //fs.writeFileSync('read.txt', writeFileSync); 7 | 8 | //var appendFileSync="2. appendFileSync : its map/append a new text in existing file" 9 | //fs.appendFileSync('read.txt',appendFileSync) 10 | 11 | 12 | // var Buffer="its by-default showing Buffer format text like binary text"; 13 | // var readFileSync="3. readFileSync : its help to read existing file.." 14 | 15 | 16 | /* const buf_Data=fs.readFileSync("read.txt") 17 | //now we have need to convert Buffer to string format 18 | org_Data=buf_Data.toString(); 19 | console.log(org_Data); 20 | */ 21 | 22 | // var renameSync="this functions help to rename existing file" 23 | // fs.renameSync("readWrite.txt", "nodes.doc"); 24 | 25 | //fs.mkdirSync('kamal/test.doc'); 26 | 27 | //fs.writeFileSync('kamal/test.doc', "wow text is added :)"); 28 | 29 | //fs.appendFileSync('kamal/test.doc', " wow text appendFileSync is added :)"); 30 | 31 | // var read =fs.readFileSync("kamal/test.doc", "utf-8") 32 | // console.log(read); 33 | 34 | //fs.renameSync("myText.doc",'kamal/test.doc') 35 | //fs.unlinkSync('kamal/test.doc') 36 | //fs.rmdirSync("kamal") 37 | 38 | // fs.writeFile('test.doc',"hello world",(err)=>{ 39 | // let show=fs.readFileSync('test.doc',"utf-8") 40 | // console.log(show); 41 | // fs.unlinkSync("test.doc") 42 | // }); 43 | 44 | 45 | // fs.writeFile("kamal.txt","wow i have done",(err)=>{ 46 | // console.log("run"); 47 | // }) 48 | 49 | // fs.appendFile("kamal.txt"," wow i have done now :)",(err)=>{ 50 | // console.log("running"); 51 | // }) 52 | // fs.readFile("kamal.txt",'utf-8',(err,data)=>{ 53 | // console.log(data); 54 | // }) 55 | 56 | // fs.rename('kamal.txt',"mrkamal.txt",(err)=>{ 57 | // console.log("change"); 58 | // }) 59 | // fs.unlink('mrkamal.txt',()=>{ 60 | // console.log("del"); 61 | // }) 62 | 63 | --------------------------------------------------------------------------------