IPv4 Parser
Generated by OSS Project Generator.
A package to calculate subnet masks.
This package provides the following features:
- Allows you to parse an IPv4 address
- Provides the address, size, netmask, first and last addresses.
- Each address provides decimal, binary and hexadecimal values.
Installation
There are two ways to install node-ipv4
: globally and locally.
To install globally:
# Install globally $ npm install -g node-ipv4 # Check installation $ node-ipv4 --version
To install locally:
$ npm install node-ipv4
Usage
There are two ways to use node-ipv4
: globally and locally.
Globally
- ###
-V
or--version
: output the version number
$ node-ipv4 --version1.1.2
- ###
-h
or--help
: output usage information
$ node-ipv4 --help Usage: cli [options] Options: -h, --help output usage information -V, --version output the version number -i, --ip [ip] IP Address -c, --cidr [cidr] Cdir block
- ###
-i
or--ip [ip: string]
: enter the IP address - ###
-c
or--cidr [ip: number]
: enter the CIDR block
# without alias $ node-ipv4 --ip 192.168.1.1 --cidr 8 # with alias $ node-ipv4 -i 192.168.1.1 -c 8 # output
Locally
const ipv4 = ; ipv4;
Output
Documentation
Address
value
: {Number} Decimal value of an addressaddress
: {String} String value of an addressbinary
: {String} Binary value of an addresshexadecimal
: {String} Hexadecimal value of an address
IPv4
cidr
: {Number} CIDR blocksize
: {Number} Size of subnetaddress
: {Object:Address} The input addressnetmask
: {Object:Address} The subnet maskfirst
: {Object:Address} The first addresslast
: {Object:Address} The last address
API: parse(address, cidr, callback)
address
{String} IP addresscidr
{Number} CIDR blockcallback
{Function}err
{Error | null} Erroripv4
{Object:IPv4} Instance ofIPv4
Development
- Clone the repo
$ git clone https://github.com/robertoachar/node-ipv4.git
- Install dependencies
$ npm install
- Running scripts
Action | Usage |
---|---|
Linting code | npm run lint |
Running unit tests | npm run jest |
Running code coverage | npm run coverage |
Running lint + tests | npm test |
Sending coverage results to Coveralls.io | npm run coveralls |