(input: string)
| 922 | * @since 4.0.0 |
| 923 | */ |
| 924 | export const macAddressFromString = (input: string): Result.Result<MacAddress, NetAddressError> => { |
| 925 | if (!/^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$/.test(input)) { |
| 926 | return addressError(input, "expected six two-digit hexadecimal octets separated by colons") |
| 927 | } |
| 928 | return Result.succeed(makeMac(new Uint8Array(input.split(":").map((part) => Number.parseInt(part, 16))))) |
| 929 | } |
| 930 | |
| 931 | /** |
| 932 | * Parses a trusted colon-separated MAC address, throwing on failure. |
no test coverage detected