@cldn/ip - v1.0.4
    Preparing search index...

    Class Subnet<T>

    A subnet of IP addresses

    Type Parameters

    Implements

    Index

    Constructors

    • Create new subnet instance

      Type Parameters

      Parameters

      • address: T

        An IP address

      • suffix: number

        Subnet suffix bits

      Returns Subnet<T>

      RangeError If the suffix is greater than the IP address family bit-length

    Properties

    address: T

    Subnet address (i.e. the first/gateway IP address of the network)

    suffix: number

    Subnet suffix bits

    IPV4_MAPPED_IPV6: Subnet<IPv4 | IPv6> = ...

    IPv4-mapped IPv6 subnet

    Methods

    • Iterate all IP addresses in this subnet

      NOTE: This can be slow for large subnets. If you need to check if an IP address is in the subnet, use Subnet#contains.

      Returns IterableIterator<T>

    • Get the last IP address in the subnet (i.e. broadcast address)

      Returns T

    • Check if the provided IP address is in this subnet

      Parameters

      • address: T

      Returns boolean

    • Iterate all IP addresses in this subnet

      NOTE: This can be slow for large subnets. If you need to check if an IP address is in the subnet, use Subnet#contains.

      Returns IterableIterator<T>

    • Get the network mask

      Returns bigint

    • A set containing all IP addresses in this subnet

      NOTE: This can be slow for large subnets. If you need to check if an IP address is in the subnet, use Subnet#contains.

      Returns Set<T>

    • Get the number of addresses in this subnet. This number includes the broadcast and gateway addresses, so for the number of usable addresses, subtract 2.

      Returns bigint

    • String representation of this subnet in CIDR notation

      Returns string

      "203.0.113.0/24"
      
    • Get the network wildcard mask

      Returns bigint