MCPcopy Create free account
hub / github.com/Effect-TS/effect / macAddressFromString

Function macAddressFromString

packages/effect/src/net/NetAddress.ts:924–929  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

922 * @since 4.0.0
923 */
924export 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.

Callers 2

macAddressFromInputFunction · 0.85

Calls 5

addressErrorFunction · 0.85
makeMacFunction · 0.70
succeedMethod · 0.45
mapMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected