-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindexa.js
More file actions
54 lines (37 loc) · 1.57 KB
/
indexa.js
File metadata and controls
54 lines (37 loc) · 1.57 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
const path = require('node:path')
const os = require('os')
const fileName = __filename;
const dirName = __dirname;
const baseName = path.basename(__filename);
const file = path.parse(__filename); // parse[pathconvert path to format] and
console.log("File path : ", fileName)
console.log("File Directory : ", dirName)
console.log("File Base Name : ", baseName)
console.log("File Extension : ", file.ext) // getting the extension of the file
console.log("Object to path format : ", path.format(file)) // format [ then format converts that information into path ]
console.log("Join different paths : ", path.join("folder1", "folder2", "home.html")) // .. IS USED to jump the folder.
// resolve method -- converts sequence of path into absolute path means from the start
console.log("Absolute Path : ", path.resolve(__dirname, "xyz.txt"))
const localMemory = os.totalmem(); // total memory
const freeMemory = os.freemem(); // free memory
console.log("Local Memory: ", localMemory)
console.log("Free Memory : ", freeMemory)
/* Events */
console.log("\nEVENTS : ")
const EventEmitter = require("events")
const myEmitter = new EventEmitter()
// First listner
myEmitter.on("FileLoaded", () => {
console.log("File is loaded")
})
// First listner
// File loaded is file name
myEmitter.on("FileLoaded", function() {
console.log("Second File is loaded")
}) // when that event is occued execute particular function.
// third listner
myEmitter.on("FileLoaded", () => {
console.log("Contact provided")
})
myEmitter.emit("FileLoaded") // Raising event -- to broadcast
/// First comment