Port: is.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
Akos Kitta 2020-07-20 10:30:21 +02:00
parent dfed2350bd
commit 2f3fe27da3

View File

@ -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}`