@faa-aviation-data-portal/aeronav-charts
Advanced tools
Comparing version 0.2.2 to 1.0.0
const superagent = require('superagent') | ||
const { parseVfrTable } = require('./utils') | ||
const baseURI = 'https://www.faa.gov/air_traffic/flight_info/aeronav/digital_products/' | ||
const baseURI = | ||
'https://www.faa.gov/air_traffic/flight_info/aeronav/digital_products/' | ||
// For some reason the server takes forever to respond without this request header | ||
const ACCEPT = 'text/html' | ||
@@ -10,2 +13,5 @@ const fetchIfr = async () => { | ||
.get(`${baseURI}/ifr`) | ||
.set('Accept', ACCEPT) | ||
.timeout({ deadline: 30000 }) | ||
.retry(5) | ||
return response.text | ||
@@ -17,37 +23,81 @@ } catch (err) { | ||
exports.all = async () => { | ||
const html = await fetchIfr() | ||
const enrouteLow = parseEnrouteLow(html) | ||
const enrouteHigh = parseEnrouteHigh(html) | ||
const enrouteLowHighAlaska = parseEnrouteLowHighAlaska(html) | ||
const enrouteArea = parseEnrouteArea(html) | ||
const enrouteHawaiiPacific = parseEnrouteHawaiiPacific(html) | ||
const planning = parsePlanning(html) | ||
const gulf = parseGulf(html) | ||
const caribbean = parseCaribbean(html) | ||
return { | ||
enrouteLow, | ||
enrouteHigh, | ||
enrouteLowHighAlaska, | ||
enrouteArea, | ||
enrouteHawaiiPacific, | ||
planning, | ||
gulf, | ||
caribbean | ||
} | ||
} | ||
exports.enrouteLow = async () => { | ||
const html = await fetchIfr() | ||
return parseVfrTable(html, '#lowsHighsAreas table', 0) | ||
return parseEnrouteLow(html) | ||
} | ||
exports.enrouteHigh = async () => { | ||
const html = await fetchIfr() | ||
return parseVfrTable(html, '#lowsHighsAreas table', 1) | ||
return parseEnrouteHigh(html) | ||
} | ||
exports.enrouteLowHighAlaska = async () => { | ||
const html = await fetchIfr() | ||
return parseVfrTable(html, '#lowsHighsAreas table', 2) | ||
return parseEnrouteLowHighAlaska(html) | ||
} | ||
exports.enrouteArea = async () => { | ||
const html = await fetchIfr() | ||
return parseVfrTable(html, '#lowsHighsAreas table', 3) | ||
return parseEnrouteArea(html) | ||
} | ||
exports.enrouteHawaiiPacific = async () => { | ||
const html = await fetchIfr() | ||
return parseVfrTable(html, '#lowsHighsAreas table', 4) | ||
return parseEnrouteHawaiiPacific(html) | ||
} | ||
exports.planning = async () => { | ||
const html = await fetchIfr() | ||
return parseVfrTable(html, '#planning table') | ||
return parsePlanning(html) | ||
} | ||
exports.gulf = async () => { | ||
const html = await fetchIfr() | ||
return parseGulf(html) | ||
} | ||
exports.caribbean = async () => { | ||
const html = await fetchIfr() | ||
return parseCaribbean(html) | ||
} | ||
const parseEnrouteLow = html => { | ||
return parseVfrTable(html, '#lowsHighsAreas table', 0) | ||
} | ||
const parseEnrouteHigh = html => { | ||
return parseVfrTable(html, '#lowsHighsAreas table', 1) | ||
} | ||
const parseEnrouteLowHighAlaska = html => { | ||
return parseVfrTable(html, '#lowsHighsAreas table', 2) | ||
} | ||
const parseEnrouteArea = html => { | ||
return parseVfrTable(html, '#lowsHighsAreas table', 3) | ||
} | ||
const parseEnrouteHawaiiPacific = html => { | ||
return parseVfrTable(html, '#lowsHighsAreas table', 4) | ||
} | ||
const parsePlanning = html => { | ||
return parseVfrTable(html, '#planning table') | ||
} | ||
const parseGulf = html => { | ||
return parseVfrTable(html, '#gulf table') | ||
} | ||
exports.grandCanyon = async () => { | ||
const html = await fetchVfr() | ||
return parseVfrTable(html, '#grandCanyon table') | ||
} | ||
exports.caribbean = async () => { | ||
const html = await fetchVfr() | ||
const parseCaribbean = html => { | ||
return parseVfrTable(html, '#caribbean table') | ||
} |
@@ -40,3 +40,3 @@ const cheerio = require('cheerio') | ||
: ' - ' | ||
;[ currentSequenceNumber, currentReleaseDate ] = currentEdition.children[0].data.split(splitter) | ||
;[currentSequenceNumber, currentReleaseDate] = currentEdition.children[0].data.split(splitter) | ||
} else { | ||
@@ -60,3 +60,3 @@ currentSequenceNumber = null | ||
: ' - ' | ||
;[ nextSequenceNumber, nextReleaseDate ] = nextEditionTitle.split(splitter) | ||
;[nextSequenceNumber, nextReleaseDate] = nextEditionTitle.split(splitter) | ||
} else { | ||
@@ -63,0 +63,0 @@ nextSequenceNumber = null |
const superagent = require('superagent') | ||
const { parseVfrTable } = require('./utils') | ||
const baseURI = 'https://www.faa.gov/air_traffic/flight_info/aeronav/digital_products/' | ||
const baseURI = | ||
'https://www.faa.gov/air_traffic/flight_info/aeronav/digital_products/' | ||
// For some reason the server takes forever to respond without this request header | ||
const ACCEPT = 'text/html' | ||
@@ -10,2 +13,5 @@ const fetchVfr = async () => { | ||
.get(`${baseURI}/vfr`) | ||
.set('Accept', ACCEPT) | ||
.timeout({ deadline: 30000 }) | ||
.retry(5) | ||
return response.text | ||
@@ -17,25 +23,62 @@ } catch (err) { | ||
exports.all = async () => { | ||
const html = await fetchVfr() | ||
const sectionals = parseSectionals(html) | ||
const terminalArea = parseTerminalArea(html) | ||
const helicopter = parseHelicopter(html) | ||
const grandCanyon = parseGrandCanyon(html) | ||
const planning = parsePlanning(html) | ||
const caribbean = parseCaribbean(html) | ||
return { | ||
sectionals, | ||
terminalArea, | ||
helicopter, | ||
grandCanyon, | ||
planning, | ||
caribbean | ||
} | ||
} | ||
exports.sectionals = async () => { | ||
const html = await fetchVfr() | ||
return parseVfrTable(html, '#sectional table') | ||
return parseSectionals(html) | ||
} | ||
exports.terminalArea = async () => { | ||
const html = await fetchVfr() | ||
return parseVfrTable(html, '#terminalArea table') | ||
return parseTerminalArea(html) | ||
} | ||
exports.helicopter = async () => { | ||
const html = await fetchVfr() | ||
return parseVfrTable(html, '#helicopter table') | ||
return parseHelicopter(html) | ||
} | ||
exports.grandCanyon = async () => { | ||
const html = await fetchVfr() | ||
return parseVfrTable(html, '#grandCanyon table') | ||
return parseGrandCanyon(html) | ||
} | ||
exports.planning = async () => { | ||
const html = await fetchVfr() | ||
return parseVfrTable(html, '#Planning table') | ||
return parsePlanning(html) | ||
} | ||
exports.caribbean = async () => { | ||
const html = await fetchVfr() | ||
return parseCaribbean(html) | ||
} | ||
const parseSectionals = html => { | ||
return parseVfrTable(html, '#sectional table') | ||
} | ||
const parseTerminalArea = html => { | ||
return parseVfrTable(html, '#terminalArea table') | ||
} | ||
const parseHelicopter = html => { | ||
return parseVfrTable(html, '#helicopter table') | ||
} | ||
const parseGrandCanyon = html => { | ||
return parseVfrTable(html, '#grandCanyon table') | ||
} | ||
const parsePlanning = html => { | ||
return parseVfrTable(html, '#Planning table') | ||
} | ||
const parseCaribbean = html => { | ||
return parseVfrTable(html, '#caribbean table') | ||
} |
{ | ||
"name": "@faa-aviation-data-portal/aeronav-charts", | ||
"description": "Fetch links and metadata for charts provided by Aeronav in a sane format.", | ||
"version": "0.2.2", | ||
"version": "1.0.0", | ||
"author": { | ||
@@ -11,14 +11,14 @@ "name": "Forrest Desjardins", | ||
"dependencies": { | ||
"cheerio": "^1.0.0-rc.3", | ||
"superagent": "^5.2.1" | ||
"cheerio": "^1.0.0-rc.12", | ||
"superagent": "^8.0.9" | ||
}, | ||
"devDependencies": { | ||
"chai": "^4.2.0", | ||
"coveralls": "^3.0.9", | ||
"mocha": "^7.0.1", | ||
"nyc": "^15.0.0", | ||
"standard": "^14.3.1" | ||
"chai": "^4.3.7", | ||
"coveralls": "^3.1.1", | ||
"mocha": "^10.2.0", | ||
"nyc": "^15.1.0", | ||
"standard": "^17.1.0" | ||
}, | ||
"engines": { | ||
"node": ">=7" | ||
"node": ">=14" | ||
}, | ||
@@ -77,4 +77,5 @@ "eslintConfig": { | ||
"scripts": { | ||
"test": "standard *.js && nyc mocha test.js" | ||
"test": "standard *.js && nyc mocha test.js", | ||
"standard:fix": "standard --fix" | ||
} | ||
} |
@@ -49,2 +49,3 @@ # aeronav-charts | ||
#### `aeronavCharts.vfr.all()` | ||
#### `aeronavCharts.vfr.sectionals()` | ||
@@ -59,9 +60,10 @@ #### `aeronavCharts.vfr.terminalArea()` | ||
#### `aeronavCharts.vfr.enrouteLow()` | ||
#### `aeronavCharts.vfr.enrouteHigh()` | ||
#### `aeronavCharts.vfr.enrouteLowHighAlaska()` | ||
#### `aeronavCharts.vfr.enrouteArea()` | ||
#### `aeronavCharts.vfr.enrouteHawaiiPacific()` | ||
#### `aeronavCharts.vfr.planning()` | ||
#### `aeronavCharts.vfr.gulf()` | ||
#### `aeronavCharts.ifr.all()` | ||
#### `aeronavCharts.ifr.enrouteLow()` | ||
#### `aeronavCharts.ifr.enrouteHigh()` | ||
#### `aeronavCharts.ifr.enrouteLowHighAlaska()` | ||
#### `aeronavCharts.ifr.enrouteArea()` | ||
#### `aeronavCharts.ifr.enrouteHawaiiPacific()` | ||
#### `aeronavCharts.ifr.planning()` | ||
#### `aeronavCharts.ifr.gulf()` | ||
@@ -68,0 +70,0 @@ ## Contributing |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
12100
248
1
78
+ Addedasap@2.0.6(transitive)
+ Addeddezalgo@1.0.4(transitive)
+ Addedform-data@4.0.2(transitive)
+ Addedformidable@2.1.2(transitive)
+ Addedhexoid@1.0.0(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedsuperagent@8.1.2(transitive)
+ Addedwrappy@1.0.2(transitive)
- Removedform-data@3.0.3(transitive)
- Removedformidable@1.2.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedreadable-stream@3.6.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedstring_decoder@1.3.0(transitive)
- Removedsuperagent@5.3.1(transitive)
- Removedutil-deprecate@1.0.2(transitive)
Updatedcheerio@^1.0.0-rc.12
Updatedsuperagent@^8.0.9