UNPKG

quran-meta

Version:

Library with meta data and functionality related to Holy Quran

26 lines (24 loc) 859 B
const require_validation = require('./validation.cjs'); const require_utils = require('./utils.cjs'); //#region src/findPagebyAyahId.ts /** * Returns the page number for a given ayah ID in the Quran. * * @param ayahId - A numeric identifier representing a verse (ayah) in the Quran * @param data - The Lists object for the riwaya. * @returns The page number where the specified ayah can be found * @throws Will throw an error if the ayahId is invalid * * @example * ```ts * const page = findPagebyAyahId(142, HafsLists); // Returns the page number containing ayah 142 * ``` */ function findPagebyAyahId(ayahId, data) { require_validation.checkValidAyahId(ayahId, data.meta); const PageList = data.PageList; const jj = require_utils.binarySearch(PageList, ayahId); return jj < 0 ? -jj - 2 : jj; } //#endregion exports.findPagebyAyahId = findPagebyAyahId;