Class IPv4Addr

Expand description

The class represents an IPv4 address.

Constructors§

source§

constructor

source§

new IPv4Addr(value: BigInteger): IPv4Addr

Construct an IPv4 address from the given integer value.

Methods§

source§

compare

source§

compare(other: IPv4Addr): 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: IPv4Addr): 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: IPv4Addr): 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: IPv4Addr): 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: IPv4Addr): 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): IPv4Addr

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 | IPv4Addr

Get the next address of the address.

source§

prev

source§

prev(): null | IPv4Addr

Get the previous address of the address.

source§

toInt

source§

toInt(): BigInteger

Get the corresponding integer of the address.

source§

toString

source§

toString(): string

Get the string representation of the address.

source§

netMask

source§

netMask(prefixLen: string | number): IPv4Addr

Construct the subnet mask address corresonding to the given prefix length.

If the prefixLen parameter is not a number between 0 and 32 (inclusive), the function will throw an error.

const mask = IPv4Addr.netMask(24);
assert(mask.toString() === '255.255.255.0');
source§

parse

source§

parse(s: string): IPv4Addr

Parse an IPv4 address string and return an instance of IPv4Addr.

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