UNPKG

quran-meta

Version:

Library with meta data and functionality related to Holy Quran

49 lines (47 loc) 2.18 kB
const require_const = require('./const.cjs'); const require_surahList = require('./lists/surahList.cjs'); const require_juzList = require('./lists/juzList.cjs'); const require_findJuzByAyahId = require('./findJuzByAyahId.cjs'); const require_findSurahByAyahId = require('./findSurahByAyahId.cjs'); const require_pageList = require('./lists/pageList.cjs'); const require_findPagebyAyahId = require('./findPagebyAyahId.cjs'); const require_rukuList = require('./lists/rukuList.cjs'); const require_findRukuByAyahId = require('./findRukuByAyahId.cjs'); //#region src/findRangeAroundAyah.ts /** * Finds the range of ayahs surrounding a given ayah based on specified mode * @param ayahId - The unique identifier of the ayah * @param mode - The scope for finding the range: * - "juz": Returns range of ayahs in the same juz * - "surah": Returns range of ayahs in the same surah * - "ayah": Returns the single ayah as both start and end of range * - "page": Returns range of ayahs on the same page * - "ruku": Returns range of ayahs on the same ruku * - "all": Returns range covering all ayahs (1 to total number of ayahs) * @returns An array of two numbers representing the start and end ayah IDs of the range [startAyahId, endAyahId] */ function findRangeAroundAyah(ayahId, mode) { switch (mode) { case "juz": { const juz = require_findJuzByAyahId.findJuzByAyahId(ayahId); return [require_juzList.JuzList[juz], require_juzList.JuzList[juz + 1] - 1]; } case "surah": { const surah = require_findSurahByAyahId.findSurahByAyahId(ayahId); return [require_surahList.SurahList[surah][0], require_surahList.SurahList[surah + 1][0] - 1]; } case "ayah": return [ayahId, ayahId]; case "page": { const page = require_findPagebyAyahId.findPagebyAyahId(ayahId); return [require_pageList.PageList[page], require_pageList.PageList[page + 1] - 1]; } case "ruku": { const ruku = require_findRukuByAyahId.findRukuByAyahId(ayahId); return [require_rukuList.RukuList[ruku], require_rukuList.RukuList[ruku + 1] - 1]; } case "all": default: return [1, require_const.meta.numAyahs]; } } //#endregion exports.findRangeAroundAyah = findRangeAroundAyah;