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-asn-map

v1.0.0

Published

Maps IP addresses to country and AS info using preprocessed IPtoASN data with low memory footprint

Downloads

15

Readme

ip-asn-map

Maps IP addresses to country and AS info with low memory footprint.

  • Uses the data graciously provided by IPtoASN (not included, fetch yourself as necessary).
  • Native JS, no dependencies. The update/build code needs Node.js, but the actual IpMap class only uses ArrayBuffer and DataView and can probably work anywhere. I haven't checked.
  • Memory usage: a single blob of about 10 MiB optimized for binary search.
  • Lookup speed: about 250k lookups/sec or 4 microseconds per lookup on my Ryzen 5600G.
  • Zero emojis (although I am holding back), bad grammar, and code with badly named variables and no comments. As if an actual human wasted half a weekend to write and document this by hand. Weirdo.

Warning: the lookup function uses a very naive parser that expects the addresses in the most basic form, 1.2.3.4 or a:b::c:d. If you're dealing with untrusted input, you should probably pass it through a proper parser first.

Command line

Install:

npm install ip-asn-map

Fetch and process the latest dataset, and save it in the package directory:

npx ip-asn-map update
# or
npx ip-asn-map update cache/custom.bin # custom destination

Generate the blob using previously fetched TSV (any of)

npx ip-asn-map parse ip2asn-combined.tsv.gz # save to default location
npx ip-asn-map parse ip2asn-combined.tsv.gz cache/custom.bin
npx ip-asn-map parse ip2asn-combined.tsv cache/custom.bin # can be unpacked
zcat ip2asn-combined.tsv.gz | npx ip-asn-map parse - - > custom.bin # stdio

Lookup an address:

npx ip-asn-map lookup 51.210.240.134
npx ip-asn-map lookup 2001:abad:1dea:: praise.odin

Example output:

{
  family: 4,
  ip: '51.210.240.134',
  int: 869462150,
  as: { number: 16276, country: 'FR', description: 'OVH' },
  range: {
    family: 4,
    first: '51.210.0.0',
    last: '51.210.255.255',
    firstInt: 869400576,
    lastInt: 869466111,
    size: 65536,
    index: 73285
  }
}

Usage

Full reference

In Node:

import { loadIpMap } from 'ip-asn-map';

const map = await loadIpMap(); // or loadIpMap('custom.bin');
const result = map.lookup('51.210.240.134');
const cc = result.as.country; // 'FR', may be null if the range is not assigned

Browser exampleindex.html

License

Public Domain / CC0