UNPKG

@sahabaplus/mushaf-engine

Version:

TypeScript implementation of a Quran Mushaf navigation engine

92 lines (91 loc) 2.83 kB
import { Mushaf } from './mushaf'; /** * Information about a Sura in the Quran */ export declare class SuraInfo { /** * Number of the Sura (1-114) */ number: number; /** * Total number of verses in the Sura */ totalVerses: number; /** * Total lines without header (bismillah and title) */ lines: number; /** * Total lines including header */ linesWithHeader: number; /** * Page number where the Sura starts */ startPage: number; /** * Page number where the Sura ends */ endPage: number; constructor(number?: number, totalVerses?: number, lines?: number, linesWithHeader?: number, startPage?: number, endPage?: number); } /** * Collection of Sura information for quick lookup */ export declare class QuranMetadata { /** * Array of Sura information indexed by Sura number (0-indexed for internal storage) * Access using getSuraInfo() method to convert 1-based sura numbers */ private suras; constructor(suras?: SuraInfo[]); /** * Create a new QuranMetadata from the Mushaf * * @param mushaf - The Mushaf to extract metadata from * @returns A new QuranMetadata instance */ static fromMushaf(mushaf: Mushaf): QuranMetadata; /** * Convert 1-based sura number to 0-based index for internal storage * * @param suraNumber - 1-based sura number * @returns 0-based index for internal storage, or undefined if out of range */ private static suraToIndex; /** * Get information about a specific Sura (using 1-based sura number) * * @param suraNumber - 1-based sura number * @returns Information about the specified Sura, or undefined if not found */ getSuraInfo(suraNumber: number): SuraInfo | undefined; /** * Find which Sura contains a particular page * * @param pageNumber - Page number to find suras for * @returns Array of sura numbers that contain the specified page, or undefined if none */ findSuraByPage(pageNumber: number): number[] | undefined; /** * Get total number of lines for a range of Suras * * @param startSura - Starting sura number (1-based) * @param endSura - Ending sura number (1-based) * @returns Total number of lines for the specified range of suras * @throws Error if startSura or endSura are outside valid range [1, 114] */ getLinesRange(startSura: number, endSura: number): number; /** * Get the number of Suras in the Quran * * @returns The total number of suras */ totalSuras(): number; /** * Get an iterator over all Sura information * * @returns An iterator over all Sura information */ [Symbol.iterator](): Iterator<SuraInfo>; }