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

@project-medusa/collector-utils

v1.1.3

Published

medusa-collector-utils is a utility package used by [MedusaCollector](https://github.com/ProjectMedusa/medusa-collector)

Downloads

8

Readme

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);

})();