UNPKG

quran-meta

Version:

Library with meta data and functionality related to Holy Quran

12 lines (11 loc) 425 B
import { findAyahIdBySurah } from "./findAyahIdBySurah.mjs"; import { PageList } from "./lists/pageList.mjs"; import { binarySearch } from "./utils.mjs"; import { checkValidSurah } from "./validation.mjs"; export function findPage(surah, ayah = 1) { checkValidSurah(surah); const ayahId = findAyahIdBySurah(surah, ayah); const jj = binarySearch(PageList, ayahId); const page = jj < 0 ? -jj - 2 : jj; return page; }