UNPKG

quran-meta

Version:

Library with meta data and functionality related to Holy Quran

23 lines (21 loc) 822 B
const require_validation = require('./validation.cjs'); const require_findAyahIdBySurah = require('./findAyahIdBySurah.cjs'); const require_utils = require('./utils.cjs'); //#region src/findPage.ts /** * Finds the page number for the given Surah and Ayah number. * * @param surah - The Surah to find the page for. * @param ayah - The Ayah number to find the page for. * @param data - The Lists object for the riwaya. * @returns The page number for the given Surah and Ayah. */ function findPage(surah, ayah = 1, data) { require_validation.checkValidSurah(surah, data.meta); const ayahId = require_findAyahIdBySurah.findAyahIdBySurah(surah, ayah, data); const PageList = data.PageList; const jj = require_utils.binarySearch(PageList, ayahId); return jj < 0 ? -jj - 2 : jj; } //#endregion exports.findPage = findPage;