1.1.3 • Published 4 years ago

@project-medusa/collector-utils v1.1.3

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

medusa-collector-utils

medusa-collector-utils is a utility package used by MedusaCollector

Installation

npm i @project-medusa/collector-utils

Usage

For a better understanding of how this package is used, please take a look at the MedusaCollector package mentioned above.

API

Table Of Contents


AirportCollector

  • Description: The AirportCollector class's purpose is to find out which airports are covered by a specific eAIP. It also caches the results under cache/XX_airports.json
  • Type: class
  • Constructor Parameters:
    • aoi:
      • Type: string
      • Description: 2-letter area code (EG, EY, EV, ...)
    • aerodromeParseFunction
      • Type: function
      • Description: This function is called to parse out an eAIP aerodrome line. Examples:
        • AD-2.EYPAdetails -> aerodromeParseFunction -> EYPA
  • Relevant Methods:
    • findCoveredAirports:
      • Async: true
      • Returns: array[string]
      • Description: This method either looks in cache or grabs and parses the covered airfields by an eAIP.
  • Usage:
  const { AirportCollector } = require('@project-medusa/collector-utils')

  const airportCollector = new AirportCollector(process.env.AOI, parseAerodromeString);

Collector

  • Description: The Collector parses the html document and calls specific Parser methods to further extract the information from the parsed html
  • Type: class
  • Constructor Parameters:
    • parser:
  • Relevant Methods:
    • retriveAndParseTable
      • Async: true
      • Returns: void
      • Description: This method calls the specific country parsers to parse out an HTML Table row.
  • Usage:

     const { Collector } = require('@project-medusa/collector-utils');
    
     const collector = new Collector(...);
  • Also see Parser

  • Also see MedusaCollector

Parser

  • Description: The Parser class is where most of the bussiness logic happens. It's where the runway/intersection information is parsed. Each country, AKA AOI (area of interest), has their own unique parser as each country's information structure is different.

  • Type: class

  • Constructor Parameters:
    • airport
      • Type: string
      • Description: 4-letter airport ICAO code
    • link
      • Type: string
  • Relevant Methods:
    • runwayRows
      • Throws: an Error if not overriden by inherited classes
      • Description: This method is called for each HTML Table row that contains runway/intersection data.
      • Returns: void
      • Parameters:
        • rows:
          • Type: NodeList {}
    • save
      • Async: true
      • Description: Saves runway results from this.results into results/XXXX.json
  • Usage:

Note: each inherited class MUST override a method called runwayRows, otherwise an error will be thrown

const { Parser } = require('@project-medusa/collector-utils');

class EY extends Parser {...}

Page

  • Description: meant for creating and retrieving a puppeteer page
  • Type: object
  • Relevant methods:
    • createPage
      • Parameters:
        • params
          • Type: object
          • Description: This params object is passed down to a puppeteer function called puppeteer.launch();
    • getPage
      • Description: returns the created puppeteer page.
  • Usage:
const { createPage, getPage: page } = require('@project-medusa/collector-utils').Page;

(async () => {

  await createPage({ headless: false, slowMo: 0, args: ['--user-agent=New User Agent'] });
  await page().goto(currentSource.menuLink);

})();
1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago