1.6.2 • Published 5 months ago

ip-sub v1.6.2

Weekly downloads
79
License
MIT
Repository
github
Last release
5 months ago

IP-sub

A small utility to manipulate prefixes. There are other possible solutions on npm, this was created mostly to prioritize performance.

It implements the following methods.

  • getIpAndCidr - if you provide "99.88.77.0/24" it returns "99.88.77.0", 24

  • isValidPrefix - it returns true/false

  • isValidIP - it returns true/false

  • sortByPrefix - it is a sorting function for an array or prefixes. It sorts the array based on the entire prefix.

  • sortByPrefixLength - it is a sorting function for an array or prefixes. It sorts the array based on the amount of bits of the netmask (from less specific to more specific).

  • expandIP - if you provide something like "127/8", you will receive "127.0.0.0/8". If you provide "2001:db8:123::", you will receive "2001:0db8:0123:0000:0000:0000:0000:0000". In case of IPv6, you can also do expandIP("2001:db8:123::", true) to obtain the expanded-shortened version "2001:db8:123:0:0:0:0:0" (without 0 padding).

  • isEqualIP - it checks for IP equality, it takes into account expansions and cases. E.g. "2001:db8:123::" is equal to "2001:DB8:123::0"

  • isEqualPrefix - same as above, but with prefixes

  • getAddressFamily - it returns 4 or 6 (integers)

  • toBinary - it returns the binary representation of the IP

  • fromBinary - it returns the decimal/hexadecimal representation of a binary IP (essentially, the opposite of the previous function)

  • applyNetmask - it applies the netmask. E.g., if you provide "99.88.77.0/24" you will get the binary representation of "99.88.77.0" truncated at 24 bits

  • isSubnet - you provide two prefixes and you will get true if the second one is subnet of the first one.

  • isSubnetBinary - same as above but directly with binary representation

  • cidrToRange - given a prefix in cidr notation, it returns the first and last ip address of the range.

1.6.2

5 months ago

1.6.1

5 months ago

1.6.0

5 months ago

1.5.8

9 months ago

1.5.7

9 months ago

1.5.6

9 months ago

1.5.5

1 year ago

1.5.4

1 year ago

1.5.3

1 year ago

1.5.2

1 year ago

1.4.0

2 years ago

1.5.1

2 years ago

1.5.0

2 years ago

1.3.9

2 years ago

1.3.7

2 years ago

1.3.6

2 years ago

1.3.8

2 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.2.0

4 years ago

1.2.2

3 years ago

1.3.0

3 years ago

1.2.1

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.28

4 years ago

1.0.27

4 years ago

1.0.26

4 years ago

1.0.25

4 years ago

1.0.24

4 years ago

1.0.23

4 years ago

1.0.22

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

6 years ago

1.0.0

6 years ago