UNPKG

quran-meta

Version:

Library with meta data and functionality related to Holy Quran

20 lines (18 loc) 677 B
import { checkValidAyahId } from "./validation.mjs"; import { binarySearch } from "./utils.mjs"; //#region src/findRubAlHizbByAyahId.ts /** * Finds the Maqra/Rub-al-Hizb of the Quran that contains the given Ayah (verse) ID. * * @param ayahId - The ID of the Ayah (verse) to find the Juz for. * @param lists - The Lists object for the riwaya. * @returns The Maqra of the Quran that contains the given Ayah ID. */ function findRubAlHizbByAyahId(ayahId, data) { checkValidAyahId(ayahId, data.meta); const HizbQuarterList = data.HizbQuarterList; const jj = binarySearch(HizbQuarterList, ayahId); return jj < 0 ? -jj - 2 : jj; } //#endregion export { findRubAlHizbByAyahId };