|
| 1 | +type QuranMeta = { |
| 2 | + numAyas: number; |
| 3 | + numSuras: number; |
| 4 | + numPages: number; |
| 5 | + numJuzs: number; |
| 6 | + manzilCount: number; |
| 7 | +}; |
| 8 | +declare const meta: Readonly<QuranMeta>; |
| 9 | + |
| 10 | +type Surah = number; |
| 11 | +type AyahNo = number; |
| 12 | +type AyahId = number; |
| 13 | +type Page = number; |
| 14 | +type Juz = number; |
| 15 | +type JuzHizb = { |
| 16 | + juz: Juz; |
| 17 | + hizb: number; |
| 18 | + id: number; |
| 19 | +}; |
| 20 | +type SurahAyah = [Surah, AyahNo]; |
| 21 | +type SurahAyahSegment = [Surah, AyahNo | [AyahNo, AyahNo]]; |
| 22 | +type PageMeta = { |
| 23 | + pageNum: Page; |
| 24 | + first: SurahAyah; |
| 25 | + last: SurahAyah; |
| 26 | +}; |
| 27 | +type JuzMeta = { |
| 28 | + leftjuz: Juz; |
| 29 | + ayahsBetweenJuzSurah: number; |
| 30 | + rightJuz: Juz; |
| 31 | + leftAyahId: AyahId; |
| 32 | + rightAyahId: AyahId; |
| 33 | +}; |
| 34 | +type SajdaType = "recommended" | "obligatory"; |
| 35 | +type Sajda = [AyahId, SajdaType]; |
| 36 | +type SurahMeta = [ |
| 37 | + startAyahId: AyahId, |
| 38 | + ayahCount: number, |
| 39 | + surahOrder: number, |
| 40 | + rukuCount: number, |
| 41 | + name: string, |
| 42 | + isMeccan: boolean, |
| 43 | + page: Page |
| 44 | +]; |
| 45 | +type SuraName = [name: string, translitName: string]; |
| 46 | + |
| 47 | +/** |
| 48 | + * Turns String of type "x:y" or "x:y1-y2" to array [x,y] or [x,[y1,y2]] respectively |
| 49 | + * @param {*} str String of type "x:y" or "x:y1-y2" |
| 50 | + * @returns {array} array [x,y] or [x,[y1,y2]] respectively |
| 51 | + */ |
| 52 | +declare function ayaStringSplitter(str: string): SurahAyahSegment; |
| 53 | + |
| 54 | +/** |
| 55 | + * Get the ayah ID for the given surah and ayah number. |
| 56 | + * @param surah - The surah number. |
| 57 | + * @param ayah - The ayah number within the surah. |
| 58 | + * @returns The ayah ID for the given surah and ayah number. |
| 59 | + */ |
| 60 | +declare function findAyaidBySurah(surah: Surah, ayah: AyahNo): AyahId; |
| 61 | + |
| 62 | +/** |
| 63 | + * Finds the Juz (part) of the Quran that the given Ayah (verse) belongs to. |
| 64 | + * |
| 65 | + * @param surah - The Surah (chapter) number. |
| 66 | + * @param ayah - The Ayah (verse) number. Defaults to 1 if not provided. |
| 67 | + * @param ayahMode - If true, the `ayah` parameter is treated as an Ayah ID instead of a Surah and Ayah number. |
| 68 | + * @returns The Juz (part) number that the given Ayah belongs to. |
| 69 | + */ |
| 70 | +declare function findJuz(surah: Surah, ayah?: AyahNo, ayahMode?: boolean): Juz; |
| 71 | + |
| 72 | +/** |
| 73 | + * Finds the juz (section) that contains the specified ayah (verse) and calculates the number of ayahs between the start of the juz and the start of the surah (chapter) that contains the ayah. |
| 74 | + * |
| 75 | + * @param surah - The surah (chapter) that contains the ayah. |
| 76 | + * @param ayah - The ayah (verse) number. |
| 77 | + * @param ayahMode - A boolean flag indicating whether the `ayah` parameter represents an ayah number or an ayah ID. |
| 78 | + * @returns An object containing the following properties: |
| 79 | + * - `juz`: The juz (section) that contains the ayah. |
| 80 | + * - `leftAyahId`: The ayah ID of the first ayah in the juz. |
| 81 | + * - `ayahsBetweenJuzSurah`: The number of ayahs between the start of the juz and the start of the surah (positive if the surah starts is in the juz, negative if the surah starts before the juz). |
| 82 | + */ |
| 83 | +declare function findJuzAndShift(surah: Surah, ayah: AyahNo, ayahMode?: boolean): { |
| 84 | + juz: Juz; |
| 85 | + leftAyahId: AyahId; |
| 86 | + ayahsBetweenJuzSurah: number; |
| 87 | +}; |
| 88 | + |
| 89 | +/** |
| 90 | + * Finds the Juz (part) of the Quran that contains the given Ayah (verse) ID. |
| 91 | + * |
| 92 | + * @param ayaId - The ID of the Ayah (verse) to find the Juz for. |
| 93 | + * @returns The Juz (part) of the Quran that contains the given Ayah ID. |
| 94 | + */ |
| 95 | +declare function findJuzByAyaid(ayaId: AyahId): Juz; |
| 96 | + |
| 97 | +/** |
| 98 | + * Finds the Juz (part) and Hizb (section) of the Quran that the given Ayah (verse) belongs to. |
| 99 | + * |
| 100 | + * @param surah - The Surah (chapter) number. |
| 101 | + * @param ayah - The Ayah (verse) number. Defaults to 1 if not provided. |
| 102 | + * @param ayahMode - If true, the `ayah` parameter is treated as an Ayah ID instead of a Surah and Ayah number. |
| 103 | + * @returns An object containing the Juz (part) number, Hizb (section) number, and the index of the Hizb that the given Ayah belongs to. |
| 104 | + */ |
| 105 | +declare function findJuzHizb(surah: Surah, ayah?: AyahNo, ayahMode?: boolean): JuzHizb; |
| 106 | + |
| 107 | +/** |
| 108 | + * Finds the Juz, Hizb, and Hizb ID for the given Ayah ID. |
| 109 | + * |
| 110 | + * @param ayaId - The Ayah ID to find the Juz, Hizb, and Hizb ID for. |
| 111 | + * @returns An object containing the Juz, Hizb, and Hizb ID for the given Ayah ID. |
| 112 | + */ |
| 113 | +declare function findJuzHizbByAyaid(ayaId: AyahId): JuzHizb; |
| 114 | + |
| 115 | +/** |
| 116 | + * Finds the JuzMeta for a given Surah and Ayah. |
| 117 | + * |
| 118 | + * @param surah - The Surah (chapter) number. |
| 119 | + * @param ayah - The Ayah (verse) number. |
| 120 | + * @returns The JuzMeta object containing the left juz, ayahs between juz and surah, right juz, left ayah ID, and right ayah ID. |
| 121 | + */ |
| 122 | +declare function findJuzMetaBySurah(surah: Surah, ayah?: AyahNo): JuzMeta; |
| 123 | + |
| 124 | +/** |
| 125 | + * Finds the page number for the given Surah and Ayah number. |
| 126 | + * |
| 127 | + * @param surah - The Surah to find the page for. |
| 128 | + * @param ayah - The Ayah number to find the page for. |
| 129 | + * @param ayahMode - If true, the `ayah` parameter is treated as an AyahId instead of an AyahNo. |
| 130 | + * @returns The page number for the given Surah and Ayah. |
| 131 | + */ |
| 132 | +declare function findPage(surah: Surah, ayah: AyahNo, ayahMode?: boolean): Page; |
| 133 | + |
| 134 | +/** |
| 135 | + * ALternative deprecated method |
| 136 | + * @param {*} pageNum |
| 137 | + */ |
| 138 | +/** |
| 139 | + * Find range containing ayah according to the mode |
| 140 | + * @param surah |
| 141 | + * @param ayah |
| 142 | + * @param {*} mode can be either 'all', 'juz', 'surah', 'ayah', 'page' |
| 143 | + * default is all |
| 144 | + */ |
| 145 | +declare function findRangeAroundAyah(surah: Surah, ayah: AyahNo, mode: "juz" | "surah" | "ayah" | "page" | "all", ayahMode?: boolean): SurahAyah; |
| 146 | + |
| 147 | +/** |
| 148 | + * Finds the Surah (chapter) and Ayah (verse) numbers that the given Ayah ID belongs to. |
| 149 | + * |
| 150 | + * @param ayaId - The Ayah ID to find the Surah and Ayah numbers for. |
| 151 | + * @returns An array containing the Surah number and the Ayah number within that Surah. |
| 152 | + */ |
| 153 | +declare function findSurahByAyaid(ayaId: AyahId): SurahAyah; |
| 154 | + |
| 155 | +/** |
| 156 | + * Get the number of ayahs (verses) in the specified surah. |
| 157 | + * @param surah - The surah number. |
| 158 | + * @returns The number of ayahs in the specified surah. |
| 159 | + */ |
| 160 | +declare function getAyaCountinSura(surah: Surah): number; |
| 161 | + |
| 162 | +/** |
| 163 | + * Gets the metadata for the specified Surah. |
| 164 | + * |
| 165 | + * @param surah - The Surah to get the metadata for. |
| 166 | + * @returns The metadata for the specified Surah. |
| 167 | + */ |
| 168 | +declare function getSurahMeta(surah: Surah): SurahMeta; |
| 169 | + |
| 170 | +/** |
| 171 | + * Returns the Juz (part) number that the given Ayah (verse) belongs to. |
| 172 | + * |
| 173 | + * |
| 174 | + * @param surah - The Surah (chapter) number. |
| 175 | + * @param ayah - The Ayah (verse) number. |
| 176 | + * @param ayahMode - If true, the `ayah` parameter is treated as an Ayah ID instead of a Surah and Ayah number. |
| 177 | + * @returns The Juz (part) number that the given Ayah belongs to. Returns Positive number if aya is first ayah of juz, number is juz number |
| 178 | + */ |
| 179 | +declare function isAyahJuzFirst(surah: Surah, ayah: AyahNo, ayahMode?: boolean): Juz; |
| 180 | + |
| 181 | +/** |
| 182 | + * Determines if the given ayah is the first ayah of a juz. |
| 183 | + * |
| 184 | + * @param surah - The surah number. |
| 185 | + * @param ayah - The ayah number. |
| 186 | + * @param ayahMode - Optional flag to indicate if the ayah number is already a valid ayah ID. |
| 187 | + * @returns The juz number if the ayah is the first ayah of the juz, otherwise -1. |
| 188 | + */ |
| 189 | +declare function isAyahPageFirst(surah: Surah, ayah: AyahNo, ayahMode?: boolean): Juz; |
| 190 | + |
| 191 | +declare const HizbQuarterList: AyahId[]; |
| 192 | + |
| 193 | +declare const JuzList: AyahId[]; |
| 194 | + |
| 195 | +declare const ManzilList: AyahId[]; |
| 196 | + |
| 197 | +declare const PageList: AyahId[]; |
| 198 | + |
| 199 | +declare const RukuList: AyahId[]; |
| 200 | + |
| 201 | +declare const SajdaList: Sajda[]; |
| 202 | + |
| 203 | +declare const SuraList: SurahMeta[]; |
| 204 | + |
| 205 | +/** |
| 206 | + * Get the next ayah for the given surah and ayah number. |
| 207 | + * @param surah - The surah number. |
| 208 | + * @param ayah - The ayah number within the surah. |
| 209 | + * @returns The surah and ayah number of the next ayah. |
| 210 | + */ |
| 211 | +declare function nextAyah(surah: Surah, ayah: AyahNo): SurahAyah; |
| 212 | + |
| 213 | +/** |
| 214 | + * Retrieves the page metadata for the specified page number. |
| 215 | + * |
| 216 | + * @param pageNum - The page number to retrieve metadata for. |
| 217 | + * @returns The page metadata, including the first and last ayah IDs on the page. |
| 218 | + * @throws {RangeError} If the page number is out of the valid range (1 to `meta.numPages`). |
| 219 | + */ |
| 220 | +declare function pageMeta(pageNum: Page): PageMeta; |
| 221 | + |
| 222 | +/** |
| 223 | + * Get the previous ayah for the given surah and ayah number. |
| 224 | + * @param surah - The surah number. |
| 225 | + * @param ayah - The ayah number within the surah. |
| 226 | + * @returns The surah and ayah number of the previous ayah. |
| 227 | + */ |
| 228 | +declare function prevAyah(surah: Surah, ayah: AyahNo): SurahAyah; |
| 229 | + |
| 230 | +/** |
| 231 | + * Checks if the given Surah (chapter) number is valid. |
| 232 | + * |
| 233 | + * @param surah - The Surah (chapter) number to check. |
| 234 | + * @param checkOnly - If true, the function will only check the validity and not throw an error. |
| 235 | + * @returns True if the Surah number is valid, false otherwise. |
| 236 | + */ |
| 237 | +declare function checkValidSurah(surah: number, checkOnly?: boolean): boolean; |
| 238 | +/** |
| 239 | + * Checks if the given Surah and Ayah (verse) numbers are valid. |
| 240 | + * |
| 241 | + * @param surah - The Surah (chapter) number to check. |
| 242 | + * @param ayah - The Ayah (verse) number to check. |
| 243 | + * @param checkOnly - If true, the function will only check the validity and not throw an error. |
| 244 | + * @returns True if the Surah and Ayah numbers are valid, false otherwise. |
| 245 | + */ |
| 246 | +declare function checkValidSurahAyah(surah: number, ayah: number, checkOnly?: boolean): boolean; |
| 247 | +/** |
| 248 | + * Checks if the given Ayah (verse) ID is valid. |
| 249 | + * |
| 250 | + * @param ayahId - The Ayah (verse) ID to check. |
| 251 | + * @param checkOnly - If true, the function will only check the validity and not throw an error. |
| 252 | + * @returns True if the Ayah ID is valid, otherwise throws a RangeError. |
| 253 | + */ |
| 254 | +declare function checkValidAyahId(ayahId: number, checkOnly?: boolean): boolean; |
| 255 | + |
| 256 | +declare const suraNames$1: (SuraName | [])[]; |
| 257 | + |
| 258 | +declare const suraNames: (SuraName | [])[]; |
| 259 | + |
| 260 | +export { type AyahId, type AyahNo, HizbQuarterList, type Juz, type JuzHizb, JuzList, type JuzMeta, ManzilList, type Page, PageList, type PageMeta, type QuranMeta, RukuList, type Sajda, SajdaList, type SajdaType, SuraList, type SuraName, type Surah, type SurahAyah, type SurahAyahSegment, type SurahMeta, ayaStringSplitter, checkValidAyahId, checkValidSurah, checkValidSurahAyah, findAyaidBySurah, findJuz, findJuzAndShift, findJuzByAyaid, findJuzHizb, findJuzHizbByAyaid, findJuzMetaBySurah, findPage, findRangeAroundAyah, findSurahByAyaid, getAyaCountinSura, getSurahMeta, isAyahJuzFirst, isAyahPageFirst, meta, nextAyah, pageMeta, prevAyah, suraNames$1 as suraNamesEn, suraNames as suraNamesRu }; |
0 commit comments