Fix reduce usage

This commit is contained in:
Girish Ramakrishnan
2019-11-21 13:48:17 -08:00
parent a98551f99c
commit ab5e4e998c
2 changed files with 4 additions and 1 deletions

View File

@@ -102,7 +102,7 @@ function getMemory(callback) {
assert.strictEqual(typeof callback, 'function');
const stdout = safe.child_process.execSync('swapon --noheadings --raw --bytes --show=SIZE', { encoding: 'utf8' });
const swap = !stdout ? 0 : stdout.split('\n').reduce((acc, cur) => acc + (parseInt(cur, 0) || 0));
const swap = !stdout ? 0 : stdout.trim().split('\n').map(x => parseInt(x, 10) || 0).reduce((acc, cur) => acc + cur);
callback(null, {
memory: os.totalmem(),