UNPKG

quran-meta

Version:

Library with meta data and functionality related to Holy Quran

54 lines (53 loc) 2.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getAyahMeta = getAyahMeta; var _findPagebyAyahId = require("./findPagebyAyahId.cjs"); var _findSurahAyahByAyahId = require("./findSurahAyahByAyahId.cjs"); var _getRubAlHizbByAyahId = require("./getRubAlHizbByAyahId.cjs"); var _hizbQuarterList = require("./lists/hizbQuarterList.cjs"); var _juzList = require("./lists/juzList.cjs"); var _pageList = require("./lists/pageList.cjs"); var _rukuList = require("./lists/rukuList.cjs"); var _sajdaList = require("./lists/sajdaList.cjs"); var _surahList = require("./lists/surahList.cjs"); var _utils = require("./utils.cjs"); var _validation = require("./validation.cjs"); function getAyahMeta(ayahId) { (0, _validation.checkValidAyahId)(ayahId); const quarterData = (0, _getRubAlHizbByAyahId.getRubAlHizbByAyahId)(ayahId); const [surah, ayah] = (0, _findSurahAyahByAyahId.findSurahAyahByAyahId)(ayahId); const page = (0, _findPagebyAyahId.findPagebyAyahId)(ayahId); const isSajdahAyah = (0, _utils.binarySearch)(_sajdaList.SajdaList, ayahId, (a, b) => a - b[0]) >= 0; const rk = (0, _utils.binarySearch)(_rukuList.RukuList, ayahId); const isStartOfRuku = rk > 0; const ruku = isStartOfRuku ? rk : -rk - 2; const isStartOfSurah = _surahList.SurahList[surah][0] === ayahId; const isStartOfPage = _pageList.PageList[page] === ayahId; const isStartOfJuz = _juzList.JuzList[quarterData.juz] === ayahId; const isStartOfQuarter = _hizbQuarterList.HizbQuarterList[quarterData.rubAlHizbId] === ayahId; const isEndOfSurah = _surahList.SurahList[surah + 1][0] - 1 === ayahId; const isEndOfPage = _pageList.PageList[page + 1] - 1 === ayahId; const isEndOfJuz = _juzList.JuzList[quarterData.juz + 1] - 1 === ayahId; const isEndOfRuku = (0, _utils.binarySearch)(_rukuList.RukuList, ayahId + 1) > 0; const isEndOfQuarter = _hizbQuarterList.HizbQuarterList[quarterData.rubAlHizbId + 1] - 1 === ayahId; return { ...quarterData, surah, ayah, page, isStartOfQuarter, isEndOfQuarter, isSajdahAyah, isStartOfPage, isEndOfPage, ruku, isStartOfJuz, isEndOfJuz, isStartOfSurah, isEndOfSurah, isStartOfRuku, isEndOfRuku }; }