Class IPv6Addr
Expand description
Constructors§
Methods§
source§toString
toString
source§toString(long?: boolean): string
toString(long?: boolean): string
Get the string representation of the address.
By default, the function returns the normalized string defined in RFC 5952.
When the long parameter is true, the function returns a long representation.
const addr = IPv6Addr.parse('2001:db8:0:0:0:0:0:1');
assert(addr.toString() === '2001:db8::1');
assert(addr.toString(true) === '2001:0db8:0000:0000:0000:0000:0000:0001');
source§netMask
netMask
source§netMask(prefixLen: string | number): IPv6Addr
netMask(prefixLen: string | number): IPv6Addr
Construct the subnet mask address corresonding to the given prefix length.
If the prefixLen parameter is not a number between 0 and 128 (inclusive),
the function will throw an error.
const mask = IPv6Addr.netMask(64);
assert(mask.toString() === 'ffff:ffff:ffff:ffff::');
The class represents an IPv6 address.