quran-meta
    Preparing search index...

    Class QuranRiwaya<R>

    QuranRiwaya class provides a clean API for Quran metadata operations with a specific riwaya (recitation tradition) context.

    It covers the whole functional API (surahs, ayahs, juz, pages, manzils, rukus, rub' al-hizb and thumun al-hizb, validation and parsing) bound to one riwaya's data.

    Basic Usage with Hafs

    import { quran } from 'quran-meta/hafs'

    const surahMeta = quran.getSurahMeta(2) // Get Al-Baqarah metadata
    const ayahCount = quran.getAyahCountInSurah(2) // 286 ayahs
    const [surah, ayah] = quran.findSurahAyahByAyahId(100) // [2, 93]

    Working with Qalun

    import { quran } from 'quran-meta/qalun'

    const meta = quran.meta
    console.log(meta.numAyahs) // 6214 (Qalun has fewer ayahs than Hafs)

    Creating a custom instance

    QuranRiwaya.create() takes a Lists object (SurahList, JuzList, PageList, etc. plus meta) shaped like the built-in data. The easiest way to build one is customizeRiwaya, which starts from a built-in riwaya and replaces some lists:

    import { QuranRiwaya, customizeRiwaya, getListsOfRiwaya } from 'quran-meta'

    const custom = QuranRiwaya.create(customizeRiwaya(getListsOfRiwaya("Hafs"), { PageList: myPages }))

    Type Parameters

    Index
    • Iterates over every [surah, ayah] in a part of the Quran

      Parameters

      • type: "juz" | "surah" | "page" | "ruku" | "rubAlHizb" | "thumunAlHizb" | "manzil"
      • num: number

      Returns Generator<SurahAyah, void, undefined>

    • Finds the juz number for a given ayah ID

      Parameters

      • ayahId: number

      Returns Juz

    • Finds the manzil number for a given ayah ID

      Parameters

      • ayahId: number

      Returns Manzil

    • Finds the page number for a given ayah ID

      Parameters

      • ayahId: number

      Returns Page

    • Finds the ruku number for a given ayah ID

      Parameters

      • ayahId: number

      Returns Ruku

    • Finds the surah number for a given ayah ID

      Parameters

      • ayahId: number

      Returns Surah

    • Formats an ayah id as a "surah:ayah" reference

      Parameters

      • ayahId: number

      Returns string

    • Returns the parts of a kind as { startAyahId, ayahCount } blocks, or null when the riwaya has no such data

      Parameters

      • type: "juz" | "surah" | "page" | "ruku" | "rubAlHizb" | "thumunAlHizb" | "manzil"

      Returns PartBlock[] | null

    • Gets the count of ayahs in a surah

      Parameters

      Returns number

    • Returns the parts of a kind as { startAyahId, ayahCount } blocks

      Parameters

      • type: "juz" | "surah" | "page" | "ruku" | "rubAlHizb" | "thumunAlHizb" | "manzil"

      Returns PartBlock[]

    • Returns [firstAyahId, lastAyahId] of a surah, juz, page, manzil, ruku, rub' al-hizb or thumun al-hizb

      Parameters

      • type: "juz" | "surah" | "page" | "ruku" | "rubAlHizb" | "thumunAlHizb" | "manzil"
      • num: number

      Returns AyahRange

    • Gets RubAlHizb data (juz, hizb, etc.) for a given ayah ID

      Parameters

      • ayahId: number

      Returns RubAlHizb

    • Checks if an ayah is the first ayah of a juz

      Parameters

      • ayahId: number

      Returns number

    • Checks if an ayah is the first ayah of a page

      Parameters

      • ayahId: number

      Returns number

    • Checks if a surah-ayah combination is the first ayah of a juz

      Parameters

      Returns number

    • Checks if a surah-ayah combination is the first ayah of a page

      Parameters

      Returns number

    • Parameters

      • x: unknown

      Returns x is number

    • Gets the next ayah after the given surah and ayah. Wraps from the last ayah to 1:1 unless { wrap: false } is passed, in which case it returns undefined.

      Parameters

      • surah: Surah
      • ayah: AyahNo
      • Optionaloptions: { wrap?: true }

      Returns SurahAyah

    • Gets the next ayah after the given surah and ayah. Wraps from the last ayah to 1:1 unless { wrap: false } is passed, in which case it returns undefined.

      Parameters

      Returns SurahAyah | undefined

    • Gets the previous ayah before the given surah and ayah. Wraps from 1:1 to the last ayah unless { wrap: false } is passed, in which case it returns undefined.

      Parameters

      • surah: Surah
      • ayah: AyahNo
      • Optionaloptions: { wrap?: true }

      Returns SurahAyah

    • Gets the previous ayah before the given surah and ayah. Wraps from 1:1 to the last ayah unless { wrap: false } is passed, in which case it returns undefined.

      Parameters

      Returns SurahAyah | undefined

    • Parameters

      • str: string
      • isStrict: boolean = false

      Returns Surah

    • Create a QuranRiwaya instance with the specified riwaya, metadata, and lists

      Type Parameters

      • R extends "Bazzi" | "Douri" | "Hafs" | "Qalun" | "Qunbul" | "Shuba" | "Sousi" | "Warsh"

      Parameters

      • rData: Riwayas[R]

        The Lists object for this riwaya

      Returns QuranRiwaya<R>

    • Parameters

      • str: string

      Returns { ayah?: number; ayahTo?: number; surahOrAyah?: number } | null