-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
'ram' flag improvement and minor ones
- Loading branch information
ferhadquluzade
committed
Sep 13, 2024
1 parent
35276c1
commit 896fa7d
Showing
4 changed files
with
16 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
import os from "os"; | ||
import { formatBytes } from "../formatter/bytes.js"; | ||
import si from "systeminformation"; | ||
|
||
export const getRamInfo = () => { | ||
export const getRamInfo = async () => { | ||
const totalMemory = os.totalmem(); | ||
const freeMemory = os.freemem(); | ||
const usedMemory = totalMemory - freeMemory; | ||
|
||
return { | ||
totalMemory: formatBytes(totalMemory), | ||
freeMemory: formatBytes(freeMemory), | ||
usedMemory: formatBytes(usedMemory), | ||
}; | ||
const rams = await si.memLayout(); | ||
let result = `total: ${formatBytes(totalMemory)}, | ||
free: ${formatBytes(freeMemory)}, | ||
used: ${formatBytes(usedMemory)}, | ||
rams: ${rams.length}`; | ||
|
||
rams.forEach((ram, index) => { | ||
result += `\nram#${index + 1} | ||
\tvendor: ${ram.manufacturer} | ||
\ttype: ${ram.type}`; | ||
}); | ||
|
||
return result; | ||
}; |