stringifyAddressv6Expanded(address: Addressv6 | ParsedAddressv6): string
Stringifies an IPv6 address to full uncompressed colon-hexadecimal notation.
Every one of the 8 groups is written with all 4 hex digits, and no run of
zero groups is replaced with ::. This is the counterpart of
stringifyAddressv6, which produces the canonical compressed form.
To expand a string, parse it first: stringifyAddressv6Expanded(parseAddressv6(s)).
Takes either the bare 128-bit bigint or a ParsedAddressv6; given
the latter, a truthy zoneId is appended after %. The zone constraint
of stringifyAddressv6 applies: no %, / or whitespace.
Basic stringifying
Basic stringifying
import { assertEquals } from "@std/assert"; import { stringifyAddressv6Expanded } from "@hertzg/ip/addressv6"; assertEquals(stringifyAddressv6Expanded(0n), "0000:0000:0000:0000:0000:0000:0000:0000"); assertEquals(stringifyAddressv6Expanded(1n), "0000:0000:0000:0000:0000:0000:0000:0001"); assertEquals(stringifyAddressv6Expanded(42540766411282592856903984951653826561n), "2001:0db8:0000:0000:0000:0000:0000:0001");
Expanding a string, zone included
Expanding a string, zone included
import { assertEquals } from "@std/assert"; import { parseAddressv6, stringifyAddressv6, stringifyAddressv6Expanded } from "@hertzg/ip/addressv6"; const address = parseAddressv6("2001:db8::1"); assertEquals(stringifyAddressv6(address), "2001:db8::1"); assertEquals(stringifyAddressv6Expanded(address), "2001:0db8:0000:0000:0000:0000:0000:0001"); assertEquals( stringifyAddressv6Expanded(parseAddressv6("fe80::1%eth0")), "fe80:0000:0000:0000:0000:0000:0000:0001%eth0", );
address: Addressv6 | ParsedAddressv6
The address as a 128-bit bigint, or a parse result