get() fixed when results are in arrays
This commit is contained in:
parent
1ed7115168
commit
fbdfd233f0
@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
|
||||
|
||||
| Version | Date | Comment |
|
||||
| -------------- | -------------- | -------- |
|
||||
| 4.27.6 | 2020-10-02 | `get()` fixed when results are in arrays |
|
||||
| 4.27.5 | 2020-09-18 | `cpuTemperature()` fix try catch (linux) |
|
||||
| 4.27.4 | 2020-09-16 | `networkInterfaceDefault()` optimization (macOS) |
|
||||
| 4.27.3 | 2020-08-26 | updated typescript typings |
|
||||
|
||||
@ -83,6 +83,11 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">4.27.6</th>
|
||||
<td>2020-10-02</td>
|
||||
<td><span class="code">get()</span> fixed when results are in arrays</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">4.27.5</th>
|
||||
<td>2020-09-18</td>
|
||||
|
||||
@ -168,7 +168,7 @@
|
||||
<img class="logo" src="assets/logo.png">
|
||||
<div class="title">systeminformation</div>
|
||||
<div class="subtitle"><span id="typed"></span></div>
|
||||
<div class="version">Current Version: <span id="version">4.27.5</span></div>
|
||||
<div class="version">Current Version: <span id="version">4.27.6</span></div>
|
||||
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
|
||||
</div>
|
||||
<div class="down">
|
||||
|
||||
@ -253,7 +253,7 @@ function parseBlk(lines) {
|
||||
let data = [];
|
||||
|
||||
lines.filter(line => line !== '').forEach((line) => {
|
||||
line = util.decodeEscapeSequence(line);
|
||||
line = decodeURIComponent(line.replace(/\\x/g, '%'));
|
||||
line = line.replace(/\\/g, '\\\\');
|
||||
let disk = JSON.parse(line);
|
||||
data.push({
|
||||
|
||||
31
lib/index.js
31
lib/index.js
@ -331,13 +331,28 @@ function get(valueObject, callback) {
|
||||
result[key] = data[i];
|
||||
} else {
|
||||
const keys = valueObject[key].replace(/,/g, ' ').replace(/ +/g, ' ').split(' ');
|
||||
const partialRes = {};
|
||||
keys.forEach(k => {
|
||||
if ({}.hasOwnProperty.call(data[i], k)) {
|
||||
partialRes[k] = data[i][k];
|
||||
}
|
||||
});
|
||||
result[key] = partialRes;
|
||||
if (Array.isArray(data[i])) {
|
||||
// result is in an array, go through all elements of array and pick only the right ones
|
||||
const partialArray = [];
|
||||
data[i].forEach(element => {
|
||||
const partialRes = {};
|
||||
keys.forEach(k => {
|
||||
if ({}.hasOwnProperty.call(element, k)) {
|
||||
partialRes[k] = element[k];
|
||||
}
|
||||
});
|
||||
partialArray.push(partialRes);
|
||||
});
|
||||
result[key] = partialArray;
|
||||
} else {
|
||||
const partialRes = {};
|
||||
keys.forEach(k => {
|
||||
if ({}.hasOwnProperty.call(data[i], k)) {
|
||||
partialRes[k] = data[i][k];
|
||||
}
|
||||
});
|
||||
result[key] = partialRes;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
@ -355,7 +370,7 @@ function observe(valueObject, interval, callback) {
|
||||
const result = setInterval(() => {
|
||||
get(valueObject).then(data => {
|
||||
if (JSON.stringify(_data) !== JSON.stringify(data)) {
|
||||
_data = Object.assign({}, data );
|
||||
_data = Object.assign({}, data);
|
||||
callback(data);
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user