netmask
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Netmask is a powerful npm package designed to parse and understand IPv4 CIDR blocks. This allows developers to explore and compare various network blocks. The operation of this module greatly resembles the functionality of the Perl Net::Netmask module. It provides functionalities like identifying the base address of the network block, the netmask, host mask, size of IP addresses in the block among others.
Usage of the Netmask npm package is quite straightforward and requires simple JavaScript code. Begin by installing the package using npm install netmask
. To utilize it, require the package in your script and create a new instance of the Netmask class. In this instance, the CIDR block to be parsed will be passed as an argument. Various methods such as base
, mask
, size
, contains
, forEach
, next
, among others can then be invoked on the created block instance.
Here's an example of how to use Netmask:
var Netmask = require('netmask').Netmask
var block = new Netmask('10.0.0.0/12');
console.log(block.base); // Outputs: 10.0.0.0
console.log(block.contains('10.0.8.10')); // Outputs: true
console.log(block.next()); // Outputs: Netmask('10.16.0.0/12')
The documentation for the Netmask npm package can be found directly in the readme section of the package's page on GitHub. It is also likely that detailed usage examples and API information can be found by looking into the repository's code. To get there, visit the repository's URL at git://github.com/rs/node-netmask.git.