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

location-database

v0.1.0

Published

This package contains a list of countries, cities, states and time-zones and derives information from three different repositories

Downloads

7

Readme

Location Database

Curated database in JSON format of countries, states, cities and timezones This data has been curated from three different souces with priority to the first one

  • https://github.com/dr5hn/countries-states-cities-database
  • https://github.com/khkwan0/countryCityStateJson
  • https://github.com/manuelmhtr/countries-and-timezones

Install via npm

npm install location-database

Methods

const ld = require('location-database')

getAll()

Returns the entire database

getCountryByCode(code)

Pass the iso2 country code (e.g. US) to get entire information on that country. Returns an empty array for no data found.

country object looks like

{ 
      id: 233,
      name: 'United States',
      iso3: 'USA',
      iso2: 'US',
      phone_code: '1',
      capital: 'Washington D.C.',
      currency: 'USD',
      native: 'United States',
      continent: 'NA',
      languages: [ 'en' ],
      emoji: '🇺🇸',
      emojiU: 'U+1F1FA U+1F1F8',
      states: [...],
      timezones: [...]
}

getStatesByCode(code)

Pass the iso2 country code (e.g. US) to get an array of states for that country. Returns an empty array for no data found.

state object looks like

{ 
      id: 1456,
      name: 'Alabama',
      country_id: 233,
      country_code: 'US',
      state_code: 'AL',
      cities: [...] 
}

getTimezonesByCode(code)

Pass the iso2 country code (e.g. US) to get an array of timezones for that country. Returns an empty array for no data found.

timezone object looks like

{ 
      name: 'America/Adak',
      country: 'US',
      utcOffset: -600,
      utcOffsetStr: '-10:00',
      dstOffset: -540,
      dstOffsetStr: '-09:00',
      aliasOf: null,
      country_code: 'US',
      country_id: 233
}

getCities(code, stateCode)

Pass the iso2 country code (e.g. US) and the state code to get an array of cities for that country and state combination. Returns an empty array for no data found.

city object looks like

{ 
      id: '114994',
      name: 'Dallas County',
      state_id: 1456,
      state_code: 'AL',
      country_id: 233,
      country_code: 'US',
      latitude: '32.32597000',
      longitude: '-87.10648000' 
}

Scripts

  • npm run lint to lint code, eslint standard being used
  • npm run lint:fix to auto fix linting where possible
  • npm run build to compile the database, it overwrites db.json in src
  • npm run test to run tests