Skip to content

Commit 50dbf8b

Browse files
committed
fixup! move isAddressInfo, add .address check
1 parent c04ddcd commit 50dbf8b

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

src/node/util.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -485,15 +485,6 @@ export function isNodeJSErrnoException(error: unknown): error is NodeJS.ErrnoExc
485485
return error !== undefined && (error as NodeJS.ErrnoException).code !== undefined
486486
}
487487

488-
/**
489-
* A helper function which returns a boolean indicating whether
490-
* the given address is AddressInfo and has .address
491-
* and a .port property.
492-
*/
493-
export function isAddressInfo(address: unknown): address is net.AddressInfo {
494-
return address !== null && typeof address !== "string" && (address as net.AddressInfo).port !== undefined
495-
}
496-
497488
// TODO: Replace with proper templating system.
498489
export const escapeJSON = (value: cp.Serializable) => JSON.stringify(value).replace(/"/g, """)
499490

test/unit/node/update.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import { AddressInfo } from "net"
44
import * as path from "path"
55
import { SettingsProvider, UpdateSettings } from "../../../src/node/settings"
66
import { LatestResponse, UpdateProvider } from "../../../src/node/update"
7-
import { isAddressInfo } from "../../../src/node/util"
8-
import { clean, mockLogger, tmpdir } from "../../utils/helpers"
7+
import { clean, isAddressInfo, mockLogger, tmpdir } from "../../utils/helpers"
98

109
describe("update", () => {
1110
let version = "1.0.0"

test/utils/helpers.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,17 @@ export function idleTimer(message: string, reject: (error: Error) => void, delay
105105
},
106106
}
107107
}
108+
109+
/**
110+
* A helper function which returns a boolean indicating whether
111+
* the given address is AddressInfo and has .address
112+
* and a .port property.
113+
*/
114+
export function isAddressInfo(address: unknown): address is net.AddressInfo {
115+
return (
116+
address !== null &&
117+
typeof address !== "string" &&
118+
(address as net.AddressInfo).port !== undefined &&
119+
(address as net.AddressInfo).address !== undefined
120+
)
121+
}

0 commit comments

Comments
 (0)