UNPKG

@sahabaplus/mushaf-engine

Version:

TypeScript implementation of a Quran Mushaf navigation engine

66 lines (65 loc) 2.47 kB
import { SuraInfo } from "../mushaf/quranMetadata"; import { Direction } from "../navigation/direction"; import { NavigationResult } from "../navigation/navigationResult"; import { Verse } from "../mushaf"; /** * Navigation parameters */ export interface NavigateParams { /** Number of lines to navigate (can be fractional) */ lines: number; /** Starting Sura number (1-114) */ fromSura: number; /** Starting verse number within the sura */ fromVerse: number; /** Direction to navigate (Forward or Backward) */ direction: Direction; } /** * Interface for navigation within a Quran Mushaf * * This interface defines the core navigation functionality for traversing * through the Quran. It allows for moving through the text by a specified * number of lines in either direction from a given verse. */ export interface IMushafEngine { /** * Navigate from a verse by a specified number of lines in the given direction * * This method enables precise navigation through the Quran by moving a * specified number of lines forward or backward from a starting verse. * * @param params - Navigation parameters * @returns Navigation result containing the verse at the destination after navigation */ navigate(params: NavigateParams): NavigationResult; /** * Get metadata about a specific Sura * * @param suraNumber - Sura number (1-114) * @returns Information about the specified Sura, or undefined if not found */ getSuraInfo(suraNumber: number): SuraInfo | undefined; /** * Calculate the lines between start and end verses * * @param startSura - Start sura number * @param startVerse - Start verse number * @param endSura - End sura number * @param endVerse - End verse number * @param direction - Direction of navigation * @returns Number of lines between the two verses */ calculateLines(startSura: number, startVerse: number, endSura: number, endVerse: number, direction: Direction): number; /** * Find the next verse from a given verse in the specified direction * * @param params - Object containing sura_number, verse_number, and direction * @returns The next verse or undefined if at the end */ nextVerse({ sura_number, verse_number, direction, }: { sura_number: number; verse_number: number; direction: Direction; }): Verse | undefined; }