quran-meta
Version:
Library with meta data and functionality related to Holy Quran
16 lines (13 loc) • 491 B
text/typescript
import { JuzList } from "./lists/juzList"
import { AyahId, Juz } from "./types"
import { checkValidAyahId } from "./validation"
/**
* 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.
*/
export function findJuzByAyahId(ayahId: AyahId): Juz {
checkValidAyahId(ayahId)
return JuzList.findIndex(x => x > ayahId) - 1
}