Class: abstract
IPAddress
Defined in: IPAddress.ts:24
Sealed
Represents an Internet Protocol (IP) address.
Extended by
Properties
value
readonly
value:bigint
Defined in: IPAddress.ts:28
Integer representation of the IP address.
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
binary()
abstract
binary():ArrayBufferView
Defined in: IPAddress.ts:60
Returns the binary representation of the IP address.
Returns
ArrayBufferView
equals()
equals(
other
):boolean
Defined in: IPAddress.ts:67
Checks if the given address is equal to this address.
Parameters
other
IPAddress
Address to compare.
Returns
boolean
offset()
abstract
offset(offset
):IPAddress
Defined in: IPAddress.ts:97
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
IPAddress
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.
toString()
abstract
toString():string
Defined in: IPAddress.ts:85
Returns the IP address as a string.
Returns
string
fromString()
static
fromString(ip
,resolveMapped?
):IP
Defined in: IPAddress.ts:47
Creates an IP address from a string.
Parameters
ip
string
String representation of the IP address.
resolveMapped?
boolean
= false
Whether to resolve IPv4-mapped IPv6 addresses (see IPv6.hasMappedIPv4).
Returns
Throws
RangeError If the string is not a valid IPv4 or IPv6 address.