Skip to content

ip-addressvsip

MIT 34 1 526
61.0 million (month) May 05 2015 9.0.5(1 year, 1 month ago)
1,516 1 83 MIT
Aug 15 2012 65.1 million (month) 2.0.1(8 months ago)

The "ip-address" library is a Node.js library that provides utility functions for working with IP addresses, similar to "ip" library. It provides functions for parsing, validating, and converting IP addresses between different formats, both IPv4 and IPv6.

The "ip" library is a Node.js library that provides utility functions for working with IP addresses. It provides functions for parsing, validating, and converting IP addresses between different formats.

The "ip" library provides a simple and easy-to-use interface for working with IP addresses in Node.js. It can be useful in a variety of contexts, such as when creating a network-related application or when working with IP addresses in a web application.

Example Use


const IPAddress = require("ip-address").Address;

// slice and manipulate addresses:
const ipv4 = new IPAddress("192.168.1.1");
console.log(ipv4.addressMinusSuffix); // '192.168.1'

// validate addresses:
console.log(IPAddress.isValid("192.168.1.1")); // true
console.log(IPAddress.isValid("2001:0db8:85a3:0000:0000:8a2e:0370:7334")); // true
const ip = require('ip');

// check IP validity:
console.log(ip.isV4Format('192.168.1.1')); // true
console.log(ip.isV4Format('2001:0db8:85a3:0000:0000:8a2e:0370:7334')); // false

// check subnets
console.log(ip.cidrSubnet('192.168.1.1/24')); // { networkAddress: '192.168.1.0', broadcastAddress: '192.168.1.255' }
console.log(ip.not('255.255.255.255')); // '0.0.0.0'

Alternatives / Similar


Was this page helpful?