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

cc2lds

v0.1.1

Published

A list of official country-code second-level domains, in case you need that sort of thing.

Downloads

14

Readme

Country-code second-level domains (cc2LDs)

I scoured the internet but could find no good single source for country-regulated second-level domains, such as .gov.uk, .co.uk, .ac.uk, etc.

I think it's probably quite useful to have this information in a single place, so I'm spending the time to put the current state together here in easily usable formats.

Please contribute if you find that anything is missing.

Goal:

  • easy to contribute to (see CONTRIBUTING.md)
  • automatically build and distribute new version through various channels on change

Accessing the datasets

I made this simple API that you can use to suffix search the most recent version of this dataset, running on Azure Functions and fine to use in production if your site doesn't have a huge amount of traffic (otherwise, warn me at [email protected]): https://tld-api.deranged.dk/api/tlds (try adding e.g. ?suffix=za at the end of the URL to see suffix search).

Alternatively, the datasets are published - via npm - as JSON and YML to the following URLs:

  • https://unpkg.com/cc2lds/output/2lds.json
  • https://unpkg.com/cc2lds/output/2lds.yml

You can also install the latest dataset as an npm dependency:

npm i cc2lds

...which lets you import the data in your Javascript code:

import cc2lds from 'cc2lds';
// `cc2lds` now contains the latest data

There are also tree-versions -- slightly denser and can be navigated more quickly once loaded into memory -- where you can check if a domain is generally managed (i.e. not open for general registration) by progressively checking its path:

import cc2ldsTree from 'cc2lds/tree';

const uk = cc2ldsTree.uk; //truthy, so ".uk" is a regulated domain
const acUk = uk.ac; //truthy, so ".ac.uk" is a regulated domain
const huh = acUk.co; //falsy, so .co.ac.uk" is not a known regulated domain

You can use modern syntax for a nice little shorthand:

if(cc2ldsTree.uk?.ac?) {
    //This block is reached, because ".ac.uk" is known and regulated.
}

These data formats can also be downloaded from unpkg:

  • https://unpkg.com/cc2lds/output/2lds-tree.json
  • https://unpkg.com/cc2lds/output/2lds-tree.yml

FAQ

  • What about top-level domains? IANA (the official authority) has a nice central list of all TLDs, and it's even available as an easily parseable text format. The goal of this project is to make officially supported 2lds and 3lds as easily accessible as the above. Most countries don't have as easily parseable a list as IANA, though it would be neat if they did - then we could automate collecting everything!

Read more