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

ip-range-list

v1.0.0

Published

An IP address range list with IPv4 and IPv6 support.

Readme

ip-range-list

A dependency-free IP allowlist/blocklist. Think Node.js net.BlockList, but faster. Accepts IPv4 and IPv6 addresses, ranges, and subnets, and uses binary search for fast lookups.

Install

npm install ip-range-list

In client-side applications, you can import the package directly via jsDelivr CDN.

Usage

Using the package in ESM/CJS applications:

import { IPRangeList } from 'ip-range-list';

let ranges = new IPRangeList()
    .addRange('192.0.1.1', '192.0.1.255')
    .addSubnet('192.0.2.9/24')
    .addAddress('2001:db8::1');

ranges.contains('192.0.2.42'); // => true
ranges.contains('::ffff:192.0.2.42'); // => true
ranges.contains('2001:db8::2'); // => false

Using the UMD build:

const { IPRangeList } = window.ipRangeList;
let ranges = new IPRangeList();

API

[!NOTE] IPv4-mapped IPv6 addresses such as ::ffff:192.0.2.1 are treated as equivalent to plain IPv4 addresses such as 192.0.2.1 across all methods.

new IPRangeList()

Creates an empty mutable list.

.addAddress(address)

Adds one IPv4 or IPv6 address and returns the same list.

.addRange(start, end)

Adds the inclusive range between two addresses and returns the same list.

.addSubnet(cidr)

Adds a CIDR subnet and returns the same list. Host bits are normalized, so 192.0.2.9/24 adds 192.0.2.0 through 192.0.2.255.

.contains(address) and .check(address)

Return whether an address belongs to a stored range. .check() is an alias for .contains(). Invalid candidates return false.

.ranges

A read-only snapshot of the currently stored canonical merged ranges:

[
    {
        start: '::ffff:192.0.2.0',
        end: '::ffff:192.0.2.255',
    },
]

Normalization and errors

  • Overlapping and adjacent ranges merge into one canonical inclusive interval.
  • IPv4 is stored as IPv4-mapped IPv6 (::ffff:0:0/96), so dotted IPv4 and mapped IPv6 candidates compare identically.
  • Public mutation methods reject malformed addresses and unsupported input types with TypeError.
  • Out-of-range CIDR prefix lengths and reversed ranges throw RangeError.

Lookups use binary search over the canonical ranges.

Benchmark

The package includes a benchmark comparing IPRangeList with Node.js net.BlockList against Manycast IPv4 and IPv6 prefix data. See the benchmark notes for the data download script, query profiles, methodology, and reproduction steps. The published run used 55,473 prefixes: 41,207 IPv4 prefixes and 14,266 IPv6 prefixes.

The present profile checks addresses from the dataset prefixes, the missing profile checks generated addresses outside the loaded ranges, and the mixed profile uses 20% present addresses and 80% missing addresses.

| Scenario | Profile | ip-range-list | node:net BlockList | Result | | --- | --- | ---: | ---: | --- | | Full import | - | 54.09 ms | 40.36 ms | BlockList 1.34x faster | | 1,000,000 lookups after import | present | 1,472.24 ms | 184,395.46 ms | ip-range-list 125.25x faster | | 1,000,000 lookups after import | missing | 1,568.54 ms | 394,476.87 ms | ip-range-list 251.49x faster | | 1,000,000 lookups after import | mixed | 1,609.40 ms | 356,680.64 ms | ip-range-list 221.62x faster | | Interleaved import/lookups | present | 71.01 ms | 1,009.32 ms | ip-range-list 14.21x faster | | Interleaved import/lookups | missing | 96.28 ms | 2,023.87 ms | ip-range-list 21.02x faster | | Interleaved import/lookups | mixed | 98.54 ms | 1,818.27 ms | ip-range-list 18.45x faster |

Development

Refer to the contributing guide.