UNPKG

quran-meta

Version:

Library with meta data and functionality related to Holy Quran

17 lines (16 loc) 510 B
import { meta } from "./const.mjs"; import { findSurahByAyahId } from "./findSurahByAyahId.mjs"; import { PageList } from "./lists/pageList.mjs"; export function getPageMeta(pageNum) { if (pageNum < 1 || pageNum > meta.numPages) throw new RangeError("pagenum must be between 1 and " + meta.numPages); const [curPage, nextPage] = [ PageList[pageNum], PageList[pageNum + 1] ]; return { pageNum, first: findSurahByAyahId(curPage), last: [...findSurahByAyahId(nextPage - 1)] }; }