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

    Function address

    • Creates a new Ipv6Address instance from the given literal. Valid formats include string (with :: compression support), bigint, or hextets array.

      Parameters

      Returns Ipv6Address

      A new Ipv6Address instance.

      import { ipv6 } from 'cidr-block';

      const addr1 = ipv6.address("2001:db8::1");
      const addr2 = ipv6.address(42540766411282592856903984951653826561n);
      const addr3 = ipv6.address([0x2001, 0xdb8, 0, 0, 0, 0, 0, 1]);
      import { ipv6 } from 'cidr-block';

      const addr = ipv6.address("2001:db8::1");
      addr.toString(); // "2001:db8::1" (compressed)
      addr.toFullString(); // "2001:0db8:0000:0000:0000:0000:0000:0001"
      addr.toBigInt(); // 42540766411282592856903984951653826561n
      addr.hextets(); // [0x2001, 0xdb8, 0, 0, 0, 0, 0, 1]
      import { ipv6 } from 'cidr-block';

      const addr = ipv6.address("2001:db8::1");
      addr.equals("2001:db8::1"); // true
      addr.isGreaterThan("2001:db8::"); // true
      addr.isLessThan("2001:db8::2"); // true
      import { ipv6 } from 'cidr-block';

      const addr = ipv6.address("2001:db8::1");
      addr.nextAddress()?.toString(); // "2001:db8::2"
      addr.previousAddress()?.toString(); // "2001:db8::"
      import { ipv6 } from 'cidr-block';

      ipv6.address("::1").isLoopbackAddress(); // true
      ipv6.address("fc00::1").isUniqueLocalAddress(); // true
      ipv6.address("fe80::1").isLinkLocalAddress(); // true
      ipv6.address("ff02::1").isMulticastAddress(); // true

      If the input is not a valid IPv6 address.