UNPKG

quran-meta

Version:

Library with meta data and functionality related to Holy Quran

19 lines (17 loc) 609 B
import { checkValidAyahId } from "./validation.mjs"; import { binarySearch } from "./utils.mjs"; //#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) { checkValidAyahId(ayahId, data.meta); const jj = binarySearch(data.JuzList, ayahId); return jj < 0 ? -jj - 2 : jj; } //#endregion export { findJuzByAyahId };