From c5647a66fd3f65f3d9fe43bfc3e407f24e76bece Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sun, 20 Nov 2022 09:57:50 +0100 Subject: [PATCH] code cleanup, refresh rate (win) --- lib/cpu.js | 6 +++--- lib/docker.js | 2 +- lib/graphics.js | 8 +++++--- lib/internet.js | 2 +- lib/network.js | 1 - lib/system.js | 2 -- lib/users.js | 1 - lib/util.js | 1 - test/test.js | 1 - 9 files changed, 10 insertions(+), 14 deletions(-) diff --git a/lib/cpu.js b/lib/cpu.js index 2966f927..c3aaffc1 100644 --- a/lib/cpu.js +++ b/lib/cpu.js @@ -525,11 +525,11 @@ function getSocketTypesByName(str) { let result = ''; for (const key in socketTypesByName) { const names = socketTypesByName[key].split(' '); - for (let i = 0; i < names.length; i++) { - if (str.indexOf(names[i]) >= 0) { + names.forEach(element => { + if (str.indexOf(element) >= 0) { result = key; } - } + }); } return result; } diff --git a/lib/docker.js b/lib/docker.js index 8125fc5c..c2a152d7 100644 --- a/lib/docker.js +++ b/lib/docker.js @@ -458,7 +458,7 @@ function dockerContainerStats(containerIDs, callback) { containerIDsSanitized = ''; const s = (util.isPrototypePolluted() ? '' : util.sanitizeShellString(containerIDs, true)).trim(); for (let i = 0; i <= util.mathMin(s.length, 2000); i++) { - if (!(s[i] === undefined)) { + if (s[i] !== undefined) { s[i].__proto__.toLowerCase = util.stringToLower; const sl = s[i].toLowerCase(); if (sl && sl[0] && !sl[1]) { diff --git a/lib/graphics.js b/lib/graphics.js index 5a88f2af..a958aa8b 100644 --- a/lib/graphics.js +++ b/lib/graphics.js @@ -864,10 +864,12 @@ function graphics(callback) { if (_pixelDepth) { result.displays[0].pixelDepth = _pixelDepth; } - if (_refreshRate && !result.displays[0].currentRefreshRate) { - result.displays[0].currentRefreshRate = _refreshRate; - } } + result.displays = result.displays.map(element => { + if (_refreshRate && !element.currentRefreshRate) { + element.currentRefreshRate = _refreshRate; + } + }); if (callback) { callback(result); diff --git a/lib/internet.js b/lib/internet.js index 71f08785..5abf1c00 100644 --- a/lib/internet.js +++ b/lib/internet.js @@ -46,7 +46,7 @@ function inetChecksite(url, callback) { let urlSanitized = ''; const s = util.sanitizeShellString(url, true); for (let i = 0; i <= util.mathMin(s.length, 2000); i++) { - if (!(s[i] === undefined)) { + if (!s[i] !== undefined) { s[i].__proto__.toLowerCase = util.stringToLower; const sl = s[i].toLowerCase(); if (sl && sl[0] && !sl[1] && sl[0].length === 1) { diff --git a/lib/network.js b/lib/network.js index e0d2d2c7..abb4157b 100644 --- a/lib/network.js +++ b/lib/network.js @@ -305,7 +305,6 @@ function getWindowsDNSsuffixes() { return dnsSuffixes; } catch (error) { - // console.log('An error occurred trying to bring the Connection-specific DNS suffix', error.message); return { primaryDNS: '', exitCode: 0, diff --git a/lib/system.js b/lib/system.js index 5774b992..71df535c 100644 --- a/lib/system.js +++ b/lib/system.js @@ -47,7 +47,6 @@ function system(callback) { if (_linux || _freebsd || _openbsd || _netbsd) { exec('export LC_ALL=C; dmidecode -t system 2>/dev/null; unset LC_ALL', function (error, stdout) { - // if (!error) { let lines = stdout.toString().split('\n'); result.manufacturer = util.getValue(lines, 'manufacturer'); result.model = util.getValue(lines, 'product name'); @@ -55,7 +54,6 @@ function system(callback) { result.serial = util.getValue(lines, 'serial number'); result.uuid = util.getValue(lines, 'uuid').toLowerCase(); result.sku = util.getValue(lines, 'sku number'); - // } // Non-Root values const cmd = `echo -n "product_name: "; cat /sys/devices/virtual/dmi/id/product_name 2>/dev/null; echo; echo -n "product_serial: "; cat /sys/devices/virtual/dmi/id/product_serial 2>/dev/null; echo; diff --git a/lib/users.js b/lib/users.js index 6c9a33cb..41aa4e92 100644 --- a/lib/users.js +++ b/lib/users.js @@ -350,7 +350,6 @@ function parseWinUsersQuery(lines) { if (lines[i].trim()) { const user = lines[i].substring(headerDelimiter[0] + 1, headerDelimiter[1]).trim() || ''; const tty = lines[i].substring(headerDelimiter[1] + 1, headerDelimiter[2] - 2).trim() || ''; - // const dateTime = util.parseDateTime(lines[i].substring(headerDelimiter[5] + 1, 2000).trim(), culture) || ''; result.push({ user: user, tty: tty, diff --git a/lib/util.js b/lib/util.js index 43793391..6f693644 100644 --- a/lib/util.js +++ b/lib/util.js @@ -254,7 +254,6 @@ function parseHead(head, rights) { let result = []; for (let i = 0; i < head.length; i++) { if (count <= rights) { - // if (head[i] === ' ' && !space) { if (/\s/.test(head[i]) && !space) { to = i - 1; result.push({ diff --git a/test/test.js b/test/test.js index 4ed96608..be363d76 100644 --- a/test/test.js +++ b/test/test.js @@ -68,7 +68,6 @@ function printTitle(title) { } process.stdin.on('keypress', (key, data) => { - // console.log(data); if (data.name === 'q' && !data.shift) { // shut down process.exit();