From 67a6cf008f815669d087e6c32d99cefbc99ccbb2 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Wed, 27 Jan 2021 13:30:37 +0100 Subject: [PATCH] MemoryLayout Manufacturer Codes Linux --- docs/index.html | 2 +- lib/memory.js | 36 +++++++++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/docs/index.html b/docs/index.html index 158dedf..015dfb2 100644 --- a/docs/index.html +++ b/docs/index.html @@ -201,7 +201,7 @@
-
13,024
+
13,086
Lines of code
diff --git a/lib/memory.js b/lib/memory.js index a208fc6..2357385 100644 --- a/lib/memory.js +++ b/lib/memory.js @@ -44,6 +44,28 @@ const OSX_RAM_manufacturers = { '0x04CD': 'G-Skill' }; +const LINUX_RAM_manufacturers = { + '017A': 'Apacer', + '0198': 'HyperX', + '029E': 'Corsair', + '04CB': 'A-DATA', + '04CD': 'G-Skill', + '059B': 'Crucial', + '00CE': 'Samsung', + '1315': 'Crutial', + '014F': 'Transcend Information', + '2C00': 'Micron Technology Inc.', + '802C': 'Micron Technology Inc.', + '80AD': 'Hynix Semiconductor Inc.', + '80CE': 'Samsung Electronics Inc.', + 'AD00': 'Hynix Semiconductor Inc.', + 'CE00': 'Samsung Electronics Inc.', + '02FE': 'Elpida', + '5105': 'Qimonda AG i. In.', + '8551': 'Qimonda AG i. In.', + '859B': 'Crucial' +}; + // _______________________________________________________________________________________ // | R A M | H D | // |______________________|_________________________| | | @@ -265,13 +287,21 @@ exports.mem = mem; function memLayout(callback) { - function getManufacturer(manId) { + function getManufacturerDarwin(manId) { if ({}.hasOwnProperty.call(OSX_RAM_manufacturers, manId)) { return (OSX_RAM_manufacturers[manId]); } return manId; } + function getManufacturerLinux(manId) { + const manIdSearch = manId.replace('0x', '').toUpperCase(); + if (manIdSearch.length === 4 && {}.hasOwnProperty.call(LINUX_RAM_manufacturers, manIdSearch)) { + return (LINUX_RAM_manufacturers[manIdSearch]); + } + return manId; + } + return new Promise((resolve) => { process.nextTick(() => { @@ -293,7 +323,7 @@ function memLayout(callback) { type: util.getValue(lines, 'Type:'), clockSpeed: (util.getValue(lines, 'Configured Clock Speed:') ? parseInt(util.getValue(lines, 'Configured Clock Speed:'), 10) : (util.getValue(lines, 'Speed:') ? parseInt(util.getValue(lines, 'Speed:'), 10) : null)), formFactor: util.getValue(lines, 'Form Factor:'), - manufacturer: util.getValue(lines, 'Manufacturer:'), + manufacturer: getManufacturerLinux(util.getValue(lines, 'Manufacturer:')), partNum: util.getValue(lines, 'Part Number:'), serialNum: util.getValue(lines, 'Serial Number:'), voltageConfigured: parseFloat(util.getValue(lines, 'Configured Voltage:') || null), @@ -398,7 +428,7 @@ function memLayout(callback) { type: util.getValue(lines, ' Type:'), clockSpeed: parseInt(util.getValue(lines, ' Speed:'), 10), formFactor: '', - manufacturer: getManufacturer(util.getValue(lines, ' Manufacturer:')), + manufacturer: getManufacturerDarwin(util.getValue(lines, ' Manufacturer:')), partNum: util.getValue(lines, ' Part Number:'), serialNum: util.getValue(lines, ' Serial Number:'), voltageConfigured: null,