From 3ef84b0b8021e39960e8270db40a4c23b68c50e6 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Fri, 2 Aug 2024 11:55:24 +0200 Subject: [PATCH] usb() fixed duplicated entries (windows) --- README.md | 1 + lib/usb.js | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 54382d80..406ef742 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,7 @@ si.cpu() (last 7 major and minor version releases) +- Version 5.23.0: `usb()` added serial number (linux) - Version 5.22.0: `wifiConnections()` added signal quality - Version 5.21.0: `graphics()` added subVendor (linux) - Version 5.20.0: `mem()` added writeback and dirty (linux) diff --git a/lib/usb.js b/lib/usb.js index 8e9d354b..0a6edba9 100644 --- a/lib/usb.js +++ b/lib/usb.js @@ -114,7 +114,6 @@ function getDarwinUsbType(name) { return result; } - function parseDarwinUsb(usb, id) { const result = {}; result.id = id; @@ -258,7 +257,7 @@ function usb(callback) { const parts = stdout.toString().split(/\n\s*\n/); for (let i = 0; i < parts.length; i++) { const usb = parseWindowsUsb(parts[i].split('\n'), i); - if (usb) { + if (usb && result.filter(x => x.deviceId === usb.deviceId).length === 0) { result.push(usb); } }