UNPKG

quran-meta

Version:

Library with meta data and functionality related to Holy Quran

23 lines (21 loc) 940 B
import { checkValidSurah } from "./validation.mjs"; import { findAyahIdBySurah } from "./findAyahIdBySurah.mjs"; import { findRangeAroundAyah } from "./findRangeAroundAyah.mjs"; //#region src/findRangeAroundSurahAyah.ts /** * Finds a range of ayahs around a given ayah based on the specified mode. * * @param surah - The surah number (1-114) * @param ayah - The ayah number within the surah * @param mode - The range mode: "juz", "surah", "ayah", "page", "ruku" or "all" * @param lists - The Lists object for the riwaya. * @returns A tuple containing the start and end ayah IDs of the range */ function findRangeAroundSurahAyah(surah, ayah, mode, data) { checkValidSurah(surah, data.meta); const SurahList = data.SurahList; if (mode === "surah") return [SurahList[surah][0], SurahList[surah + 1][0] - 1]; return findRangeAroundAyah(findAyahIdBySurah(surah, ayah, data), mode, data); } //#endregion export { findRangeAroundSurahAyah };