Class IPv6Addr

Expand description

The class represents an IPv6 address.

Constructors§

source§

constructor

source§

new IPv6Addr(value: BigInteger): IPv6Addr

Construct an IPv6 address from the given integer value.

Methods§

source§

compare

source§

compare(other: IPv6Addr): number

Performs a comparison between two addresses.

If the two addresses are equal, returns 0. If the address is greater than the parameter, returns 1. If the address is less than the parameter, returns -1.

source§

eq

source§

eq(other: IPAddr<any>): boolean

Determine if the two addresses are equal.

If the two addresses are in different type, eg. one is IPv4Addr and another is IPv6Addr, the function will always return false.

source§

gt

source§

gt(other: IPv6Addr): boolean

Determine if the address is greater than the parameter.

If the two addresses are in different type, eg. one is IPv4Addr and another is IPv6Addr, the function will throw an error.

source§

gte

source§

gte(other: IPv6Addr): boolean

Determine if the address is greater than or equal to the parameter.

If the two addresses are in different type, eg. one is IPv4Addr and another is IPv6Addr, the function will throw an error.

source§

isMax

source§

isMax(): boolean

Determine if the address is the maximum possible address.

source§

isMin

source§

isMin(): boolean

Determine if the address is the minimum possible address.

source§

isSameType

source§

isSameType(other: object): boolean

Determine if the given object is an instance of the address' class.

source§

lt

source§

lt(other: IPv6Addr): boolean

Determine if the address is less than the parameter.

If the two addresses are in different type, eg. one is IPv4Addr and another is IPv6Addr, the function will throw an error.

source§

lte

source§

lte(other: IPv6Addr): boolean

Determine if the address is less than or equal to the parameter.

If the two addresses are in different type, eg. one is IPv4Addr and another is IPv6Addr, the function will throw an error.

source§

neq

source§

neq(other: IPAddr<any>): boolean

Determine if the two addresses are unequal.

If the two addresses are in different type, eg. one is IPv4Addr and another is IPv6Addr, the function will always return true.

source§

newInstance

source§

newInstance(value: BigInteger): IPv6Addr

Create a new instance of the address' class. This method is called by the base class most of the time.

source§

next

source§

next(): null | IPv6Addr

Get the next address of the address.

source§

prev

source§

prev(): null | IPv6Addr

Get the previous address of the address.

source§

toInt

source§

toInt(): BigInteger

Get the corresponding integer of the address.

source§

toString

source§

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

source§

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::');
source§

parse

source§

parse(s: string): IPv6Addr

Parse an IPv6 address string and return an instance of IPv6Addr.

If the parameter s is not a valid string representation of an IPv6 address, the function will throw an error.