From bab27584767c78477beaa9aa4aabe577b023ce7e Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Wed, 21 May 2025 19:49:07 +0200 Subject: [PATCH] getStatic() added audio, usb, bluetooth, printer --- CHANGELOG.md | 1 + README.md | 1 + docs/history.html | 5 +++++ docs/index.html | 2 +- lib/cpu.js | 35 ++++++++++++++++++++++------------- lib/index.js | 10 +++++++++- 6 files changed, 39 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbd0e38..be4389b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -90,6 +90,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page. | Version | Date | Comment | | ------- | ---------- | --------------------------------------------------------------------------------------------------- | +| 5.26.0 | 2025-05-21 | `getStatic()` added audio, usb, bluetooth, printer | | 5.25.11 | 2025-01-11 | `docs` updated | | 5.25.10 | 2025-01-10 | `graphics()` improvement Raspberry Ubuntu | | 5.25.9 | 2025-01-10 | `memLayout()` improvement Raspberry PI 5 | diff --git a/README.md b/README.md index 77a377b..11e478c 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,7 @@ si.cpu() (last 7 major and minor version releases) +- Version 5.26.0: `getStatic()`, `getAll()` added usb, audio, bluetooth, printer - Version 5.25.0: `versions()` added homebrew - Version 5.24.0: `versions()` added bun and deno - Version 5.23.0: `usb()` added serial number (linux) diff --git a/docs/history.html b/docs/history.html index f4972cf..a0c8ceb 100644 --- a/docs/history.html +++ b/docs/history.html @@ -57,6 +57,11 @@ + + 5.26.0 + 2024-05-21 + getStatic() added audio, usb, bluetooth, printer + 5.25.11 2024-01-11 diff --git a/docs/index.html b/docs/index.html index 2f002d6..c1a51d6 100644 --- a/docs/index.html +++ b/docs/index.html @@ -170,7 +170,7 @@
systeminformation
 
- 3
New Version: 5.25.11
+ 3
New Version: 5.26.0
diff --git a/lib/cpu.js b/lib/cpu.js index 16d821e..602e8a2 100644 --- a/lib/cpu.js +++ b/lib/cpu.js @@ -994,7 +994,7 @@ function getCpuCurrentSpeedSync() { let cores = []; let speeds = []; - if (cpus && cpus.length && cpus[0].speed) { + if (cpus && cpus.length && cpus[0].hasOwnProperty('speed')) { for (let i in cpus) { speeds.push(cpus[i].speed > 100 ? (cpus[i].speed + 1) / 1000 : cpus[i].speed / 10); } @@ -1010,19 +1010,28 @@ function getCpuCurrentSpeedSync() { } if (speeds && speeds.length) { - for (let i in speeds) { - avgFreq = avgFreq + speeds[i]; - if (speeds[i] > maxFreq) { maxFreq = speeds[i]; } - if (speeds[i] < minFreq) { minFreq = speeds[i]; } - cores.push(parseFloat(speeds[i].toFixed(2))); + try { + for (let i in speeds) { + avgFreq = avgFreq + speeds[i]; + if (speeds[i] > maxFreq) { maxFreq = speeds[i]; } + if (speeds[i] < minFreq) { minFreq = speeds[i]; } + cores.push(parseFloat(speeds[i].toFixed(2))); + } + avgFreq = avgFreq / speeds.length; + return { + min: parseFloat(minFreq.toFixed(2)), + max: parseFloat(maxFreq.toFixed(2)), + avg: parseFloat((avgFreq).toFixed(2)), + cores: cores + }; + } catch (e) { + return { + min: 0, + max: 0, + avg: 0, + cores: cores + }; } - avgFreq = avgFreq / speeds.length; - return { - min: parseFloat(minFreq.toFixed(2)), - max: parseFloat(maxFreq.toFixed(2)), - avg: parseFloat((avgFreq).toFixed(2)), - cores: cores - }; } else { return { min: 0, diff --git a/lib/index.js b/lib/index.js index 07e8919..81d5efb 100644 --- a/lib/index.js +++ b/lib/index.js @@ -95,7 +95,11 @@ function getStaticData(callback) { graphics.graphics(), network.networkInterfaces(), memory.memLayout(), - filesystem.diskLayout() + filesystem.diskLayout(), + audio.audio(), + bluetooth.bluetoothDevices(), + usb.usb(), + printer.printer(), ]).then((res) => { data.system = res[0]; data.bios = res[1]; @@ -110,6 +114,10 @@ function getStaticData(callback) { data.net = res[10]; data.memLayout = res[11]; data.diskLayout = res[12]; + data.audio = res[13]; + data.bluetooth = res[14]; + data.usb = res[15]; + data.printer = res[16]; if (callback) { callback(data); } resolve(data); });