From 2f3fe27da3166d0d8ae1e41d0744f2387c35f936 Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Mon, 20 Jul 2020 10:30:21 +0200 Subject: [PATCH] Port: `is`. Signed-off-by: Akos Kitta --- arduino-ide-extension/src/common/protocol/boards-service.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arduino-ide-extension/src/common/protocol/boards-service.ts b/arduino-ide-extension/src/common/protocol/boards-service.ts index a98094c7..f1bd1fef 100644 --- a/arduino-ide-extension/src/common/protocol/boards-service.ts +++ b/arduino-ide-extension/src/common/protocol/boards-service.ts @@ -94,6 +94,10 @@ export namespace Port { } } + export function is(arg: any): arg is Port { + return !!arg && 'address' in arg && typeof arg['address'] === 'string' && 'protocol' in arg && typeof arg['protocol'] === 'string'; + } + export function toString(port: Port, options: { useLabel: boolean } = { useLabel: false }): string { if (options.useLabel && port.label) { return `${port.address} ${port.label}`