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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ip2country

v1.0.1

Published

Self-contained IP to country lookup

Downloads

567

Readme

IP 2 Country

IP 2 Country provides a current lookup table to geolocate IP address to the countries in which they are most probably located. Distributed as a stand-alone NPM module with no dependencies, the list is created at publication time. This mapping is generated through the use of two databases:

  • autnums Provides a textual descriptiosn of each registered ASN, including the country to which that ASN is registered.
  • routeviews.org orginas Provides a current list of BGP announcements, allowing us to understand which ASNs are announcing ownership of which IP prefixes.

Size

2.0M ip2country.js
510K ip2country.js.gz

Installation

  npm install ip2country

Usage

var ip2country = require('ip2country');
var country = ip2country(ip);

Advanced Usage

There are several related lookup tables for IP addresses that may be of use. While not published for direct consumption, this library contains the tools to generate those tables for your process. This functionality is accessed through the getGenericMap() function in build.js. In particular, the following knobs are exposed when generating the lookup table:

  • compress - Should the table be de-duplicated? When false the table will be faster to generate but slower to look up.
  • toCountry - Should the ip-ASN table be joined with an ASN-country table? When false an IP-ASN lookup table will be generated.
  • when - At what point should the table be generated? If set, the full RIB - routing information base - from the given time will be loaded and an originas extracted from that file (see historicBGPData.js).
  • nocache - Should a new originas be downloaded even if one already exists on disk? (defaults to false).