Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "parsers/course-detail"

Index

Type aliases

Prerequisite

Prerequisite: undefined | [string, string] | string | object

Functions

buildPrerequisiteTree

formatPrerequisite

  • formatPrerequisite(prerequisite: Prerequisite, depth?: number): string

parseCorequisites

  • parseCorequisites(bodyHtml: string): undefined | string | Object | object
  • Parses corequisites from the bodyHtml

    Parameters

    • bodyHtml: string

    Returns undefined | string | Object | object

parseCourseDetail

  • parseCourseDetail(html: string): object
  • Given a course detail html, this returns the description, the prerequisites, and the corequisites.

    Parameters

    • html: string

    Returns object

    • corequisites: undefined | string | Object | object
    • creditHours: undefined | number
    • creditHoursMin: undefined | number
    • description: undefined | string
    • prerequisites: undefined | string | Object | object
    • restrictions: undefined | string

parseCreditHours

  • parseCreditHours(bodyTextContent: string): object
  • Parameters

    • bodyTextContent: string

    Returns object

    • creditHours: number | undefined
    • creditHoursMin: number | undefined

parseDescription

  • parseDescription(bodyHtml: string): undefined | string
  • Takes in the HTML inside of the <td class="ntdefault"> and grabs the description. All HTML is escaped and the line breaks are removed.

    Parameters

    • bodyHtml: string

    Returns undefined | string

parsePrerequisites

  • parsePrerequisites(bodyHtml: string): undefined | string | Object | object
  • Parses the prerequisites from the bodyHtml

    Parameters

    • bodyHtml: string

    Returns undefined | string | Object | object

parsePrerequisitesHtml

  • parsePrerequisitesHtml(prerequisiteHtml: string): undefined | string | Object | object
  • Used to parse both prerequisites and corequisites. Simply calls all the individual functions.

    Parameters

    • prerequisiteHtml: string

    Returns undefined | string | Object | object

parseRestrictions

  • parseRestrictions(bodyTextContent: string): undefined | string
  • parses the restrictions sections of a course detail

    Parameters

    • bodyTextContent: string

    Returns undefined | string

replaceAllCourseDirectivesInTree

  • replaceAllCourseDirectivesInTree(prerequisite: Prerequisite): undefined | string | Object | object
  • Given a Prerequisite tree, this function will replace all __SUBJECT-CODE|COURSE-NUMBER__ directives in the operands of the Prerequisite with ['SUBJECT-CODE', 'COURSE-NUMBER'] tuples.

    Parameters

    Returns undefined | string | Object | object

replaceCourseDirectiveInToken

  • replaceCourseDirectiveInToken(token: string): string
  • If the string provided matches /__(.*)\|(.*)__/ (e.g. blah __CIS|310__ blah) then the function will return just the __CIS|310__ and leave out the blah blah

    Parameters

    • token: string

    Returns string

replacePrerequisiteAnchors

  • replacePrerequisiteAnchors(prerequisiteHtml: string): string
  • Given the HTML containing the prerequisites, this function will find all the anchors denoting course in the catalog and replace them with a __SUBJECT-CODE|COURSE-NUMBER__ directive. This directive will be parsed out later.

    Parameters

    • prerequisiteHtml: string

    Returns string

tokenizeByOperator

  • Joins strings in an array tree based on whether or not they are operators (i.e. and or or).

    transforms:

    ['one', 'two', 'and', ['buckle', 'shoe', 'or', 'three', 'four']]
    

    into:

    ['one two', 'and', ['buckle shoe', 'or', 'three four']]
    

    Parameters

    Returns ParseTree

transformParenthesesToTree

  • transformParenthesesToTree(expression: string): object
  • Recursive function that takes in a string which can include ( ) and transforms it into an array of arrays. Strings get separated by spaces and substrings inside of ( ) will get put into a sub array:

    e.g.:

    the quick (brown (fox jumps) over the (lazy dog))
    

    becomes:

    ['the', 'quick', ['brown', ['fox', 'jumps'], 'over', 'the', ['lazy', 'dog']]]
    

    Parameters

    • expression: string

    Returns object

Generated using TypeDoc