function stringifyCidrv6Expanded
stringifyCidrv6Expanded(cidr: Addressv6 | ParsedAddressv6 | ParsedCidrv6): string

Stringifies an IPv6 CIDR block, or an address, to CIDR notation with the address written in full uncompressed colon-hexadecimal.

The expanded counterpart of stringifyCidrv6, with the same dialect, default and zone rules: /prefixLength or /mask as stored, /128 for a bare address, %zoneId before the slash when there is one. A mask is written expanded too, so both halves line up.

Examples

Example 1

import { assertEquals } from "@std/assert";
import { parseCidrv6, stringifyCidrv6Expanded } from "@hertzg/ip/cidrv6";

assertEquals(
  stringifyCidrv6Expanded(parseCidrv6("2001:db8::/32")),
  "2001:0db8:0000:0000:0000:0000:0000:0000/32",
);
assertEquals(
  stringifyCidrv6Expanded(parseCidrv6("fe80::%ether1/64")),
  "fe80:0000:0000:0000:0000:0000:0000:0000%ether1/64",
);
assertEquals(
  stringifyCidrv6Expanded(parseCidrv6("fe80::/ffff:ffff::")),
  "fe80:0000:0000:0000:0000:0000:0000:0000/ffff:ffff:0000:0000:0000:0000:0000:0000",
);
assertEquals(stringifyCidrv6Expanded(1n), "0000:0000:0000:0000:0000:0000:0000:0001/128");

Parameters

The CIDR block in either dialect, a parse result, or a bare address

Return Type

string

The CIDR notation string with all 8 groups of the address written in full

Throws

RangeError

If the address, or a mask, is not a 128-bit unsigned integer

Usage

import { stringifyCidrv6Expanded } from "mod.ts";