Options
All
  • Public
  • Public/Protected
  • All
Menu

Class IP

Hierarchy

  • IP

Index

Constructors

constructor

  • new IP(): IP
  • Returns IP

Properties

Protected m_bytes

m_bytes: Buffer = ...

Protected m_isV4

m_isV4: boolean = false

Protected Optional m_zone

m_zone: string

Accessors

buffer

  • get buffer(): Buffer
  • Returns the IP address as a Buffer

    Returns Buffer

bytes

  • get bytes(): Uint8Array
  • Returns the IP address as a Uint8Array

    Returns Uint8Array

decimal

  • get decimal(): BigInteger
  • Returns the decimal representation of the IP Address

    Returns BigInteger

isV4

  • get isV4(): boolean
  • Whether the address is a v4 Address

    Returns boolean

zone

  • get zone(): undefined | string
  • Returns a zone (RFC6874) ID if available

    Returns undefined | string

Methods

toString

  • toString(encoding?: "mapped" | "expanded"): string
  • Returns the string representation of the IP address

    Parameters

    • Optional encoding: "mapped" | "expanded"

      Whether we will use any special encoding or not

    Returns string

Static Private compressV6

  • compressV6(address: string): string
  • Parameters

    • address: string

    Returns string

Static Private expandV6

  • expandV6(address: string): string
  • Parameters

    • address: string

    Returns string

Static fromDecimal

  • fromDecimal(decimal: number | BigInteger, forceV6?: boolean): IP
  • Creates a new instance of an IP address from the given decimal value

    Parameters

    • decimal: number | BigInteger

      the decimal representation of the IP address to create

    • forceV6: boolean = false

      whether to force the decimal into v6 space

    Returns IP

Static Private isIPv4

  • isIPv4(ip: string): boolean
  • Parameters

    • ip: string

    Returns boolean

Static Private isIPv6

  • isIPv6(ip: string): boolean
  • Parameters

    • ip: string

    Returns boolean

Static parse

  • parse(address: string): IP
  • Parses the given string into an IP address

    Parameters

    • address: string

      the string representation of the IP address to parse

    Returns IP

Static splitHostPort

  • splitHostPort(host: string): [string, number]
  • Splits a host (ie. ip:port) into the IP address and port number

    Parameters

    • host: string

      the host to split

    Returns [string, number]

Static Private v4StringToBuffer

  • v4StringToBuffer(ip: string): Buffer
  • Parameters

    • ip: string

    Returns Buffer

Static Private v4ToString

  • v4ToString(bytes: Buffer, mapped?: boolean): string
  • Parameters

    • bytes: Buffer
    • mapped: boolean = false

    Returns string

Static Private v6StringToBuffer

  • v6StringToBuffer(ip: string): [Buffer, string?]
  • Parameters

    • ip: string

    Returns [Buffer, string?]

Static Private v6ToString

  • v6ToString(bytes: Buffer, expanded?: boolean): string
  • Parameters

    • bytes: Buffer
    • expanded: boolean = false

    Returns string

Generated using TypeDoc