diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b3be0f..c79c761 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 4.0.9 | 2019-02-08 | `cpu()` fix, code cleanup | | 4.0.8 | 2019-02-05 | `inetLatency()` Windows fix parse chinese output | | 4.0.7 | 2019-02-05 | `inetLatency()` Windows fix | | 4.0.6 | 2019-02-04 | powershell catch error | diff --git a/docs/history.html b/docs/history.html index 650e80e..15569b3 100644 --- a/docs/history.html +++ b/docs/history.html @@ -80,6 +80,11 @@ + + 4.0.9 + 2019-02-08 + cpu() fix, code clean up + 4.0.8 2019-02-05 diff --git a/docs/index.html b/docs/index.html index 640cafb..0f91a3a 100644 --- a/docs/index.html +++ b/docs/index.html @@ -170,7 +170,7 @@
systeminformation
-
Current Version: 4.0.7
+
Current Version: 4.0.9
@@ -193,7 +193,7 @@
-
7,973
+
8,137
Lines of code
@@ -201,7 +201,7 @@
Downloads last month
-
124
+
127
Dependends
diff --git a/lib/cpu.js b/lib/cpu.js index 3b413f9..6435beb 100644 --- a/lib/cpu.js +++ b/lib/cpu.js @@ -293,7 +293,7 @@ function getCpu() { } if (result.speed === '0.00') { let current = getCpuCurrentSpeedSync(); - if (current !== '0.00') result.speed = current.avg.toFixed(2); + if (current.avg !== 0) result.speed = current.avg.toFixed(2); } _cpu_speed = result.speed; result.speedmin = Math.round(parseFloat(util.getValue(lines, 'cpu min mhz').replace(/,/g, '.')) / 10.0) / 100; @@ -374,7 +374,7 @@ function getCpu() { } if (result.speed === '0.00') { let current = getCpuCurrentSpeedSync(); - if (current !== '0.00') result.speed = current.avg.toFixed(2); + if (current.avg !== 0) result.speed = current.avg.toFixed(2); } _cpu_speed = result.speed; result.speedmin = ''; @@ -575,8 +575,15 @@ function cpuCurrentspeed(callback) { return new Promise((resolve) => { process.nextTick(() => { let result = getCpuCurrentSpeedSync(); - if (result === 0 && _cpu_speed !== '0.00') result = parseFloat(_cpu_speed); - + if (result.avg === 0 && _cpu_speed !== '0.00') { + const currCpuSpeed = parseFloat(_cpu_speed); + result = { + min: currCpuSpeed, + max: currCpuSpeed, + avg: currCpuSpeed, + cores: [] + } + } if (callback) { callback(result); } resolve(result); });