@cursorsdottsx/i

A few IP address utilities (only v4).

Usage no npm install needed!

<script type="module">
  import cursorsdottsxI from 'https://cdn.skypack.dev/@cursorsdottsx/i';
</script>

README

| a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z |

I is for IP

@cursorsdottsx/i

A few IP address utilities (only v4). More will be added later when I actually understand how IPs work.

Use NPM or Yarn to install:

npm install @cursorsdottsx/i
yarn add @cursorsdottsx/i

Import the utility class:

const IPv4 = require("@cursorsdottsx/i");

A class named IPv4 will be added.

new IPv4(address, subnet)

  • address – IP address
  • subnet – Subnet mask

Creates a new IPv4 address.

IPv4.prototype.toBinary() – Returns the binary representation of the IP address.

IPv4.prototype.toDecimal() – Returns the decimal representation of the IP address.

IPv4.isValid(address) – Returns true if the IP address is valid.

IPv4.isPrivate(address) – Returns true if the IP address is private.

IPv4.not(a, b) – Exactly what it sounds like.

IPv4.or(a, b) – Exactly what it sounds like.

npm abc's homepage