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

openflights-cached

v1.3.15

Published

A module that fetches newest OpenFlights airport data upon install and exposes in simple API allowing to search by ICAO and IATA codes.

Downloads

818

Readme

OpenFlights Cached

A module that fetches newest OpenFlights airport data upon install and exposes in simple API.

Usage:

$ npm install -s openflights-cached

Remeber that the data is fetched upon installation so it's always fresh, but also needs a connection to the NPM repo.

Module API

The module API exposes a number of methods allowing different ways to access OpenFlights data. The recommended ones are with the two lookup methods:

const openflights = require("openflights-cached");

console.log(openflights.findIATA("PEK").name);
// -> Beijing Capital International Airport

console.log(openflights.findICAO("SBUA").country)
// -> Brazil

These methods use simple lookup methods without loading any large data sets.

Exports

openflights-cached exports the following methods and properties:

IATA2ICAO

openflights-cached/iata2icao exposes a simple hash of IATA keys and ICAO values.

const openflights = require("openflights-cached/iata2icao");
//    ^^^^^^^^^^^ - this here's an object

const myAirport = openflights.BCN; // -> LEBL

ICAOs

openflights-cached/icaos exposes a simple array of all ICAO ids.

const openflights = require("openflights-cached/icaos");
//    ^^^^^^^^^^^ - this here's an array

const myAirport = openflights.includes('KLAS') // has Las Vegas
const myAirport = openflights.includes('KLAK') // this is a typo

Array

openflights-cached/array exposes an array of all [OpenFlight entries](#Entry type) - the JSON is approx. 2.1 megs and will probably use approx. double the amount of memory.

const openflights = require("openflights-cached/array");
//    ^^^^^^^^^^^ - this here's an array

const myAirport = openflights.find(({iata}) => iata === "WAW"); // -> Warsaw Chopin

ICAO

openflights-cached/icao exposes an object of all OpenFlight entries indexed by ICAO ids - the JSON is approx. 2.3 megs and will probably use approx. double the amount of memory.

const openflights = require("openflights-cached/icao");
//    ^^^^^^^^^^^ - this here's an object with icao ids as keys

const myAirport = openflights["EHAM"] // -> Amsterdam Schiphol

IATA

openflights-cached/iata exposes an object of all OpenFlight entries indexed by IATA ids - the JSON is approx. 1.7 megs and will probably use approx. double the amount of memory.

const openflights = require("openflights-cached/iata");
//    ^^^^^^^^^^^ - this here's an object with iata ids as keys

const myAirport = openflights["JFK"] // -> New York, JFK

Entry type

Each entry exposed by the module is type of OpenFlightsEntry is an object with the following keys:

  • airportid: string - Unique OpenFlights identifier for this airport.
  • name: string - Name of airport. May or may not contain the City name.
  • city: string - Main city served by airport. May be spelled differently from Name.
  • country: string - Country or territory where airport is located. See countries.dat to cross-reference to ISO 3166-1 codes.
  • iata: string - 3-letter IATA code. Null if not assigned/unknown.
  • icao: string - 4-letter ICAO code.
  • latitude: string - Decimal degrees, usually to six significant digits. Negative is South, positive is North.
  • longitude: string - Decimal degrees, usually to six significant digits. Negative is West, positive is East.
  • altitude: string - In feet.
  • [timezone]: string - Hours offset from UTC. Fractional hours are expressed as decimals, eg. India is 5.5.
  • [dst]: string - Daylight savings time. One of E (Europe), A (US/Canada), S (South America), O (Australia), Z (New Zealand), N (None) or U (Unknown). See also: Help: Time
  • [tz]: string - database time zone Timezone in "tz" (Olson) format, eg. "America/Los_Angeles".
  • type: string - Type of the airport. Value "airport" for air terminals, "station" for train stations, "port" for ferry terminals and "unknown" if not known. In airports.csv, only type=airport is included.
  • source: string - Source of this data. "OurAirports" for data sourced from OurAirports, "Legacy" for old data not matched to OurAirports (mostly DAFIF), "User" for unverified user contributions.

License

The module code is licensed as MIT (see MIT license here), the module fetches data from OpenFlights, keep in mind you need to follow that license too.