Skip to content

Release 2.1.0

Compare
Choose a tag to compare
@github-actions github-actions released this 08 Jul 18:04

New features:

  • Added toBits() to IPv4/IPv6, producing e.g. [1, 1, 0, 0, 0, 0, ...] for 192.0.0.0 (length 32 and 128 for IPv4 and IPv6 respectively)
  • Added IPv4.fromBits(bits) and IPv6.fromBits(bits), accepting the "bit arrays" produced from toBits()
    • Accepts arrays (with length 32 for IPv4 and length 128 for IPv6) filled with 0's and 1's
  • Added IPv4.bits = 32 and IPv6.bits = 128, both on the class and class objects (e.g. new IPv4('0.0.0.0').bits)
  • Added getAmount() to IPMatch, allowing you see how many IP addresses a match (e.g. a range/subnet) matches
  • Added isSubsetOf(mask) to IPMask, allowing to check whether one mask is a subset of another mask
    • Mask A is a subset of mask B if every IP address that is matched by A is also matched by B

Changes:

  • Caching added to convertToMasks()/convertToSubnets(), making repeated calls a lot cheaper
  • matches(ip) in IPRange no longer errors for passing an IPv4 to an IPv6 range and vice-versa, instead returning false now
    • This is line with matches() in general, where it only errors if the input is neither an IP nor a string that can be converted to one