UNPKG

quran-meta

Version:

Library with meta data and functionality related to Holy Quran

21 lines (19 loc) 855 B
const require_validation = require('./validation.cjs'); const require_utils = require('./utils.cjs'); //#region src/findThumunAlHizbByAyahId.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 data - The Lists object for the riwaya. * @returns The thumun of the Quran that contains the given Ayah ID. */ function findThumunAlHizbByAyahId(ayahId, data) { require_validation.checkValidAyahId(ayahId, data.meta); const HizbEighthList = data.HizbEighthList; if (!HizbEighthList) throw new Error(`Riwaya ${data.meta.riwayaName} does not have Hizb Eighth List data.`); const jj = require_utils.binarySearch(HizbEighthList, ayahId); return jj < 0 ? -jj - 2 : jj; } //#endregion exports.findThumunAlHizbByAyahId = findThumunAlHizbByAyahId;