Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Catalog

Catalog wraps the raw data of a semester, providing methods to access and search for courses/sections

author

Hanzhi Zhou

Hierarchy

  • Catalog

Index

Constructors

constructor

  • new Catalog(semester: SemesterJSON, data: ReturnType<Catalog["data"]>, modified: number): Catalog

Properties

Readonly courseDict

courseDict: {}

a mapping from course key to courses

Type declaration

Readonly courses

courses: readonly Course[]

array of all courses. equal to Object.values(this.courseDict)

Private descriptionSearcher

descriptionSearcher: FastSearcher<Course, "description">

Private instrSearcher

instrSearcher: FastSearcher<Section, "instructors">

Readonly modified

modified: number

Private roomSearcher

roomSearcher: FastSearcher<Section, "rooms">

Private Readonly sectionMap

sectionMap: Map<number, Section>

a map from section id to section instance

Readonly sections

sections: readonly Section[]

array of all sections. equal to

this.courses.flatMap(c => c.sections)

Readonly semester

semester: SemesterJSON

the semester corresponding to the catalog stored in this object

Private titleSearcher

titleSearcher: FastSearcher<Course, "title">

Private topicSearcher

topicSearcher: FastSearcher<Section, "topic">

Methods

Private appendToResult

convertKey

  • convertKey(key: string, schedule?: Schedule): undefined | string
  • convert cs11105 style key to CS 1110 Lecture

    convert key of an event (e.g. MoFr 1:00PM - 2:00PM) to its title

    Parameters

    • key: string
    • Optional schedule: Schedule

    Returns undefined | string

Private data

fuzzySearch

getCourse

  • getCourse(key: string, sections?: number[] | Set<number> | -1): Course
  • Get a Course associated with the given key

    you may specify a set of section indices so that you can only obtain a subset of the original course sections

    Parameters

    • key: string
    • Optional sections: number[] | Set<number> | -1

    Returns Course

getSectionById

  • getSectionById(id: number): Section

Private prepQuery

  • prepQuery(query: string): [string, string, string]

Private processCourseResults

Private processSectionResults

search

  • Perform a linear search in the catalog against course number, title, topic, professor name and description, in the order specified.

    Parameters

    • _query: string
    • Default value maxResults: number = 6

    Returns [Course[], SearchMatch[]]

Private searchField

  • searchField(query: string, field: "title" | "description", course: Course, results: Course[], matches: SearchMatch[]): void

Private searchKey

Private searchSectionField

  • searchSectionField(query: string, field: "topic" | "instructors" | "rooms", course: Course, results: Course[], matches: SearchMatch[]): void

Generated using TypeDoc