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

all-cities

v0.1.0

Published

JSON Object containing list of all countries, states and cities.

Downloads

26

Readme

countrycitystatejson

JSON formatted data containing the world's countries, states/provinces, and cities.

Usage

knock yourself out

yourhandle.getAll()

Returns entire DB in JSON format. ~ 2.5MB

yourhandle.getCountries()

yourhandle.getCountriesShort()

yourhandle.getCountryByShort(shortName)

yourhandle.getCountryInfoByShort(shortName)

yourhandle.getStatesByShort(shortName)

yourhandle.getCities(shortName, state)

if u really care this is a copied text

In my search for a good database in JSON format that contained Countries and their associated states and cities, I found disparate solutions. While I found a great database of countries from https://github.com/annexare/Countries and a great database of cities from https://github.com/lutangar/cities.json, I required a linkage between them via states/provinces. I did indeed found a solution https://www.npmjs.com/package/country-state-city. However, it did not have rich enough data from the other databases. In addition, a spot check on that particular database showed errors. The United States showed 57 states, those 7 extra entries were also incorrect (e.g. it contained state entries for the US named: Midland, Seward, Lowa, etc). Why didn't I just fix it and make a pull request you say? The issue with that particular database was that the entries were linked together with integer ID's. So in order to lookup a list of states in a country, you need to use the country id. This indexing scheme extended down the hierarchy; in order to find the cities of a state, the parameter was a a state id, which stemmed from a country id. While this indexing scheme is high performant, it made edits and updates to the data somewhat painful. Any change in or update would require a reindexing of the whole data set. So in order for me to remove the 7 erroneous US states, extra code would need to be written to reindex. The solution I present you merges the rich data from https://github.com/annexare/Countries, merges it with https://www.npmjs.com/package/country-state-city and replaces the integer indexing scheme with named keys. This makes recompiling the final JSON object easier. Any edits to the underyling raw data can recompile the final json without a need for indexing. I'm making the assumption that there will be more edits and updates required. I personally only fixed the 7 erroneous states for country code US, and have not confirmed any other state/province and city for accuracy. In addition, removing the integer id indexing and replacing it with named indeces should not have a performance hit if you are using the V8 engine.