Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RangedSet<T>

Represents a continuous segment of either IPv4 or IPv6 numbers without adhering to classless inter-domain routing scheme for allocating IP addresses.

Type parameters

Hierarchy

  • RangedSet

Implements

Index

Constructors

constructor

  • new RangedSet(first: T, last: T): RangedSet
  • Constructor for an instance of RangedSet from an instance of either IPv4CidrRange or IPv6CidrRange

    Throws an exception if first IP number is not less than given last IP number

    Parameters

    • first: T

      the first IP number of the range

    • last: T

      the last IP number of the range

    Returns RangedSet

Properties

bitValue

bitValue: BigInteger

Private currentValue

currentValue: T

Private first

first: T

Private last

last: T

Methods

[Symbol.iterator]

append

  • Appends given range with this range. The last IP in this range should be adjacent to the first IP in range to append

    Parameters

    • otherRange: RangedSet<T>

      the other range to append

    Returns RangedSet<T>

contains

  • Checks if this range contains the given other range.

    Parameters

    Returns boolean

difference

getFirst

  • getFirst(): T
  • Returns the first IP number in the range

    Returns T

getLast

  • getLast(): T
  • Returns the last IP number in the range

    Returns T

getSize

  • getSize(): BigInteger
  • Returns the size, which is the number of IP numbers in the range.

    Returns BigInteger

inside

  • Checks if this range is inside another range.

    Parameters

    • otherRange: RangedSet<T>

      the other range to check if this range is inside of.

    Returns boolean

isCidrAble

  • isCidrAble(): boolean
  • Check if this range can be converted to a CIDR range.

    Returns boolean

isConsecutive

  • isConsecutive(otherRange: RangedSet<T>): boolean
  • Checks if this range is consecutive with another range.

    This means if the two ranges can be placed side by side, without any gap. Hence Equal or ranges contained inside one another, or overlapping ranges are not considered as consecutive.

    Parameters

    • otherRange: RangedSet<T>

      the other range to check if this range is consecutive to.

    Returns boolean

isEquals

  • isEquals(otherRange: RangedSet<T>): boolean
  • Check if this range is equal to the given other range.

    Parameters

    • otherRange: RangedSet<T>

      the other range to check if equal to this range.

    Returns boolean

isGreaterThan

  • isGreaterThan(otherRange: RangedSet<T>): boolean
  • Check if this range is greater than the given range.

    Parameters

    • otherRange: RangedSet<T>

      the other range to check if greater than.

    Returns boolean

isLessThan

  • isLessThan(otherRange: RangedSet<T>): boolean
  • Check if this range is less than the given range.

    Parameters

    • otherRange: RangedSet<T>

      the other range to check if less than.

    Returns boolean

isOverlapping

  • isOverlapping(otherRange: RangedSet<T>): boolean
  • Checks of this range overlaps with a given other range.

    This means it checks if part of a range is part of another range without being totally contained in the other range. Hence Equal or ranges contained inside one another are not considered as overlapping.

    Parameters

    • otherRange: RangedSet<T>

      the other range to check if it overlaps with this range.

    Returns boolean

prepend

  • Prepends given range with this range. The last IP in the given range should be adjacent to the first IP in this range

    Parameters

    • otherRange: RangedSet<T>

      the other range to prepend

    Returns RangedSet<T>

subtract

take

takeSubRange

  • Returns a sub range of a given size from this range.

    Parameters

    • offset: BigInteger

      offset from this range where the subrange should begin

    • size: BigInteger

      the size of the range

    Returns RangedSet<AbstractIPNum>

toCidrRange

Private toIPv4CidrRange

Private toIPv6CidrRange

toRangeString

  • toRangeString(): string
  • Converts to a string representation of the range in the form of: -

    Returns string

union

  • Creates a range that is a union of this range and the given other range.

    Parameters

    • otherRange: RangedSet<T>

      the other range to combine with this range

    Returns RangedSet<T>

Static fromCidrRange

Static fromRangeString

  • Convenience method for constructing an instance of RangedSet from a range string in the form of firstIp-lastIp

    Parameters

    • rangeString: string

      string in the form of firstIp-lastIp

    Returns RangedSet<IPv4> | RangedSet<IPv6>

Static fromSingleIP

  • Convenience method for constructing an instance of RangedSet from a single IP number.

    Type parameters

    Parameters

    • ip: T

      The IP number, either IPv4 or IPv6 to construct the range from.

    Returns RangedSet<T>

Generated using TypeDoc