cpuTemperature() optimized parsing

This commit is contained in:
Sebastian Hildebrandt
2018-08-08 07:11:31 +02:00
parent 796c31aa8d
commit bb58e99ffe
3 changed files with 5 additions and 2 deletions
+3 -2
View File
@@ -464,10 +464,11 @@ function cpuTemperature(callback) {
lines.forEach(function (line) {
let regex = /[+-]([^°]*)/g;
let temps = line.match(regex);
if (line.split(':')[0].toUpperCase().indexOf('PHYSICAL') !== -1) {
let firstPart = line.split(':')[0].toUpperCase();
if (firstPart.indexOf('PHYSICAL') !== -1 || firstPart.indexOf('PACKAGE') !== -1) {
result.main = parseFloat(temps);
}
if (line.split(':')[0].toUpperCase().indexOf('CORE ') !== -1) {
if (firstPart.indexOf('CORE ') !== -1) {
result.cores.push(parseFloat(temps));
}
});