Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Ipv4Address

Representation of an IPv4 address. Provides various utility methods like equality checking.

remarks

Avoid direct instantiation; use ipv4.address instead.

Hierarchy

  • Ipv4Address

Index

Constructors

Properties

Accessors

Methods

Constructors

Properties

_address: number

Accessors

  • get address(): number
  • The address as a number

    Returns number

Methods

  • Compares if two IPv4 addresses are the same.

    example
    import { ipv4 as ip } from 'cidr-block'

    function isLoopback(address: Ipv4Representable) {
    return ip.address(address).equals('127.0.0.1')
    }

    Parameters

    Returns boolean

    if the other IP address is the same

  • Calculates the next logical IPv4 address.

    example
    import { ipv4 as ip } from 'cidr-block'

    const myIp = ip.address('52.89.32.255')
    myIp.nextIp() // ==> '52.89.33.0'

    Returns Ipv4Address

    the next consecutive IPv4 address

  • example
    import { ipv4 as ip } from 'cidr-block'

    const myIp = ip.address('52.89.32.19')
    myIp.previousIp() // ==> '52.89.32.18'

    Returns Ipv4Address

    the preceding IPv4 address

  • toString(): string
  • Returns the string representation of the address

    example
    import { ipv4 as ip } from 'cidr-block'

    ip.address(255) // ==> '0.0.0.255'
    ip.address(0b11111111_00000000_11111111_00000000) // ==> '255.0.255.0'

    Returns string

    the IPv4 address as a string

Generated using TypeDoc