cidr-block - v2.1.1
    Preparing search index...

    Function parseOctets

    • Parses the given IPv4 address into its octet representation.

      Parameters

      • ip: Ipv4AddressLiteral

        The IPv4 address to parse, which can be in string, number, or octet array format.

      Returns Ipv4AddressOctets

      An array of four numbers representing the octets of the IPv4 address.

      import { ipv4 } from 'cidr-block';

      ipv4.parseOctets("192.168.1.1"); // [192, 168, 1, 1]
      ipv4.parseOctets(3232235777); // [192, 168, 1, 1]
      ipv4.parseOctets([10, 0, 0, 1]); // [10, 0, 0, 1]

      If the input is not a valid IPv4 address.