UNPKG

quran-meta

Version:

Library with meta data and functionality related to Holy Quran

19 lines (17 loc) 662 B
const require_validation = require('./validation.cjs'); const require_utils = require('./utils.cjs'); //#region src/findJuzByAyahId.ts /** * Finds the Juz (part) 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 containing JuzList. * @returns The Juz (part) of the Quran that contains the given Ayah ID. */ function findJuzByAyahId(ayahId, data) { require_validation.checkValidAyahId(ayahId, data.meta); const jj = require_utils.binarySearch(data.JuzList, ayahId); return jj < 0 ? -jj - 2 : jj; } //#endregion exports.findJuzByAyahId = findJuzByAyahId;