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

@pfeiferio/ipv4

v1.1.0

Published

A strict, well-tested IPv4 address and network utility library for Node.js

Readme

@pfeiferio/ipv4

npm types license downloads node

Strict and well-tested IPv4 address and network utilities for Node.js.

  • ESM only
  • Node.js ≥ 18
  • TypeScript-first
  • No dependencies
  • Full test coverage

Installation

npm install @pfeiferio/ipv4

Basic Usage

import { ipV4 } from '@pfeiferio/ipv4'

const ip = ipV4('192.168.1.10/24')

ip.address            // "192.168.1.10"
ip.prefix             // 24
ip.addressWithCidr    // "192.168.1.10/24"
ip.toInteger()        // 3232235786

Default prefix is /32.


IPv4Address examples

Create addresses

ipV4('1.1.1.1')
ipV4('1.1.1.1/32')
ipV4(3232235777)

Prefix handling (immutable)

const ip = ipV4('10.0.0.1')
const withPrefix = ip.withPrefix(16)

ip.addressWithCidr        // "10.0.0.1/32"
withPrefix.addressWithCidr // "10.0.0.1/16"

Address comparison

ip.equals(ipV4('10.0.0.1/32'))        // true
ip.isSameAddress(ipV4('10.0.0.1/8'))  // true

Navigation

ipV4('1.1.1.1').next().address   // "1.1.1.2"
ipV4('1.1.1.1').prev().address   // "1.1.1.0"

IPv4Network examples

Create networks

const net = ipV4('192.168.1.10/24').network()

net.addressWithCidr   // "192.168.1.0/24"
net.size              // 256
net.hostCount         // 254

Network helpers

net.firstHost.address   // "192.168.1.1"
net.lastHost.address    // "192.168.1.254"
net.broadcast.address   // "192.168.1.255"

Containment & relations

net.contains('192.168.1.42')                 // true
net.overlaps('192.168.1.128/25')             // true
net.containsNetwork('192.168.1.128/25')      // true
net.isSubnetOf('192.168.0.0/16')              // true
net.isSupernetOf('192.168.1.128/25')          // true

Iteration

Usable hosts

for (const host of net.hosts()) {
  console.log(host.address)
}

All addresses

for (const addr of net.addresses()) {
  console.log(addr.address)
}

Utilities

import { ipToInt, intToIp } from '@pfeiferio/ipv4'

ipToInt('192.168.1.1')   // 3232235777
intToIp(3232235777)      // "192.168.1.1"

Design notes

  • Prefix defaults to /32
  • Network addresses are always normalized
  • No implicit magic
  • /0, /31, /32 handled correctly

License

MIT