airport-utils 1.0.27 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,6 +10,7 @@ jobs:
10
10
  runs-on: ubuntu-latest
11
11
  permissions:
12
12
  contents: write
13
+ id-token: write
13
14
 
14
15
  steps:
15
16
  - name: Check out code
package/README.md CHANGED
@@ -58,11 +58,17 @@ try {
58
58
  // longitude: -73.7781,
59
59
  // name: 'John F. Kennedy International Airport',
60
60
  // city: 'New York',
61
- // country: 'US'
61
+ // country: 'US',
62
+ // continent: 'North America'
62
63
  // }
63
64
  } catch (err) {
64
65
  // handle UnknownAirportError
65
66
  }
67
+
68
+ // Get all airports
69
+ import { getAllAirports } from 'airport-utils';
70
+ const airports = getAllAirports();
71
+ console.log(airports.length); // > 10000
66
72
  ```
67
73
 
68
74
  ### API
@@ -85,8 +91,20 @@ export function getAirportInfo(iata: string): {
85
91
  name: string;
86
92
  city: string;
87
93
  country: string;
94
+ continent: string;
88
95
  };
89
96
 
97
+ export function getAllAirports(): {
98
+ iata: string;
99
+ timezone: string;
100
+ latitude: number;
101
+ longitude: number;
102
+ name: string;
103
+ city: string;
104
+ country: string;
105
+ continent: string;
106
+ }[];
107
+
90
108
  export class UnknownAirportError extends Error {}
91
109
  export class InvalidTimestampError extends Error {}
92
110
  export class UnknownTimezoneError extends Error {}
package/dist/cjs/index.js CHANGED
@@ -9,6 +9,7 @@ var errors = require('./errors.js');
9
9
  exports.convertLocalToUTCByZone = converter.convertLocalToUTCByZone;
10
10
  exports.convertToUTC = converter.convertToUTC;
11
11
  exports.getAirportInfo = info.getAirportInfo;
12
+ exports.getAllAirports = info.getAllAirports;
12
13
  exports.InvalidTimestampError = errors.InvalidTimestampError;
13
14
  exports.UnknownAirportError = errors.UnknownAirportError;
14
15
  exports.UnknownTimezoneError = errors.UnknownTimezoneError;
package/dist/cjs/info.js CHANGED
@@ -12,5 +12,13 @@ function getAirportInfo(iata) {
12
12
  throw new errors.UnknownAirportError(iata);
13
13
  return { timezone: tz, ...g };
14
14
  }
15
+ function getAllAirports() {
16
+ return Object.keys(geo.geo).map(iata => {
17
+ const tz = timezones.timezones[iata];
18
+ const g = geo.geo[iata];
19
+ return { iata, timezone: tz, ...g };
20
+ });
21
+ }
15
22
 
16
23
  exports.getAirportInfo = getAirportInfo;
24
+ exports.getAllAirports = getAllAirports;