npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ipv4-utils

v0.2.2

Published

IPv4 utilities

Downloads

66

Readme

IPv4 Utils

Table of Contents

Overview

IPv4 Utils is a library for working with IPv4 addresses.

Installation

IPv4 Utils is available on npm as ipv4-utils:

$ npm install --save ipv4-utils

To use the module in your application, require it from any JavaScript file:

const ipv4_utils = require('ipv4-utils');

Usage

Require IPv4 Utils

const ipv4_utils = require('ipv4-utils');

Get local IPv4 Address

const myIPv4 = ipv4_utils.myIP();
/*
Response sample:

{
    address: '192.168.0.0',
    netmask: {
        address: '255.255.255.0',
        binary: '11111111111111111111111100000000'
    },
    cidr: '192.168.0.0/24'
}
*/
const myIPv4_str = myIPv4.address;
//192.168.0.0
const myIPv4_cidr = myIPv4.cidr;
//192.168.0.0/24
const myIPv4_netmask_addr = myIPv4.netmask.address;
//255.255.255.0
const myIPv4_netmask_binary = myIPv4.netmask.binary;
//11111111111111111111111100000000

Calculate CIDR using existing IPv4 address and netmask


const cidr = ipv4_utils.cidrFromIPv4(myIPv4_str, myIPv4_netmask_addr);
/*NOTE: 
Allowed values for IP address:
    -IPv4 address string. (Ex: '192.168.0.0')
    -IPv4 address binary string. (Ex: '11000000101010000000000000000000')
    -IPv4 address integer (Ex: 3232235520)
    -IPv4 address array (Ex: [192, 168, 0, 0])

Allowed values for netmask:
    -IPv4 netmask address string. (Ex: '255.255.255.0')
    -IPv4 netmask binary string. (Ex: '11111111111111111111111100000000')
    -IPv4 netmask integer (Ex: 4294967040)
    -IPv4 netmask array (Ex: [255, 255, 255, 0])
*/

Parse IPv4 address

const ipv4_str = '192.168.0.0';
const ipv4_binary = '11000000101010000000000000000000';
const ipv4_int = 3232235520;
const ipv4_arr = ipv4_utils.parse(ipv4_str);

ipv4_utils.parse(ipv4_binary); //Output: [192, 168, 0, 0]
ipv4_utils.parse(ipv4_int); //Output: [192, 168, 0, 0]
ipv4_utils.parse(ipv4_arr); //Output: [192, 168, 0, 0]

/*NOTE:
Allowed values for IP address:
    -IPv4 address string. (Ex: '192.168.0.0')
    -IPv4 address binary string. (Ex: '11000000101010000000000000000000')
    -IPv4 address integer (Ex: 3232235520)
    -IPv4 object (Ex: { address: '192.168.0.0', netmask: {address: '255.255.255.0', binary: '11111111111111111111111100000000'}, cidr: '192.168.0.0/24' })
*/

Generate IPv4 ranges

const range = ipv4_utils.generateIPRange('192.168.0.0', '192.168.255.255', {
    //Possible values for includeLimits: true, false
    //Include given start and end IPv4 addresses in the result
    includeLimits: true,
    arrayFormat: 'string',
    //Possible values for arrayFormat: 'string', 'array', 'number'
    //Return result array containing IPv4 address as string, array or number
});
//Result: ['192.168.0.0'...'192.168.255.255'] (Array containing IPv4 range in specified format)