EUI-48 MAC address parsing and stringification.

Sister package to @hertzg/ip — same shape, single concern: convert between the canonical 17-character text form (aa:bb:cc:dd:ee:ff or AA-BB-CC-DD-EE-FF) and the 6-byte binary form.

The functions are intentionally named parse and stringify (not parseMac/stringifyMac) so callers can pick a name that fits the surrounding code:

// namespace import — short call sites
import * as mac from "@hertzg/mac";
mac.parse("aa:bb:cc:dd:ee:ff");

// aliased named import — disambiguates when mixing with @hertzg/ip
import { parse as parseMac, stringify as stringifyMac } from "@hertzg/mac";
parseMac("aa:bb:cc:dd:ee:ff");

Examples

Round-trip

import { assertEquals } from "@std/assert";
import { parse, stringify } from "@hertzg/mac";

const bytes = parse("AA:BB:CC:DD:EE:FF");
assertEquals(bytes, new Uint8Array([0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff]));
assertEquals(stringify(bytes), "aa:bb:cc:dd:ee:ff");