steam-sysreq
Advanced tools
Comparing version
62
index.js
@@ -1,5 +0,2 @@ | ||
'use strict'; | ||
import { osInfo, cpu, mem, graphics, fsSize } from 'systeminformation'; | ||
const formattedOsNames = { | ||
@@ -14,57 +11,24 @@ aix: 'Aix', | ||
android: 'Android' | ||
}, | ||
sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], | ||
logBase = Math.log(1024); | ||
}, sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], logBase = Math.log(1024); | ||
/** | ||
* Formats bytes into a more readable string. | ||
* @param {number} bytes The bytes to format. | ||
* @returns {string} The formatted bytes. | ||
* Formats bytes into a more human-readable form. | ||
*/ | ||
function formatBytes(bytes) { | ||
const exponent = Math.floor(Math.log(bytes) / logBase); | ||
return `${(bytes / Math.pow(1024, exponent)).toFixed()} ${sizes[exponent]}`; | ||
const exponent = Math.floor(Math.log(bytes) / logBase); | ||
return `${(bytes / Math.pow(1024, exponent)).toFixed()} ${sizes[exponent]}`; | ||
} | ||
/** | ||
* @typedef {object} SystemRequirements | ||
* @prop {string} os The operating system. | ||
* @prop {string} processor The Central Processing Unit (CPU) | ||
* model. | ||
* @prop {string} ram The Random Access Memory (RAM) size. | ||
* @prop {string[]} graphics The Graphics Processing Unit (GPU) | ||
* models. | ||
* @prop {string} availableDiskSpace The available disk space. | ||
*/ | ||
/** | ||
* Gets the Steam system requirements information. | ||
* @returns {Promise<SystemRequirements>} The system requirements. | ||
*/ | ||
export default async function getSteamSysReq() { | ||
const osInfo_ = await osInfo(), | ||
cpu_ = await cpu(), | ||
mem_ = await mem(), | ||
graphics_ = await graphics(), | ||
fsSize_ = await fsSize(); | ||
return { | ||
os: `${formattedOsNames[osInfo_.platform] ?? osInfo_.platform} ${ | ||
osInfo_.kernel | ||
} (${osInfo_.distro} ${osInfo_.release})`, | ||
processor: `${cpu_.manufacturer} ${cpu_.brand} @ ${cpu_.speedMax.toFixed( | ||
2 | ||
)}GHz`, | ||
ram: formatBytes(mem_.total), | ||
graphics: graphics_.controllers.map( | ||
(controller) => | ||
`${controller.vendor} ${ | ||
controller.model.at(-1) === ' ' | ||
const osInfo_ = await osInfo(), cpu_ = await cpu(), mem_ = await mem(), graphics_ = await graphics(), fsSize_ = await fsSize(); | ||
return { | ||
os: `${formattedOsNames[osInfo_.platform] ?? osInfo_.platform} ${osInfo_.kernel} (${osInfo_.distro} ${osInfo_.release})`, | ||
processor: `${cpu_.manufacturer} ${cpu_.brand} @ ${cpu_.speedMax.toFixed(2)}GHz`, | ||
ram: formatBytes(mem_.total), | ||
graphics: graphics_.controllers.map((controller) => `${controller.vendor} ${controller.model.at(-1) === ' ' | ||
? controller.model.slice(0, -1) | ||
: controller.model | ||
}` | ||
), | ||
availableDiskSpace: formatBytes(fsSize_[0].available) | ||
}; | ||
: controller.model}`), | ||
availableDiskSpace: formatBytes(fsSize_[0].available) | ||
}; | ||
} |
{ | ||
"name": "steam-sysreq", | ||
"version": "1.2.2", | ||
"version": "1.3.0", | ||
"description": "Gets system requirement information to compare to the ones shown in Steam.", | ||
@@ -9,3 +9,5 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"format": "prettier -w .", | ||
"lint": "eslint .", | ||
"build": "tsc" | ||
}, | ||
@@ -19,4 +21,11 @@ "keywords": [ | ||
"dependencies": { | ||
"systeminformation": "^5.12.10" | ||
"systeminformation": "^5.12.11" | ||
}, | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^5.41.0", | ||
"@typescript-eslint/parser": "^5.41.0", | ||
"eslint": "^8.26.0", | ||
"prettier": "^2.7.1", | ||
"typescript": "^4.8.4" | ||
}, | ||
"bugs": { | ||
@@ -23,0 +32,0 @@ "url": "https://github.com/VoltrexMaster/steam-sysreq/issues" |
@@ -19,11 +19,11 @@ # Steam SysReq | ||
{ | ||
os: 'Linux 5.13.0-37-generic (Ubuntu 21.10)', | ||
os: 'Linux 5.19.0-23-generic (Ubuntu 22.10)', | ||
processor: 'Intel Pentium® 6405U @ 2.40GHz', | ||
ram: '8 GB', | ||
graphics: [ | ||
'Intel Corporation Device 9b21', | ||
'Intel Corporation Comet Lake-U GT2 [UHD Graphics 620]', | ||
'NVIDIA Corporation GM108M [GeForce MX130]' | ||
], | ||
availableDiskSpace: '826 GB' | ||
availableDiskSpace: '644 GB' | ||
} | ||
``` |
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
0
-100%3936
-16.8%5
Infinity%4
-42.86%33
-61.63%Updated