function stringify
stringify(
bytes: Uint8Array,
delimiter?: ":" | "-"
): string

Formats a 6-byte EUI-48 MAC address as a lowercase hex string.

Produces the canonical colon-delimited form (aa:bb:cc:dd:ee:ff) by default. Pass "-" for the hyphenated IEEE form.

Examples

Default (colon)

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

assertEquals(
  stringify(new Uint8Array([0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff])),
  "aa:bb:cc:dd:ee:ff",
);

Hyphen

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

assertEquals(
  stringify(new Uint8Array([0x00, 0x11, 0x22, 0x33, 0x44, 0x55]), "-"),
  "00-11-22-33-44-55",
);

Parameters

6-byte MAC address.

optional
delimiter: ":" | "-" = :

Octet delimiter — ":" (default) or "-".

Return Type

string

Lowercase hex MAC string.

Throws

TypeError

when bytes.length !== 6.

Usage

import { stringify } from ".";