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

View File

@ -100,6 +100,7 @@ Other changes
| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 3.42.9 | 2018-08-08 | `cpuTemperature()` optimized parsing |
| 3.42.8 | 2018-08-03 | updated docs |
| 3.42.7 | 2018-08-03 | `processes()` optimized parsing ps name |
| 3.42.6 | 2018-08-03 | `processes()` bugfix parsing ps linux |

View File

@ -564,6 +564,7 @@ Written by Sebastian Hildebrandt [sebhildebrandt](https://github.com/sebhildebra
- Adam Reis [adamreisnz](https://github.com/adamreisnz)
- Jimi M [ItsJimi](https://github.com/ItsJimi)
- Git² [GitSquared](https://github.com/GitSquared)
- weiyin [weiyin](https://github.com/weiyin)
OSX Temperature: credits here are going to:

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));
}
});