Class: IPv6
Defined in: IPv6.ts:22
Represents an Internet Protocol version 6 (IPv6) address.
Extends
Constructors
Constructor
new IPv6(
value):IPv6
Defined in: IPv6.ts:34
Creates a new IPv6 address instance.
Parameters
value
bigint
128-bit unsigned integer.
Returns
IPv6
Throws
TypeError If the value is not a 128-bit unsigned integer.
Overrides
IPAddress.constructor
Properties
value
readonlyvalue:bigint
Defined in: IPAddress.ts:28
Integer representation of the IP address.
Inherited from
BIT_LENGTH
staticBIT_LENGTH:number=128
Defined in: IPv6.ts:26
Bit length of IPv6 addresses.
Methods
[toPrimitive]()
[toPrimitive](
hint):string|bigint
Defined in: IPAddress.ts:76
Returns the IP address as a bigint or string primitive.
Parameters
hint
Preferred primitive type.
"string" | "number" | "default"
Returns
string | bigint
Inherited from
binary()
binary():
Uint16Array
Defined in: IPv6.ts:109
Returns the 8 hextets of the IPv6 address.
Returns
Overrides
equals()
equals(
other):boolean
Defined in: IPAddress.ts:67
Checks if the given address is equal to this address.
Parameters
other
Address to compare.
Returns
boolean
Inherited from
getMappedIPv4()
getMappedIPv4():
IPv4
Defined in: IPv6.ts:136
Returns the IPv4-mapped IPv6 address.
Returns
The IPv4 address from the least significant 32 bits of this IPv6 address.
See
hasMappedIPv4()
hasMappedIPv4():
boolean
Defined in: IPv6.ts:126
Checks whether this IPv6 address is an IPv4-mapped IPv6 address as defined by the ::ffff:0:0/96 prefix. This method does not detect other IPv4 embedding or tunnelling formats.
Returns
boolean
offset()
offset(
offset):IPv6
Defined in: IPv6.ts:157
Returns a new IP address offset by the given amount from this address.
Parameters
offset
Number of steps to offset, positive or negative.
number | bigint
Returns
IPv6
Examples
ip.offset(1) // Returns the next IP address.ip.offset(-1) // Returns the previous IP address.IPAddress.fromString("203.0.113.42").offset(-18) // Returns 203.0.113.24.Throws
TypeError If the resulting address is outside the IP address family range.
Overrides
toString()
toString():
string
Defined in: IPv6.ts:149
Returns the IP address as a string in colon-hexadecimal notation.
Returns
string
Overrides
fromBinary()
staticfromBinary(hextets):IPv6
Defined in: IPv6.ts:46
Creates an IPv6 address instance from hextets.
Parameters
hextets
Typed array of 8 hextets.
Returns
IPv6
Throws
RangeError If the number of hextets is not 8.
fromString()
staticfromString(ip):IPv6
Defined in: IPv6.ts:67
Creates an IPv6 address instance from a string.
Parameters
ip
string
String representation of an IPv6 address.
Returns
IPv6
Throws
RangeError If the string is not a valid IPv6 address.