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

@jnode/ip

v1.0.0

Published

Simple IP handling package for Node.js.

Readme

@jnode/ip

Simple IP handling package for Node.js.

Installation

npm i @jnode/ip

Quick start

Import

const { IP, IPRange, IPRangeGroup } = require('@jnode/ip');

Basic IP parsing and formatting

const ipv4 = new IP('127.0.0.1');
console.log(ipv4.toString()); // '::ffff:127.0.0.1'

const ipv6 = new IP('2001:db8::1');
console.log(ipv6.toString()); // '2001:db8::1'

Check if an IP is within a range

const range = new IPRange('192.168.1.0/24');

// returns true
console.log(range.check('192.168.1.5'));

// using the IP instance method
const myIp = new IP('10.0.0.1');
console.log(myIp.within('10.0.0.0/8')); // true

How it works?

The package provides a high-performance way to handle IP addresses by converting them into BigInt representations.

  1. BigInt Core: All IP addresses (IPv4 and IPv6) are stored as 128-bit integers.
  2. Unified Handling: IPv4 addresses are automatically mapped to IPv6 (using the ::ffff:0:0/96 prefix) to allow seamless comparison and range checking across different protocols.
  3. Standard Formatting: When converting back to a string, the package follows standard IPv6 compression rules (RFC 5952) to ensure the shortest valid representation.

This approach makes subnet calculations and IP comparisons extremely fast and reliable.


Reference

Class: ip.IP

Represents an IP address.

new ip.IP(address)

  • address <string> | <bigint> | <ip.IP>
    • If a string, it can be an IPv4 (e.g., '127.0.0.1') or IPv6 (e.g., '::1').
    • If a bigint, it is treated as the raw 128-bit integer value.
    • If an IP instance, it clones the value.

ip.toString()

Returns the string representation of the IP address. IPv4 addresses are returned in IPv4-mapped IPv6 format (e.g., ::ffff:1.2.3.4). IPv6 addresses are returned with zero compression where applicable.

ip.within(range)

Checks if the IP address is within the specified CIDR range.

Class: ip.IPRange

Represents a CIDR range used for filtering or matching IP addresses.

new ip.IPRange(cidr)

  • cidr <string> An IP address followed by a prefix length (e.g., '192.168.0.0/16' or '2001:db8::/32').

ipRange.check(ip)

Returns true if the provided IP address is within the CIDR range.

Class: ip.IPRangeGroup

A utility class to check an IP against multiple CIDR ranges simultaneously.

new ip.IPRangeGroup(ranges)

ipRangeGroup.check(ip)

Returns true if the provided IP address matches any of the ranges in the group.