quran-meta
Version:
Library with meta data and functionality related to Holy Quran
20 lines (18 loc) • 677 B
JavaScript
const require_validation = require('./validation.cjs');
const require_juzList = require('./lists/juzList.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.
* @returns The Juz (part) of the Quran that contains the given Ayah ID.
*/
function findJuzByAyahId(ayahId) {
require_validation.checkValidAyahId(ayahId);
const jj = require_utils.binarySearch(require_juzList.JuzList, ayahId);
const juz = jj < 0 ? -jj - 2 : jj;
return juz;
}
//#endregion
exports.findJuzByAyahId = findJuzByAyahId;