From b43b59e526a7f3f45bc57d0f09c115967031837a Mon Sep 17 00:00:00 2001 From: Nathan Kellenicki Date: Thu, 9 Jan 2020 10:56:59 -0800 Subject: [PATCH] Virtual ports tested --- src/hubs/basehub.ts | 2 +- src/hubs/lpf2hub.ts | 12 ++---------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/hubs/basehub.ts b/src/hubs/basehub.ts index fb6f0d1..d917ead 100644 --- a/src/hubs/basehub.ts +++ b/src/hubs/basehub.ts @@ -188,7 +188,7 @@ export class BaseHub extends EventEmitter { if (portId !== undefined) { return this._attachedDevices[portId]; } else { - throw new Error(`Port ${portName} does not exist on this hub type`); + return undefined; } } diff --git a/src/hubs/lpf2hub.ts b/src/hubs/lpf2hub.ts index 0efdb31..bd56b4e 100644 --- a/src/hubs/lpf2hub.ts +++ b/src/hubs/lpf2hub.ts @@ -95,19 +95,11 @@ export class LPF2Hub extends BaseHub { public createVirtualPort (firstPortName: string, secondPortName: string) { - const firstPortId = this._portMap[firstPortName]; - if (!firstPortId) { - throw new Error(`Port ${firstPortName} does not exist on this hub`); - } - const secondPortId = this._portMap[secondPortName]; - if (!secondPortId) { - throw new Error(`Port ${secondPortName} does not exist on this hub`); - } - const firstDevice = this._getDeviceByPortId(firstPortId); + const firstDevice = this.getDeviceAtPort(firstPortName); if (!firstDevice) { throw new Error(`Port ${firstPortName} does not have an attached device`); } - const secondDevice = this._getDeviceByPortId(secondPortId); + const secondDevice = this.getDeviceAtPort(secondPortName); if (!secondDevice) { throw new Error(`Port ${secondPortName} does not have an attached device`); }