Just-IP is an library for parsing ip address and subnet in both browser and nodejs
npm install just-ip --save
const ip = IpV4.fromBytes(127, 0, 0, 1);
const intIp = ip.toInt(); // => 0x7F000001
const strIp = ip.toString(); // => '127.0.0.1'
ip.isLinkLocal(); // => true
ip.isGlobal(); // => false
IpV4.equal(intIp, strIp); // => true
IpV4.isBroadcast('255.255.255.255'); // => true
const net = NetV4.fromString('172.10.1.33/24');
net.getSize(); // => 256
net.getBase('ip'); // => IpV4(172.10.1.0)
net.getBoardcase('arr'); // => [172, 10, 1, 255]
net.containIP(ip); // => false
NetV4.containNet(net, '172.10.1.0/255.255.255.252'); // => true
You can find more documention and demos here.