Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const zeroRegex = /(?:[0]{1,2}[:-]){5}[0]{1,2}/
* Get the first proper MAC address
* @param iface If provided, restrict MAC address fetching to this interface
*/
export default function getMAC(iface?: string): string {
export default function getMAC(iface?: string): string| Error {
const list = networkInterfaces()
if (iface) {
const parts = list[iface]
Expand All @@ -21,7 +21,7 @@ export default function getMAC(iface?: string): string {
}
throw new Error(`interface ${iface} had no valid mac addresses`)
} else {
for (const [key, parts] of Object.entries(list)) {
for (const [_, parts] of Object.entries(list)) {
// for some reason beyond me, this is needed to satisfy typescript
// fix https://github.com/bevry/getmac/issues/100
if (!parts) continue
Expand All @@ -36,6 +36,6 @@ export default function getMAC(iface?: string): string {
}

/** Check if the input is a valid MAC address */
export function isMAC(macAddress: string) {
export function isMAC(macAddress: string):boolean {
return macRegex.test(macAddress)
}