quran-meta
Version:
Library with meta data and functionality related to Holy Quran
404 lines (402 loc) • 13 kB
JavaScript
const require_getSurahInfo = require('./getSurahInfo.cjs');
const require_getAyahCountInSurah = require('./getAyahCountInSurah.cjs');
const require_typeGuards = require('./typeGuards.cjs');
const require_ayahStringSplitter = require('./ayahStringSplitter.cjs');
const require_findAyahIdBySurah = require('./findAyahIdBySurah.cjs');
const require_findJuzByAyahId = require('./findJuzByAyahId.cjs');
const require_findJuz = require('./findJuz.cjs');
const require_findSurahAyahByAyahId = require('./findSurahAyahByAyahId.cjs');
const require_findSurahByAyahId = require('./findSurahByAyahId.cjs');
const require_findJuzAndShift = require('./findJuzAndShift.cjs');
const require_findJuzMetaBySurah = require('./findJuzMetaBySurah.cjs');
const require_findManzilByAyahId = require('./findManzilByAyahId.cjs');
const require_findManzil = require('./findManzil.cjs');
const require_findPage = require('./findPage.cjs');
const require_findPagebyAyahId = require('./findPagebyAyahId.cjs');
const require_findRukuByAyahId = require('./findRukuByAyahId.cjs');
const require_findRangeAroundAyah = require('./findRangeAroundAyah.cjs');
const require_findRangeAroundSurahAyah = require('./findRangeAroundSurahAyah.cjs');
const require_findRubAlHizbByAyahId = require('./findRubAlHizbByAyahId.cjs');
const require_findRubAlHizb = require('./findRubAlHizb.cjs');
const require_findThumunAlHizbByAyahId = require('./findThumunAlHizbByAyahId.cjs');
const require_findThumunAlHizb = require('./findThumunAlHizb.cjs');
const require_getList = require('./lists/getList.cjs');
const require_getRubAlHizb = require('./getRubAlHizb.cjs');
const require_getRubAlHizbByAyahId = require('./getRubAlHizbByAyahId.cjs');
const require_getAyahMeta = require('./getAyahMeta.cjs');
const require_getAyahMetasForSurah = require('./getAyahMetasForSurah.cjs');
const require_getJuzMeta = require('./getJuzMeta.cjs');
const require_getManzilMeta = require('./getManzilMeta.cjs');
const require_getPageMeta = require('./getPageMeta.cjs');
const require_getRubAlHizbMeta = require('./getRubAlHizbMeta.cjs');
const require_getRubAlHizbMetaByAyahId = require('./getRubAlHizbMetaByAyahId.cjs');
const require_getRukuMeta = require('./getRukuMeta.cjs');
const require_getSurahMeta = require('./getSurahMeta.cjs');
const require_getThumunAlHizb = require('./getThumunAlHizb.cjs');
const require_getThumunAlHizbByAyahId = require('./getThumunAlHizbByAyahId.cjs');
const require_getThumunAlHizbMeta = require('./getThumunAlHizbMeta.cjs');
const require_prevAyah = require('./prevAyah.cjs');
const require_nextAyah = require('./nextAyah.cjs');
const require_isAyahJuzFirst = require('./isAyahJuzFirst.cjs');
const require_isAyahPageFirst = require('./isAyahPageFirst.cjs');
const require_isSurahAyahJuzFirst = require('./isSurahAyahJuzFirst.cjs');
const require_isSurahAyahPageFirst = require('./isSurahAyahPageFirst.cjs');
const require_getThumunAlHizbMetaByAyahId = require('./getThumunAlHizbMetaByAyahId.cjs');
const require_surahStringParser = require('./surahStringParser.cjs');
//#region src/QuranRiwaya.ts
/**
* QuranRiwaya class provides a clean API for Quran metadata operations
* with a specific riwaya (recitation tradition) context.
*
* Currently provides basic Surah and Ayah operations. For advanced features
* like Juz, Page, Manzil, RubAlHizb, etc., use the functional API directly.
*
* @example
* **Basic Usage with Hafs**
* ```typescript
* 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]
* ```
*
* @example
* **Working with Qalun**
* ```typescript
* import { quran } from 'quran-meta/qalun'
*
* const meta = quran.meta
* console.log(meta.numAyahs) // 6214 (Qalun has fewer ayahs than Hafs)
* ```
*
* @example
* **Creating a custom instance**
* ```typescript
* import { QuranRiwaya } from 'quran-meta'
* import { WarshMeta, WarshLists } from 'quran-meta/lists/WarshLists'
*
* const warsh = QuranRiwaya.create(WarshLists)
* ```
*/
var QuranRiwaya = class QuranRiwaya {
#riwaya;
#meta;
#data;
constructor(rData) {
this.#riwaya = rData.meta.riwayaName;
this.#meta = rData.meta;
this.#data = rData;
}
/**
* Create a QuranRiwaya instance with the specified riwaya, metadata, and lists
* @param riwaya - The riwaya name ("Hafs", "Qalun", or "Warsh")
* @param meta - The metadata for this riwaya
* @param rData - The Lists object for this riwaya
*/
static create(rData) {
return new QuranRiwaya(rData);
}
/**
* Gets the metadata for the specified Surah
*/
getSurahMeta(surahNum) {
return require_getSurahMeta.getSurahMeta(surahNum, this.#data);
}
ayahStringSplitter(str, isStrict = true) {
return require_ayahStringSplitter.ayahStringSplitter(str, isStrict, this.#data);
}
/**
* Gets the surah info array [firstAyahId, ayahCount, surahOrder, rukuCount, name, isMeccan]
*/
getSurahInfo(surah) {
return require_getSurahInfo.getSurahInfo(surah, this.#data);
}
/**
* Gets the count of ayahs in a surah
*/
getAyahCountInSurah(surah) {
return require_getAyahCountInSurah.getAyahCountInSurah(surah, this.#data);
}
/**
* Finds the surah number for a given ayah ID
*/
findSurahByAyahId(ayahId) {
return require_findSurahByAyahId.findSurahByAyahId(ayahId, this.#data);
}
/**
* Finds the [surah, ayah] tuple for a given ayah ID
*/
findSurahAyahByAyahId(ayahId) {
return require_findSurahAyahByAyahId.findSurahAyahByAyahId(ayahId, this.#data);
}
/**
* Finds the ayah ID for a given surah and ayah number
*/
findAyahIdBySurah(surah, ayah) {
return require_findAyahIdBySurah.findAyahIdBySurah(surah, ayah, this.#data);
}
generatePartBlocks(type) {
return require_getList.generatePartBlocks(type, this.#data);
}
getList(type) {
return require_getList.getList(type, this.#data);
}
getListNormalised(type) {
return require_getList.getListNormalised(type, this.#data);
}
/**
* Gets the next ayah after the given surah and ayah
*/
nextAyah(surah, ayah) {
return require_nextAyah.nextAyah(surah, ayah, this.#data);
}
/**
* Gets the previous ayah before the given surah and ayah
*/
prevAyah(surah, ayah) {
return require_prevAyah.prevAyah(surah, ayah, this.#data);
}
/**
* Finds the juz number for a given surah and ayah
*/
findJuz(surah, ayah = 1) {
return require_findJuz.findJuz(surah, ayah, this.#data);
}
/**
* Finds the juz number for a given ayah ID
*/
findJuzByAyahId(ayahId) {
return require_findJuzByAyahId.findJuzByAyahId(ayahId, this.#data);
}
/**
* Finds the page number for a given surah and ayah
*/
findPage(surah, ayah = 1) {
return require_findPage.findPage(surah, ayah, this.#data);
}
/**
* Finds the page number for a given ayah ID
*/
findPagebyAyahId(ayahId) {
return require_findPagebyAyahId.findPagebyAyahId(ayahId, this.#data);
}
/**
* Gets metadata for a specific page
*/
getPageMeta(pageNum) {
return require_getPageMeta.getPageMeta(pageNum, this.#data);
}
/**
* Finds the manzil number for a given surah and ayah
*/
findManzil(surah, ayah = 1) {
return require_findManzil.findManzil(surah, ayah, this.#data);
}
/**
* Finds the manzil number for a given ayah ID
*/
findManzilByAyahId(ayahId) {
return require_findManzilByAyahId.findManzilByAyahId(ayahId, this.#data);
}
/**
* Gets metadata for a specific manzil
*/
getManzilMeta(manzilNum) {
return require_getManzilMeta.getManzilMeta(manzilNum, this.#data);
}
/**
* Finds the ruku number for a given ayah ID
*/
findRukuByAyahId(ayahId) {
return require_findRukuByAyahId.findRukuByAyahId(ayahId, this.#data);
}
/**
* Gets metadata for a specific ruku
*/
getRukuMeta(rukuNum) {
return require_getRukuMeta.getRukuMeta(rukuNum, this.#data);
}
/**
* Gets metadata for a specific juz
*/
getJuzMeta(juzNum) {
return require_getJuzMeta.getJuzMeta(juzNum, this.#data);
}
/**
* Finds juz metadata for a given surah and ayah
*/
findJuzMetaBySurah(surah, ayah = 1) {
return require_findJuzMetaBySurah.findJuzMetaBySurah(surah, ayah, this.#data);
}
/**
* Finds juz and calculates shift between juz start and surah start
*/
findJuzAndShift(surah, ayah) {
return require_findJuzAndShift.findJuzAndShift(surah, ayah, this.#data);
}
/**
* Finds juz and shift for a given ayah ID
*/
findJuzAndShiftByAyahId(ayahId) {
return require_findJuzAndShift.findJuzAndShiftByAyahId(ayahId, this.#data);
}
/**
* Finds the RubAlHizb for a given surah and ayah
*/
findRubAlHizb(surah, ayah = 1) {
return require_findRubAlHizb.findRubAlHizb(surah, ayah, this.#data);
}
/**
* Finds the RubAlHizb ID for a given ayah ID
*/
findRubAlHizbByAyahId(ayahId) {
return require_findRubAlHizbByAyahId.findRubAlHizbByAyahId(ayahId, this.#data);
}
/**
* Gets RubAlHizb data (juz, hizb, etc.) for a given ayah ID
*/
getRubAlHizbByAyahId(ayahId) {
return require_getRubAlHizbByAyahId.getRubAlHizbByAyahId(ayahId, this.#data);
}
/**
* Gets RubAlHizb data (juz, hizb, etc.) for a given ayah ID
*/
getRubAlHizb(quarterIndex) {
return require_getRubAlHizb.getRubAlHizb(quarterIndex);
}
/**
* Gets complete RubAlHizb metadata for a given ayah ID
*/
getRubAlHizbMetaByAyahId(ayahId) {
return require_getRubAlHizbMetaByAyahId.getRubAlHizbMetaByAyahId(ayahId, this.#data);
}
/**
* Gets metadata for a specific RubAlHizb
*/
getRubAlHizbMeta(quarterIndex) {
return require_getRubAlHizbMeta.getRubAlHizbMeta(quarterIndex, this.#data);
}
/**
* Finds the ThumunAlHizb ID for a given ayah ID (Qalun/Warsh only)
*/
findThumunAlHizbByAyahId(ayahId) {
return require_findThumunAlHizbByAyahId.findThumunAlHizbByAyahId(ayahId, this.#data);
}
/**
* Finds the ThumunAlHizb ID for a given ayah ID (Qalun/Warsh only)
*/
findThumunAlHizb(surah, ayah = 1) {
return require_findThumunAlHizb.findThumunAlHizb(surah, ayah, this.#data);
}
/**
* Gets metadata for a specific ThumunAlHizb (Qalun/Warsh only)
*/
getThumunAlHizbMeta(eighthIndex) {
return require_getThumunAlHizbMeta.getThumunAlHizbMeta(eighthIndex, this.#data);
}
getThumunAlHizbByAyahId(ayahId) {
return require_getThumunAlHizbByAyahId.getThumunAlHizbByAyahId(ayahId, this.#data);
}
getThumunAlHizbMetaByAyahId(ayahId) {
return require_getThumunAlHizbMetaByAyahId.getThumunAlHizbMetaByAyahId(ayahId, this.#data);
}
getThumunAlHizb(eighthIndex) {
return require_getThumunAlHizb.getThumunAlHizb(eighthIndex);
}
/**
* Gets comprehensive metadata for a specific ayah
*/
getAyahMeta(ayahId) {
return require_getAyahMeta.getAyahMeta(ayahId, this.#data);
}
/**
* Gets metadata for all ayahs in a surah
*/
getAyahMetasForSurah(surahNumber) {
return require_getAyahMetasForSurah.getAyahMetasForSurah(surahNumber, this.#data);
}
/**
* Finds the range of ayahs around a given ayah
*/
findRangeAroundAyah(ayahId, mode) {
return require_findRangeAroundAyah.findRangeAroundAyah(ayahId, mode, this.#data);
}
/**
* Finds the range of ayahs around a given surah and ayah
*/
findRangeAroundSurahAyah(surah, ayah, mode) {
return require_findRangeAroundSurahAyah.findRangeAroundSurahAyah(surah, ayah, mode, this.#data);
}
/**
* Checks if an ayah is the first ayah of a juz
*/
isAyahJuzFirst(ayahId) {
return require_isAyahJuzFirst.isAyahJuzFirst(ayahId, this.#data);
}
/**
* Checks if an ayah is the first ayah of a page
*/
isAyahPageFirst(ayahId) {
return require_isAyahPageFirst.isAyahPageFirst(ayahId, this.#data);
}
/**
* Checks if a surah-ayah combination is the first ayah of a juz
*/
isSurahAyahJuzFirst(surah, ayah) {
return require_isSurahAyahJuzFirst.isSurahAyahJuzFirst(surah, ayah, this.#data);
}
/**
* Checks if a surah-ayah combination is the first ayah of a page
*/
isSurahAyahPageFirst(surah, ayah) {
return require_isSurahAyahPageFirst.isSurahAyahPageFirst(surah, ayah, this.#data);
}
isValidAyahId(x) {
return require_typeGuards.isValidAyahId(x, this.#meta);
}
isValidPage(x) {
return require_typeGuards.isValidPage(x, this.#meta);
}
isValidSurah(x) {
return require_typeGuards.isValidSurah(x, this.#meta);
}
isValidJuz(x) {
return require_typeGuards.isValidJuz(x, this.#meta);
}
isValidRuku(x) {
return require_typeGuards.isValidRuku(x, this.#meta);
}
isValidSurahAyah(x) {
return require_typeGuards.isValidSurahAyah(x, this.#data);
}
static isValidAyahNo(x) {
return require_typeGuards.isValidAyahNo(x);
}
surahStringParser(str, isStrict = false) {
return require_surahStringParser.surahStringParser(str, isStrict, this.#meta);
}
static string2NumberSplitter(str) {
return require_ayahStringSplitter.string2NumberSplitter(str);
}
/**
* Gets the riwaya name
*/
get riwayaName() {
return this.#riwaya;
}
/**
* Gets the metadata for this riwaya
*/
get meta() {
return this.#meta;
}
/**
* Gets the metadata for this riwaya
*/
get lists() {
return this.#data;
}
};
//#endregion
exports.QuranRiwaya = QuranRiwaya;