From 21303f77aa42b2d26113ec62245f253f879f28c6 Mon Sep 17 00:00:00 2001 From: HG <husayt@gmail.com> Date: Mon, 10 Mar 2025 11:34:17 +0000 Subject: [PATCH 1/3] feat: rename SurahMeta to SurahInfo (breaking change) --- README.md | 2 +- examples/data-check/checkKFQC.ts | 2 +- examples/data-check/checkKFQCSmart.ts | 2 +- examples/data-check/checkQuranApi.ts | 4 +- examples/data-check/checkQuranCloud.ts | 4 +- examples/data-check/checkTanzil.ts | 4 +- src/findPage.ts | 2 +- src/getAyahCountinSurah.ts | 4 +- src/getList.ts | 4 +- src/{getSurahMeta.ts => getSurahInfo.ts} | 4 +- src/index.ts | 4 +- src/lists/surahList.ts | 236 +++++++++--------- src/types.ts | 5 +- ...SurahMeta.spec.ts => getSurahInfo.spec.ts} | 15 +- tests/meta.spec.ts | 4 +- tests/quran-data.spec.ts | 6 +- 16 files changed, 151 insertions(+), 151 deletions(-) rename src/{getSurahMeta.ts => getSurahInfo.ts} (75%) rename tests/{getSurahMeta.spec.ts => getSurahInfo.spec.ts} (60%) diff --git a/README.md b/README.md index 15e1975..b30dc8f 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ Answering Questions like: * find range around ayah (`findRangeAroundAyah`) * Get meta data for * ayah (`getAyahMeta`) - * surah (`getSurahMeta`) + * surah (`getSurahInfo`, `getSurahInfo`) * page (`getPageMeta`) * juz (`findJuzMetaBySurah`) * maqra/rub-el-hizb (`getRubAlHizbMeta`, `getRubAlHizbMetaByAyahId`) diff --git a/examples/data-check/checkKFQC.ts b/examples/data-check/checkKFQC.ts index 22c6981..d2106b5 100644 --- a/examples/data-check/checkKFQC.ts +++ b/examples/data-check/checkKFQC.ts @@ -3,7 +3,7 @@ * https://qurancomplex.gov.sa/en/techquran/dev/ */ -import { findPagebyAyahId, findAyahIdBySurah, findJuz, findRubAlHizb, getAyahMeta, getRubAlHizbMetaByAyahId, HizbQuarterList, Juz, JuzList, ManzilList, meta, PageList, RukuList, SajdaList, Surah, SurahList, SurahMeta } from "../../src" +import { findPagebyAyahId, findAyahIdBySurah, findJuz, findRubAlHizb, getAyahMeta, getRubAlHizbMetaByAyahId, HizbQuarterList, Juz, JuzList, ManzilList, meta, PageList, RukuList, SajdaList, Surah, SurahList, SurahInfo } from "../../src" import { AyahNo, AyahId, Manzil, Page, Ruku } from "../../src/types" import hafsData from "./data/hafsData_v2-0.json" diff --git a/examples/data-check/checkKFQCSmart.ts b/examples/data-check/checkKFQCSmart.ts index 1ad9faf..aa8a73f 100644 --- a/examples/data-check/checkKFQCSmart.ts +++ b/examples/data-check/checkKFQCSmart.ts @@ -1,4 +1,4 @@ -import { findPagebyAyahId, findAyahIdBySurah, findJuz, findRubAlHizb, getAyahMeta, getRubAlHizbMetaByAyahId, HizbQuarterList, Juz, JuzList, ManzilList, meta, PageList, RukuList, SajdaList, Surah, SurahList, SurahMeta } from "../../src" +import { findPagebyAyahId, findAyahIdBySurah, findJuz, findRubAlHizb, getAyahMeta, getRubAlHizbMetaByAyahId, HizbQuarterList, Juz, JuzList, ManzilList, meta, PageList, RukuList, SajdaList, Surah, SurahList, SurahInfo } from "../../src" import { AyahNo, AyahId, Manzil, Page, Ruku } from "../../src/types" diff --git a/examples/data-check/checkQuranApi.ts b/examples/data-check/checkQuranApi.ts index 167d719..5674729 100644 --- a/examples/data-check/checkQuranApi.ts +++ b/examples/data-check/checkQuranApi.ts @@ -5,7 +5,7 @@ */ -import { findPagebyAyahId, findAyahIdBySurah, findJuz, findRubAlHizb, getAyahMeta, getRubAlHizbMetaByAyahId, HizbQuarterList, Juz, JuzList, ManzilList, meta, PageList, RukuList, SajdaList, Surah, SurahList, SurahMeta, getJuzMeta, getRubAlHizbMeta, getRukuMeta, getPageMeta, getManzilMeta, getSurahMeta } from "../../src" +import { findPagebyAyahId, findAyahIdBySurah, findJuz, findRubAlHizb, getAyahMeta, getRubAlHizbMetaByAyahId, HizbQuarterList, Juz, JuzList, ManzilList, meta, PageList, RukuList, SajdaList, Surah, SurahList, SurahInfo, getJuzMeta, getRubAlHizbMeta, getRukuMeta, getPageMeta, getManzilMeta, getSurahInfo } from "../../src" import { AyahNo, AyahId, Manzil, Page, Ruku, RubAlHizbId } from "../../src/types" import quranApi from "./data/quran-api.json" @@ -37,7 +37,7 @@ export function checkQuranApi() { name, isMeccan, page - ]: SurahMeta = getSurahMeta(surahNo as Surah) + ]: SurahInfo = getSurahInfo(surahNo as Surah) const { chapter, name: oName, englishname, arabicname, revelation, verses } = quranApi.chapters[surahNo - 1] if (surahNo !== chapter) console.warn("error QuranApi surah: ", surahNo, chapter) diff --git a/examples/data-check/checkQuranCloud.ts b/examples/data-check/checkQuranCloud.ts index 6679f4c..f1fd708 100644 --- a/examples/data-check/checkQuranCloud.ts +++ b/examples/data-check/checkQuranCloud.ts @@ -3,7 +3,7 @@ * https://api.alquran.cloud/v1/meta */ -import { findPagebyAyahId, findAyahIdBySurah, findJuz, findRubAlHizb, getAyahMeta, getRubAlHizbMetaByAyahId, HizbQuarterList, Juz, JuzList, ManzilList, meta, PageList, RukuList, SajdaList, Surah, SurahList, SurahMeta } from "../../src" +import { findPagebyAyahId, findAyahIdBySurah, findJuz, findRubAlHizb, getAyahMeta, getRubAlHizbMetaByAyahId, HizbQuarterList, Juz, JuzList, ManzilList, meta, PageList, RukuList, SajdaList, Surah, SurahList, SurahInfo } from "../../src" import { AyahNo, AyahId, Manzil, Page, Ruku } from "../../src/types" @@ -21,7 +21,7 @@ export function checkQuranCloud() { name, isMeccan, page - ]: SurahMeta = SurahList[surahNo] + ]: SurahInfo = SurahList[surahNo] const sura = quranCloud.data.surahs.references[surahNo - 1] if (ayahCount !== sura.numberOfAyahs) console.warn("error QuranCloud surah: ", ayahCount, sura) diff --git a/examples/data-check/checkTanzil.ts b/examples/data-check/checkTanzil.ts index ae5d2ec..a21227c 100644 --- a/examples/data-check/checkTanzil.ts +++ b/examples/data-check/checkTanzil.ts @@ -3,7 +3,7 @@ * https://tanzil.net/res/text/metadata/quran-data.js */ -import { findPagebyAyahId, findAyahIdBySurah, findJuz, findRubAlHizb, getAyahMeta, getRubAlHizbMetaByAyahId, HizbQuarterList, Juz, JuzList, ManzilList, meta, PageList, RukuList, SajdaList, Surah, SurahList, SurahMeta } from "../../src" +import { findPagebyAyahId, findAyahIdBySurah, findJuz, findRubAlHizb, getAyahMeta, getRubAlHizbMetaByAyahId, HizbQuarterList, Juz, JuzList, ManzilList, meta, PageList, RukuList, SajdaList, Surah, SurahList, SurahInfo } from "../../src" import { AyahNo, AyahId, Manzil, Page, Ruku } from "../../src/types" import tanzilData from "./data/tanzil-data.js"; @@ -15,7 +15,7 @@ export function checkTanzil() { for (let surahNo: Surah = 1; surahNo <= meta.numSurahs; surahNo++) { const [ startAyahId, ayahCount, surahOrder, rukuCount, name, isMeccan, page - ]: SurahMeta = SurahList[surahNo]; + ]: SurahInfo = SurahList[surahNo]; const sura = tanzilData.Sura[surahNo]; if (startAyahId !== sura[0] + 1) console.warn("error Tanzil surah: ", startAyahId, sura); diff --git a/src/findPage.ts b/src/findPage.ts index e0c0501..52762de 100644 --- a/src/findPage.ts +++ b/src/findPage.ts @@ -11,7 +11,7 @@ import { checkValidSurah } from "./validation" * @param ayah - The Ayah number to find the page for. * @returns The page number for the given Surah and Ayah. */ -export function findPage(surah: Surah, ayah: AyahNo | AyahId): Page { +export function findPage(surah: Surah, ayah: AyahNo | AyahId = 1): Page { checkValidSurah(surah) const ayahId: AyahId = findAyahIdBySurah(surah, ayah as AyahNo) diff --git a/src/getAyahCountinSurah.ts b/src/getAyahCountinSurah.ts index a0aa6ad..176fb86 100644 --- a/src/getAyahCountinSurah.ts +++ b/src/getAyahCountinSurah.ts @@ -1,4 +1,4 @@ -import { getSurahMeta } from "./getSurahMeta" +import { getSurahInfo } from "./getSurahInfo" import { AyahNo, Surah } from "./types" /** @@ -7,5 +7,5 @@ import { AyahNo, Surah } from "./types" * @returns The number of ayahs in the specified surah. */ export function getAyahCountInSurah(surah: Surah): AyahNo { - return getSurahMeta(surah)[1] + return getSurahInfo(surah)[1] } diff --git a/src/getList.ts b/src/getList.ts index a8ae7d2..c038b54 100644 --- a/src/getList.ts +++ b/src/getList.ts @@ -4,7 +4,7 @@ import { ManzilList } from "./lists/manzilList" import { PageList } from "./lists/pageList" import { RukuList } from "./lists/rukuList" import { SurahList } from "./lists/surahList" -import { AyahId, AyahNo, SurahMeta } from "./types" +import { AyahId, AyahNo, SurahInfo } from "./types" export const partNames = ["surah", "juz", "page", "manzil", "rubAlHizb", "ruku"] as const export type PartType = (typeof partNames)[number] @@ -33,7 +33,7 @@ type PartBlocker = (...any: unknown[]) => PartBlock function toPartFormatter(type: PartType): PartBlocker { return (type === "surah") - ? ([startAyahId, ayahCount]: SurahMeta) => ({ + ? ([startAyahId, ayahCount]: SurahInfo) => ({ startAyahId, ayahCount }) : (ayahId: AyahId, index: number) => { diff --git a/src/getSurahMeta.ts b/src/getSurahInfo.ts similarity index 75% rename from src/getSurahMeta.ts rename to src/getSurahInfo.ts index 21abcfd..81097d0 100644 --- a/src/getSurahMeta.ts +++ b/src/getSurahInfo.ts @@ -1,5 +1,5 @@ import { SurahList } from "./lists/surahList" -import { Surah, SurahMeta } from "./types" +import { Surah, SurahInfo } from "./types" import { checkValidSurah } from "./validation" /** @@ -8,7 +8,7 @@ import { checkValidSurah } from "./validation" * @param surah - The Surah to get the metadata for. * @returns The metadata for the specified Surah. */ -export function getSurahMeta(surah: Surah): SurahMeta { +export function getSurahInfo(surah: Surah): SurahInfo { checkValidSurah(surah) return SurahList[surah] } diff --git a/src/index.ts b/src/index.ts index a9534a2..ef627b5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ // Quran Meta export type { QuranMeta } from "./const" -export type { RukuMeta, RangeMode, AyahCountBetweenJuzSurah, JuzMeta, AyahId, AyahMeta, AyahNo, AyahRange, HizbId, Juz, RubAlHizb, RubAlHizbMeta, SurahJuzMeta, JuzPart, Manzil, Page, PageMeta, RubAlHizbId, Ruku, Sajda, SajdaType, Surah, SurahAyah, SurahAyahSegment, SurahMeta, SurahName } from "./types" +export type { RukuMeta, RangeMode, AyahCountBetweenJuzSurah, JuzMeta, AyahId, AyahMeta, AyahNo, AyahRange, HizbId, Juz, RubAlHizb, RubAlHizbMeta, SurahJuzMeta, JuzPart, Manzil, Page, PageMeta, RubAlHizbId, Ruku, Sajda, SajdaType, Surah, SurahAyah, SurahAyahSegment, SurahInfo, SurahName } from "./types" export { ayahStringSplitter, string2NumberSplitter, string2NumberSplitterStrict } from "./ayahStringSplitter" export { surahStringParser } from "./surahStringParser" @@ -34,7 +34,7 @@ export { getRubAlHizb } from "./getRubAlHizb" export { getRubAlHizbMeta } from "./getRubAlHizbMeta" export { getRubAlHizbMetaByAyahId } from "./getRubAlHizbMetaByAyahId" export { getRubAlHizbByAyahId } from "./getRubAlHizbByAyahId" -export { getSurahMeta } from "./getSurahMeta" +export { getSurahInfo as getSurahInfo } from "./getSurahInfo" export { isAyahJuzFirst } from "./isAyahJuzFirst" export { isAyahPageFirst } from "./isAyahPageFirst" export { isSurahAyahJuzFirst } from "./isSurahAyahJuzFirst" diff --git a/src/lists/surahList.ts b/src/lists/surahList.ts index a3270a5..a6ea1b7 100644 --- a/src/lists/surahList.ts +++ b/src/lists/surahList.ts @@ -1,120 +1,120 @@ -import { SurahMeta } from "../types" +import { SurahInfo } from "../types" -export const SurahList: SurahMeta[] = [ - [-1, 1, 1, 1, "", false, 0], // this value is not used, but is here to make the array 1-indexed - [1, 7, 5, 1, "الفاتحة", true, 1], - [8, 286, 87, 40, "البقرة", false, 2], - [294, 200, 89, 20, "آل عمران", false, 50], - [494, 176, 92, 24, "النساء", false, 77], - [670, 120, 112, 16, "المائدة", false, 107], - [790, 165, 55, 20, "الأنعام", true, 128], - [955, 206, 39, 24, "الأعراف", true, 151], - [1161, 75, 88, 10, "الأنفال", false, 177], - [1236, 129, 113, 16, "التوبة", false, 187], - [1365, 109, 51, 11, "يونس", true, 208], - [1474, 123, 52, 10, "هود", true, 222], - [1597, 111, 53, 12, "يوسف", true, 236], - [1708, 43, 96, 6, "الرعد", false, 249], - [1751, 52, 72, 7, "ابراهيم", true, 256], - [1803, 99, 54, 6, "الحجر", true, 262], - [1902, 128, 70, 16, "النحل", true, 268], - [2030, 111, 50, 12, "الإسراء", true, 282], - [2141, 110, 69, 12, "الكهف", true, 294], - [2251, 98, 44, 6, "مريم", true, 305], - [2349, 135, 45, 8, "طه", true, 313], - [2484, 112, 73, 7, "الأنبياء", true, 322], - [2596, 78, 103, 10, "الحج", false, 332], - [2674, 118, 74, 6, "المؤمنون", true, 342], - [2792, 64, 102, 9, "النور", false, 350], - [2856, 77, 42, 6, "الفرقان", true, 360], - [2933, 227, 47, 11, "الشعراء", true, 367], - [3160, 93, 48, 7, "النمل", true, 377], - [3253, 88, 49, 8, "القصص", true, 386], - [3341, 69, 85, 7, "العنكبوت", true, 397], - [3410, 60, 84, 6, "الروم", true, 405], - [3470, 34, 57, 3, "لقمان", true, 411], - [3504, 30, 75, 3, "السجدة", true, 415], - [3534, 73, 90, 9, "الأحزاب", false, 418], - [3607, 54, 58, 6, "سبإ", true, 428], - [3661, 45, 43, 5, "فاطر", true, 435], - [3706, 83, 41, 5, "يس", true, 441], - [3789, 182, 56, 5, "الصافات", true, 446], - [3971, 88, 38, 5, "ص", true, 453], - [4059, 75, 59, 8, "الزمر", true, 459], - [4134, 85, 60, 9, "غافر", true, 468], - [4219, 54, 61, 6, "فصلت", true, 477], - [4273, 53, 62, 5, "الشورى", true, 483], - [4326, 89, 63, 7, "الزخرف", true, 490], - [4415, 59, 64, 3, "الدخان", true, 496], - [4474, 37, 65, 4, "الجاثية", true, 499], - [4511, 35, 66, 4, "الأحقاف", true, 503], - [4546, 38, 95, 4, "محمد", false, 507], - [4584, 29, 111, 4, "الفتح", false, 511], - [4613, 18, 106, 2, "الحجرات", false, 516], - [4631, 45, 34, 3, "ق", true, 518], - [4676, 60, 67, 3, "الذاريات", true, 521], - [4736, 49, 76, 2, "الطور", true, 524], - [4785, 62, 23, 3, "النجم", true, 526], - [4847, 55, 37, 3, "القمر", true, 529], - [4902, 78, 97, 3, "الرحمن", false, 532], - [4980, 96, 46, 3, "الواقعة", true, 535], - [5076, 29, 94, 4, "الحديد", false, 538], - [5105, 22, 105, 3, "المجادلة", false, 542], - [5127, 24, 101, 3, "الحشر", false, 546], - [5151, 13, 91, 2, "الممتحنة", false, 549], - [5164, 14, 109, 2, "الصف", false, 552], - [5178, 11, 110, 2, "الجمعة", false, 553], - [5189, 11, 104, 2, "المنافقون", false, 555], - [5200, 18, 108, 2, "التغابن", false, 556], - [5218, 12, 99, 2, "الطلاق", false, 558], - [5230, 12, 107, 2, "التحريم", false, 560], - [5242, 30, 77, 2, "الملك", true, 562], - [5272, 52, 2, 2, "القلم", true, 565], - [5324, 52, 78, 2, "الحاقة", true, 567], - [5376, 44, 79, 2, "المعارج", true, 569], - [5420, 28, 71, 2, "نوح", true, 571], - [5448, 28, 40, 2, "الجن", true, 572], - [5476, 20, 3, 2, "المزمل", true, 574], - [5496, 56, 4, 2, "المدثر", true, 576], - [5552, 40, 31, 2, "القيامة", true, 578], - [5592, 31, 98, 2, "الانسان", false, 579], - [5623, 50, 33, 2, "المرسلات", true, 581], - [5673, 40, 80, 2, "النبإ", true, 582], - [5713, 46, 81, 2, "النازعات", true, 584], - [5759, 42, 24, 1, "عبس", true, 585], - [5801, 29, 7, 1, "التكوير", true, 586], - [5830, 19, 82, 1, "الإنفطار", true, 587], - [5849, 36, 86, 1, "المطففين", true, 588], - [5885, 25, 83, 1, "الإنشقاق", true, 589], - [5910, 22, 27, 1, "البروج", true, 590], - [5932, 17, 36, 1, "الطارق", true, 591], - [5949, 19, 8, 1, "الأعلى", true, 592], - [5968, 26, 68, 1, "الغاشية", true, 592], - [5994, 30, 10, 1, "الفجر", true, 593], - [6024, 20, 35, 1, "البلد", true, 594], - [6044, 15, 26, 1, "الشمس", true, 595], - [6059, 21, 9, 1, "الليل", true, 596], - [6080, 11, 11, 1, "الضحى", true, 596], - [6091, 8, 12, 1, "الشرح", true, 596], - [6099, 8, 28, 1, "التين", true, 597], - [6107, 19, 1, 1, "العلق", true, 597], - [6126, 5, 25, 1, "القدر", true, 598], - [6131, 8, 100, 1, "البينة", false, 599], - [6139, 8, 93, 1, "الزلزلة", false, 599], - [6147, 11, 14, 1, "العاديات", true, 600], - [6158, 11, 30, 1, "القارعة", true, 600], - [6169, 8, 16, 1, "التكاثر", true, 600], - [6177, 3, 13, 1, "العصر", true, 601], - [6180, 9, 32, 1, "الهمزة", true, 601], - [6189, 5, 19, 1, "الفيل", true, 601], - [6194, 4, 29, 1, "قريش", true, 602], - [6198, 7, 17, 1, "الماعون", true, 602], - [6205, 3, 15, 1, "الكوثر", true, 602], - [6208, 6, 18, 1, "الكافرون", true, 603], - [6214, 3, 114, 1, "النصر", false, 603], - [6217, 5, 6, 1, "المسد", true, 603], - [6222, 4, 22, 1, "الإخلاص", true, 604], - [6226, 5, 20, 1, "الفلق", true, 604], - [6231, 6, 21, 1, "الناس", true, 604], - [6237, 1, 1, 1, "", false, 604] // this value is not used, but is here to be used as a length check +export const SurahList: SurahInfo[] = [ + [-1, 1, 1, 1, "", false], // this value is not used, but is here to make the array 1-indexed + [1, 7, 5, 1, "الفاتحة", true], + [8, 286, 87, 40, "البقرة", false], + [294, 200, 89, 20, "آل عمران", false], + [494, 176, 92, 24, "النساء", false], + [670, 120, 112, 16, "المائدة", false], + [790, 165, 55, 20, "الأنعام", true], + [955, 206, 39, 24, "الأعراف", true], + [1161, 75, 88, 10, "الأنفال", false], + [1236, 129, 113, 16, "التوبة", false], + [1365, 109, 51, 11, "يونس", true], + [1474, 123, 52, 10, "هود", true], + [1597, 111, 53, 12, "يوسف", true], + [1708, 43, 96, 6, "الرعد", false], + [1751, 52, 72, 7, "ابراهيم", true], + [1803, 99, 54, 6, "الحجر", true], + [1902, 128, 70, 16, "النحل", true], + [2030, 111, 50, 12, "الإسراء", true], + [2141, 110, 69, 12, "الكهف", true], + [2251, 98, 44, 6, "مريم", true], + [2349, 135, 45, 8, "طه", true], + [2484, 112, 73, 7, "الأنبياء", true], + [2596, 78, 103, 10, "الحج", false], + [2674, 118, 74, 6, "المؤمنون", true], + [2792, 64, 102, 9, "النور", false], + [2856, 77, 42, 6, "الفرقان", true], + [2933, 227, 47, 11, "الشعراء", true], + [3160, 93, 48, 7, "النمل", true], + [3253, 88, 49, 8, "القصص", true], + [3341, 69, 85, 7, "العنكبوت", true], + [3410, 60, 84, 6, "الروم", true], + [3470, 34, 57, 3, "لقمان", true], + [3504, 30, 75, 3, "السجدة", true], + [3534, 73, 90, 9, "الأحزاب", false], + [3607, 54, 58, 6, "سبإ", true], + [3661, 45, 43, 5, "فاطر", true], + [3706, 83, 41, 5, "يس", true], + [3789, 182, 56, 5, "الصافات", true], + [3971, 88, 38, 5, "ص", true], + [4059, 75, 59, 8, "الزمر", true], + [4134, 85, 60, 9, "غافر", true], + [4219, 54, 61, 6, "فصلت", true], + [4273, 53, 62, 5, "الشورى", true], + [4326, 89, 63, 7, "الزخرف", true], + [4415, 59, 64, 3, "الدخان", true], + [4474, 37, 65, 4, "الجاثية", true], + [4511, 35, 66, 4, "الأحقاف", true], + [4546, 38, 95, 4, "محمد", false], + [4584, 29, 111, 4, "الفتح", false], + [4613, 18, 106, 2, "الحجرات", false], + [4631, 45, 34, 3, "ق", true], + [4676, 60, 67, 3, "الذاريات", true], + [4736, 49, 76, 2, "الطور", true], + [4785, 62, 23, 3, "النجم", true], + [4847, 55, 37, 3, "القمر", true], + [4902, 78, 97, 3, "الرحمن", false], + [4980, 96, 46, 3, "الواقعة", true], + [5076, 29, 94, 4, "الحديد", false], + [5105, 22, 105, 3, "المجادلة", false], + [5127, 24, 101, 3, "الحشر", false], + [5151, 13, 91, 2, "الممتحنة", false], + [5164, 14, 109, 2, "الصف", false], + [5178, 11, 110, 2, "الجمعة", false], + [5189, 11, 104, 2, "المنافقون", false], + [5200, 18, 108, 2, "التغابن", false], + [5218, 12, 99, 2, "الطلاق", false], + [5230, 12, 107, 2, "التحريم", false], + [5242, 30, 77, 2, "الملك", true], + [5272, 52, 2, 2, "القلم", true], + [5324, 52, 78, 2, "الحاقة", true], + [5376, 44, 79, 2, "المعارج", true], + [5420, 28, 71, 2, "نوح", true], + [5448, 28, 40, 2, "الجن", true], + [5476, 20, 3, 2, "المزمل", true], + [5496, 56, 4, 2, "المدثر", true], + [5552, 40, 31, 2, "القيامة", true], + [5592, 31, 98, 2, "الانسان", false], + [5623, 50, 33, 2, "المرسلات", true], + [5673, 40, 80, 2, "النبإ", true], + [5713, 46, 81, 2, "النازعات", true], + [5759, 42, 24, 1, "عبس", true], + [5801, 29, 7, 1, "التكوير", true], + [5830, 19, 82, 1, "الإنفطار", true], + [5849, 36, 86, 1, "المطففين", true], + [5885, 25, 83, 1, "الإنشقاق", true], + [5910, 22, 27, 1, "البروج", true], + [5932, 17, 36, 1, "الطارق", true], + [5949, 19, 8, 1, "الأعلى", true], + [5968, 26, 68, 1, "الغاشية", true], + [5994, 30, 10, 1, "الفجر", true], + [6024, 20, 35, 1, "البلد", true], + [6044, 15, 26, 1, "الشمس", true], + [6059, 21, 9, 1, "الليل", true], + [6080, 11, 11, 1, "الضحى", true], + [6091, 8, 12, 1, "الشرح", true], + [6099, 8, 28, 1, "التين", true], + [6107, 19, 1, 1, "العلق", true], + [6126, 5, 25, 1, "القدر", true], + [6131, 8, 100, 1, "البينة", false], + [6139, 8, 93, 1, "الزلزلة", false], + [6147, 11, 14, 1, "العاديات", true], + [6158, 11, 30, 1, "القارعة", true], + [6169, 8, 16, 1, "التكاثر", true], + [6177, 3, 13, 1, "العصر", true], + [6180, 9, 32, 1, "الهمزة", true], + [6189, 5, 19, 1, "الفيل", true], + [6194, 4, 29, 1, "قريش", true], + [6198, 7, 17, 1, "الماعون", true], + [6205, 3, 15, 1, "الكوثر", true], + [6208, 6, 18, 1, "الكافرون", true], + [6214, 3, 114, 1, "النصر", false], + [6217, 5, 6, 1, "المسد", true], + [6222, 4, 22, 1, "الإخلاص", true], + [6226, 5, 20, 1, "الفلق", true], + [6231, 6, 21, 1, "الناس", true], + [6237, 1, 1, 1, "", false] // this value is not used, but is here to be used as a length check ] as const diff --git a/src/types.ts b/src/types.ts index 1c0706b..58e4958 100644 --- a/src/types.ts +++ b/src/types.ts @@ -135,14 +135,13 @@ export type SurahJuzMeta = { export type SajdaType = "recommended" | "obligatory" export type Sajda = [AyahId, SajdaType] // [start, ayas, order, rukus, name, isMeccan, page ] -export type SurahMeta = [ +export type SurahInfo = [ startAyahId: AyahId, ayahCount: AyahNo, surahOrder: Surah, rukuCount: Ruku, name: string, - isMeccan: boolean, - page: Page + isMeccan: boolean ] export type SurahName = [name: string, translitName: string] diff --git a/tests/getSurahMeta.spec.ts b/tests/getSurahInfo.spec.ts similarity index 60% rename from tests/getSurahMeta.spec.ts rename to tests/getSurahInfo.spec.ts index bf0c795..bff17e5 100644 --- a/tests/getSurahMeta.spec.ts +++ b/tests/getSurahInfo.spec.ts @@ -1,26 +1,27 @@ -import { getSurahMeta, SurahList } from "../src" +import { findPage, getSurahInfo, meta, Surah, SurahList } from "../src" -describe("getSurahMeta", () => { +describe("getSurahInfo", () => { it("should return correct metadata for first surah", () => { - const result = getSurahMeta(1) + const result = getSurahInfo(1) expect(result).toEqual(SurahList[1]) }) it("should return correct metadata for last surah", () => { - const result = getSurahMeta(114) + const result = getSurahInfo(114) expect(result).toEqual(SurahList[114]) }) + it("should return correct metadata for a middle surah", () => { - const result = getSurahMeta(57) + const result = getSurahInfo(57) expect(result).toEqual(SurahList[57]) }) it("should throw an error for surah number 0", () => { - expect(() => getSurahMeta(0)).toThrow() + expect(() => getSurahInfo(0)).toThrow() }) it("should throw an error for surah number 115", () => { - expect(() => getSurahMeta(115)).toThrow() + expect(() => getSurahInfo(115)).toThrow() }) }) diff --git a/tests/meta.spec.ts b/tests/meta.spec.ts index 4c99e65..71272d3 100644 --- a/tests/meta.spec.ts +++ b/tests/meta.spec.ts @@ -1,4 +1,4 @@ -import { meta, getList, getSurahMeta, HizbQuarterList, JuzList, ManzilList, PageList, RukuList, SajdaList, SurahList } from "../src" +import { meta, getList, getSurahInfo, HizbQuarterList, JuzList, ManzilList, PageList, RukuList, SajdaList, SurahList } from "../src" import { maxAyahsInSurah } from "../src/const" describe("Meta constants", () => { @@ -60,6 +60,6 @@ describe("Meta constants", () => { it("should have correct maximum number of ayahs in a surah", () => { expect(maxAyahsInSurah).toBe(286) - expect(maxAyahsInSurah).toBe(getSurahMeta(2)[1]) + expect(maxAyahsInSurah).toBe(getSurahInfo(2)[1]) }) }) diff --git a/tests/quran-data.spec.ts b/tests/quran-data.spec.ts index e8a9eda..b04c109 100644 --- a/tests/quran-data.spec.ts +++ b/tests/quran-data.spec.ts @@ -5,7 +5,7 @@ import { findSurahAyahByAyahId, findSurahByAyahId, getPageMeta, - getSurahMeta, + getSurahInfo, isAyahJuzFirst, JuzList, meta @@ -36,8 +36,8 @@ console.log("findJuzMetaBySurah 2,1", findJuzMetaBySurah(2, 1)) console.log("findJuzMetaBySurah 114,1", findJuzMetaBySurah(114, 1)) console.log("findJuzMetaBySurah 114,5", findJuzMetaBySurah(114, 5)) console.log("findPage 604", findPage(114, 1)) -console.log("surahMeta 1", getSurahMeta(1)) -console.log("surahMeta 114", getSurahMeta(114)) +console.log("SurahInfo 1", getSurahInfo(1)) +console.log("SurahInfo 114", getSurahInfo(114)) console.log("pageMeta 604", getPageMeta(604)) // console.log("pmeta", pageMetaOld(604)) console.log("pmeta", getPageMeta(1)) From 01ce7d50aabc8e1d2412288f034e90e084735660 Mon Sep 17 00:00:00 2001 From: HG <husayt@gmail.com> Date: Mon, 10 Mar 2025 12:17:14 +0000 Subject: [PATCH 2/3] feat: add updated SurahMeta --- examples/data-check/checkQuranApi.ts | 13 ++++---- src/ayahStringSplitter.ts | 12 ++++---- src/findManzilByAyahId.ts | 2 +- src/findRukuByAyahId.ts | 4 +-- src/getPageMeta.ts | 4 +-- src/getRukuMeta.ts | 2 +- src/getSurahMeta.ts | 33 ++++++++++++++++++++ src/index.ts | 2 +- src/surahStringParser.ts | 2 +- src/typeGuards.ts | 2 ++ src/types.ts | 30 ++++++++++++------- src/validation.ts | 20 ++++++------- tests/getManzilMeta.spec.ts | 45 ++++++++++++++++++++++++++++ tests/getSurahInfo.spec.ts | 4 +-- tests/getSurahMeta.spec.ts | 35 ++++++++++++++++++++++ tests/meta.spec.ts | 3 +- tests/quran-data.spec.ts | 2 +- 17 files changed, 171 insertions(+), 44 deletions(-) create mode 100644 src/getSurahMeta.ts create mode 100644 tests/getManzilMeta.spec.ts create mode 100644 tests/getSurahMeta.spec.ts diff --git a/examples/data-check/checkQuranApi.ts b/examples/data-check/checkQuranApi.ts index 5674729..4655c49 100644 --- a/examples/data-check/checkQuranApi.ts +++ b/examples/data-check/checkQuranApi.ts @@ -5,7 +5,7 @@ */ -import { findPagebyAyahId, findAyahIdBySurah, findJuz, findRubAlHizb, getAyahMeta, getRubAlHizbMetaByAyahId, HizbQuarterList, Juz, JuzList, ManzilList, meta, PageList, RukuList, SajdaList, Surah, SurahList, SurahInfo, getJuzMeta, getRubAlHizbMeta, getRukuMeta, getPageMeta, getManzilMeta, getSurahInfo } from "../../src" +import { findPagebyAyahId, findAyahIdBySurah, findJuz, findRubAlHizb, getAyahMeta, getRubAlHizbMetaByAyahId, HizbQuarterList, Juz, JuzList, ManzilList, meta, PageList, RukuList, SajdaList, Surah, SurahList, SurahInfo, getJuzMeta, getRubAlHizbMeta, getRukuMeta, getPageMeta, getManzilMeta, getSurahInfo, getSurahMeta } from "../../src" import { AyahNo, AyahId, Manzil, Page, Ruku, RubAlHizbId } from "../../src/types" import quranApi from "./data/quran-api.json" @@ -29,19 +29,18 @@ export function checkQuranApi() { } for (let surahNo: Surah = 1; surahNo <= meta.numSurahs; surahNo++) { - const [ - startAyahId, + const { + firstAyahId, ayahCount, surahOrder, rukuCount, name, - isMeccan, - page - ]: SurahInfo = getSurahInfo(surahNo as Surah) + isMeccan + } = getSurahMeta(surahNo as Surah) const { chapter, name: oName, englishname, arabicname, revelation, verses } = quranApi.chapters[surahNo - 1] if (surahNo !== chapter) console.warn("error QuranApi surah: ", surahNo, chapter) - if (startAyahId !== verses[0].line) console.warn("error QuranApi surah: ", startAyahId, verses[0].line) + if (firstAyahId !== verses[0].line) console.warn("error QuranApi surah: ", firstAyahId, verses[0].line) if (ayahCount !== verses.length) console.warn("error QuranApi surah: ", ayahCount, verses.length) } diff --git a/src/ayahStringSplitter.ts b/src/ayahStringSplitter.ts index e7c82cb..50ecd22 100644 --- a/src/ayahStringSplitter.ts +++ b/src/ayahStringSplitter.ts @@ -7,13 +7,15 @@ import { checkValidAyahId, checkValidSurahAyah } from "./validation" * @param str - The string to parse, expected format: "surah:ayah" or "surah:ayahStart-ayahEnd" * @param isStrict - If true, enforces strict format checking. Defaults to true. If false, allows for additional characters in the string * @returns A tuple containing surah number and either a single ayah number or a range [start, end] - * @throws {Error} If the string format is invalid - * @throws {Error} If surah number is invalid - * @throws {Error} If ayah number(s) are invalid - * @throws {Error} If ayah range is invalid (start > end) + * @throws {@link Error} If the string format is invalid + * @throws {@link Error} If surah number is invalid + * @throws {@link Error} If ayah number(s) are invalid + * @throws {@link sError} If ayah range is invalid (start > end) * @example + * ```ts * ayahStringSplitter("2:255") // returns [2, 255] * ayahStringSplitter("1:1-7") // returns [1, [1, 7]] + * ``` */ export function ayahStringSplitter(str: string, isStrict = true): SurahAyahSegment { const result = isStrict ? string2NumberSplitterStrict(str) : string2NumberSplitter(str) @@ -82,7 +84,7 @@ export function string2NumberSplitter(str: string): { ayah?: number, ayahTo?: nu * - surahOrAyah: The surah number * - ayah: The first or only ayah number * - ayahTo: The ending ayah number (if range specified) - * @throws {Error} When the input string format is invalid or contains non-numeric values + * @throws {@link Error} When the input string format is invalid or contains non-numeric values * * @example * string2NumberSplitterStrict("2:255") // returns { surahOrAyah: 2, ayah: 255, ayahTo: NaN } diff --git a/src/findManzilByAyahId.ts b/src/findManzilByAyahId.ts index 2eb000a..54b4851 100644 --- a/src/findManzilByAyahId.ts +++ b/src/findManzilByAyahId.ts @@ -9,7 +9,7 @@ import { checkValidAyahId } from "./validation" * * @param ayahId - The ID of the Ayah to find the Manzil for * @returns The Manzil number (1-7) containing the specified Ayah - * @throws {Error} If the provided Ayah ID is invalid + * @throws {@link Error} If the provided Ayah ID is invalid * * @example * ```typescript diff --git a/src/findRukuByAyahId.ts b/src/findRukuByAyahId.ts index 2e83a86..854e087 100644 --- a/src/findRukuByAyahId.ts +++ b/src/findRukuByAyahId.ts @@ -8,10 +8,10 @@ import { checkValidAyahId } from "./validation" * * @param ayahId - The unique identifier of an Ayah in format: surah:ayah (e.g., "2:255") * @returns The Ruku number corresponding to the given Ayah ID - * @throws {Error} If the provided Ayah ID is invalid + * @throws {@link Error} If the provided Ayah ID is invalid * * @example - * ```typescript + * ```ts * const ruku = findRukuByAyahId("2:255"); * // Returns the Ruku number containing Ayah 255 of Surah 2 * ``` diff --git a/src/getPageMeta.ts b/src/getPageMeta.ts index 1f0825b..99336c5 100644 --- a/src/getPageMeta.ts +++ b/src/getPageMeta.ts @@ -7,8 +7,8 @@ import { checkValidPage } from "./validation" * Retrieves metadata for a specific page of the Quran. * * @param pageNum - The page number to retrieve metadata for (1-604) - * @returns An object containing the page number, first ayah, and last ayah on the page - * @throws RangeError If the page number is not between 1 and 604 + * @returns {@link PageMeta} An object containing the page number, first ayah, and last ayah on the page + * @throws {@link RangeError} If the page number is not between 1 and 604 */ export function getPageMeta(pageNum: Page): PageMeta { checkValidPage(pageNum) diff --git a/src/getRukuMeta.ts b/src/getRukuMeta.ts index ea3bd22..2f9ee13 100644 --- a/src/getRukuMeta.ts +++ b/src/getRukuMeta.ts @@ -6,7 +6,7 @@ import { checkValidRuku } from "./validation" /** * Retrieves metadata for a specific Ruku (section) of the Quran. * @param rukuNum - The number of the Ruku to retrieve metadata for - * @returns {RukuMeta} An object containing metadata about the Ruku including: + * @returns {@link RukuMeta} An object containing metadata about the Ruku including: * - rukuNum: The Ruku number * - firstAyahId: The global Ayah ID of the first verse in this Ruku * - lastAyahId: The global Ayah ID of the last verse in this Ruku diff --git a/src/getSurahMeta.ts b/src/getSurahMeta.ts new file mode 100644 index 0000000..fdaf7aa --- /dev/null +++ b/src/getSurahMeta.ts @@ -0,0 +1,33 @@ +import { getSurahInfo } from "./getSurahInfo" +import { Surah, SurahMeta } from "./types" + +/** + * Gets the metadata for the specified Surah. + * + * @param surah - The Surah to get the metadata for. + * @returns The metadata for the specified Surah. + */ +export function getSurahMeta(surahNum: Surah): SurahMeta { + const [ + firstAyahId, + ayahCount, + surahOrder, + rukuCount, + name, + isMeccan + ] = getSurahInfo(surahNum) + + const lastAyahId = firstAyahId + ayahCount - 1 + return { + surahNum, + ayahCount, + surahOrder, + rukuCount, + name, + isMeccan, + firstAyahId, + lastAyahId, + first: [surahNum, 1], + last: [surahNum, ayahCount] + } +} diff --git a/src/index.ts b/src/index.ts index ef627b5..7f27602 100644 --- a/src/index.ts +++ b/src/index.ts @@ -34,7 +34,7 @@ export { getRubAlHizb } from "./getRubAlHizb" export { getRubAlHizbMeta } from "./getRubAlHizbMeta" export { getRubAlHizbMetaByAyahId } from "./getRubAlHizbMetaByAyahId" export { getRubAlHizbByAyahId } from "./getRubAlHizbByAyahId" -export { getSurahInfo as getSurahInfo } from "./getSurahInfo" +export { getSurahMeta } from "./getSurahMeta" export { isAyahJuzFirst } from "./isAyahJuzFirst" export { isAyahPageFirst } from "./isAyahPageFirst" export { isSurahAyahJuzFirst } from "./isSurahAyahJuzFirst" diff --git a/src/surahStringParser.ts b/src/surahStringParser.ts index 121080b..2e0fa1e 100644 --- a/src/surahStringParser.ts +++ b/src/surahStringParser.ts @@ -5,7 +5,7 @@ import { Surah } from "./types" * Parses a string representation of a Surah number and converts it to a valid Surah type * @param str - The string containing the Surah number to parse * @returns The parsed Surah number as a Surah type - * @throws {Error} If the string cannot be parsed as a number or if the number is not a valid Surah number + * @throws {@link Error} If the string cannot be parsed as a number or if the number is not a valid Surah number */ export function surahStringParser(str: string, isStrict = false): Surah { const surahX = isStrict ? Number(str.trim()) : Number.parseInt(str.trim(), 10) diff --git a/src/typeGuards.ts b/src/typeGuards.ts index e646dd8..19d9057 100644 --- a/src/typeGuards.ts +++ b/src/typeGuards.ts @@ -112,9 +112,11 @@ export function isValidRuku(x: unknown): x is Ruku { * @returns True if the value is an integer between 1 and the total number of Manzils * * @example + * ```ts * if (isValidManzil(3)) { * // value is a valid Manzil number * } + * ``` */ export function isValidManzil(x: unknown): x is Manzil { return Number.isInteger(x) && 1 <= (x as number) && x as number <= meta.numManzils diff --git a/src/types.ts b/src/types.ts index 58e4958..fa5f3d2 100644 --- a/src/types.ts +++ b/src/types.ts @@ -83,6 +83,17 @@ export type Juz = NumericRange<0, typeof meta.numJuzs> */ export type JuzPart = NumericRange<1, typeof meta.numRubsInJuz> +// [start, ayas, order, rukus, name, isMeccan, page ] +export type SurahInfo = [ + startAyahId: AyahId, + ayahCount: AyahNo, + surahOrder: Surah, + rukuCount: Ruku, + name: string, + isMeccan: boolean +] +export type SurahName = [name: string, translitName: string] + export type RangeMeta = { firstAyahId: AyahId lastAyahId: AyahId @@ -106,6 +117,15 @@ export type SurahAyah = [Surah, AyahNo] export type AyahRange = [AyahId, AyahId] export type SurahAyahSegment = [Surah, AyahNo | [AyahNo, AyahNo]] +export type SurahMeta = { + name: string + surahNum: Surah + ayahCount: AyahNo + surahOrder: Surah + rukuCount: Ruku + isMeccan: boolean +} & RangeMeta + export type PageMeta = { pageNum: Page } & RangeMeta @@ -134,16 +154,6 @@ export type SurahJuzMeta = { } export type SajdaType = "recommended" | "obligatory" export type Sajda = [AyahId, SajdaType] -// [start, ayas, order, rukus, name, isMeccan, page ] -export type SurahInfo = [ - startAyahId: AyahId, - ayahCount: AyahNo, - surahOrder: Surah, - rukuCount: Ruku, - name: string, - isMeccan: boolean -] -export type SurahName = [name: string, translitName: string] export type RangeMode = "juz" | "surah" | "ayah" | "page" | "ruku" | "all" diff --git a/src/validation.ts b/src/validation.ts index 591fcc7..4144178 100644 --- a/src/validation.ts +++ b/src/validation.ts @@ -71,8 +71,8 @@ export function checkValidAyahId(ayahId: unknown | number | AyahId): asserts aya /** * Checks if a value is a valid Page number. * @param x - The value to check - * @throws {TypeError} When the value is not an integer - * @throws {RangeError} When the value is not within valid page range (1 to numPages) + * @throws {@link TypeError} When the value is not an integer + * @throws {@link RangeError} When the value is not within valid page range (1 to numPages) * @remarks This is a type assertion function that ensures a value is a valid Page number */ export function checkValidPage(x: unknown | number | Page): asserts x is Page { @@ -90,8 +90,8 @@ export function checkValidPage(x: unknown | number | Page): asserts x is Page { * Throws RangeError if value is outside valid Juz range. * * @param x - Value to check - * @throws {TypeError} If value is not an integer - * @throws {RangeError} If value is not between 1 and the total number of Juz + * @throws {@link TypeError} If value is not an integer + * @throws {@link RangeError} If value is not between 1 and the total number of Juz */ export function checkValidJuz(x: unknown | number | Juz): asserts x is Juz { if (typeof x !== "number" || !Number.isInteger(x)) { @@ -104,11 +104,11 @@ export function checkValidJuz(x: unknown | number | Juz): asserts x is Juz { /** * Type guard that checks if a value is a valid Ruku number. - * @param x The value to check - * @throws {TypeError} If the value is not an integer number - * @throws {RangeError} If the number is not within valid Ruku range + * @param x - The value to check + * @throws {@link TypeError} If the value is not an integer number + * @throws {@link RangeError} If the number is not within valid Ruku range * @example - * ```typescript + * ```ts * checkValidRuku(5); // OK * checkValidRuku("5"); // Throws TypeError * checkValidRuku(999); // Throws RangeError @@ -126,8 +126,8 @@ export function checkValidRuku(x: unknown | number | Ruku): asserts x is Ruku { /** * Type guard that checks if a value is a valid Manzil number. * @param x - The value to check - * @throws {TypeError} If the value is not an integer - * @throws {RangeError} If the value is not within valid Manzil range (1 to max manzils) + * @throws {@link TypeError} If the value is not an integer + * @throws {@link RangeError} If the value is not within valid Manzil range (1 to max manzils) * @remarks This is an assertion function that ensures the input is a valid Manzil type */ export function checkValidManzil(x: unknown | number | Manzil): asserts x is Manzil { diff --git a/tests/getManzilMeta.spec.ts b/tests/getManzilMeta.spec.ts new file mode 100644 index 0000000..84e6912 --- /dev/null +++ b/tests/getManzilMeta.spec.ts @@ -0,0 +1,45 @@ +import { describe, it, expect } from "vitest" +import { getManzilMeta } from "../src/getManzilMeta" + +describe("getManzilMeta", () => { + it("should return correct metadata for Manzil 1", () => { + const result = getManzilMeta(1) + expect(result).toEqual({ + manzilNum: 1, + firstAyahId: 1, + lastAyahId: 669, + first: [1, 1], + last: [4, 176] + }) + }) + + it("should return correct metadata for Manzil 4", () => { + const result = getManzilMeta(4) + expect(result).toEqual({ + manzilNum: 4, + firstAyahId: 2030, + lastAyahId: 2932, + first: [17, 1], + last: [25, 77] + }) + }) + + it("should return correct metadata for Manzil 8", () => { + const result = getManzilMeta(7) + expect(result).toEqual({ + manzilNum: 7, + firstAyahId: 4631, + lastAyahId: 6236, + first: [50, 1], + last: [114, 6] + }) + }) + + it("should throw error for invalid Manzil number 0", () => { + expect(() => getManzilMeta(0)).toThrow() + }) + + it("should throw error for invalid Manzil number 8", () => { + expect(() => getManzilMeta(8)).toThrow() + }) +}) diff --git a/tests/getSurahInfo.spec.ts b/tests/getSurahInfo.spec.ts index bff17e5..5459745 100644 --- a/tests/getSurahInfo.spec.ts +++ b/tests/getSurahInfo.spec.ts @@ -1,4 +1,5 @@ -import { findPage, getSurahInfo, meta, Surah, SurahList } from "../src" +import { SurahList } from "../src" +import { getSurahInfo } from "../src/getSurahInfo" describe("getSurahInfo", () => { it("should return correct metadata for first surah", () => { @@ -11,7 +12,6 @@ describe("getSurahInfo", () => { expect(result).toEqual(SurahList[114]) }) - it("should return correct metadata for a middle surah", () => { const result = getSurahInfo(57) expect(result).toEqual(SurahList[57]) diff --git a/tests/getSurahMeta.spec.ts b/tests/getSurahMeta.spec.ts new file mode 100644 index 0000000..985d496 --- /dev/null +++ b/tests/getSurahMeta.spec.ts @@ -0,0 +1,35 @@ +import { getSurahMeta } from "../src/getSurahMeta" + +describe("getSurahMeta", () => { + it("returns correct metadata for Surah Al-Fatihah (1)", () => { + const meta = getSurahMeta(1) + expect(meta).toEqual({ + surahNum: 1, + ayahCount: 7, + surahOrder: 5, + rukuCount: 1, + name: "الفاتحة", + isMeccan: true, + firstAyahId: 1, + lastAyahId: 7, + first: [1, 1], + last: [1, 7] + }) + }) + + it("returns correct metadata for Surah Al-Baqarah (2)", () => { + const meta = getSurahMeta(2) + expect(meta).toEqual({ + surahNum: 2, + ayahCount: 286, + surahOrder: 87, + rukuCount: 40, + name: "البقرة", + isMeccan: false, + firstAyahId: 8, + lastAyahId: 293, + first: [2, 1], + last: [2, 286] + }) + }) +}) diff --git a/tests/meta.spec.ts b/tests/meta.spec.ts index 71272d3..1ecf04c 100644 --- a/tests/meta.spec.ts +++ b/tests/meta.spec.ts @@ -1,5 +1,6 @@ -import { meta, getList, getSurahInfo, HizbQuarterList, JuzList, ManzilList, PageList, RukuList, SajdaList, SurahList } from "../src" +import { meta, getList, HizbQuarterList, JuzList, ManzilList, PageList, RukuList, SajdaList, SurahList } from "../src" import { maxAyahsInSurah } from "../src/const" +import { getSurahInfo } from "../src/getSurahInfo" describe("Meta constants", () => { it("should return correct numSurahs", () => { diff --git a/tests/quran-data.spec.ts b/tests/quran-data.spec.ts index b04c109..0e62499 100644 --- a/tests/quran-data.spec.ts +++ b/tests/quran-data.spec.ts @@ -5,11 +5,11 @@ import { findSurahAyahByAyahId, findSurahByAyahId, getPageMeta, - getSurahInfo, isAyahJuzFirst, JuzList, meta } from "../src" +import { getSurahInfo } from "../src/getSurahInfo" import { AyahId, AyahNo, Surah } from "../src/types" console.log("STARING") From d70376448de02a36c7c524b06c083155fccfd56d Mon Sep 17 00:00:00 2001 From: HG <husayt@gmail.com> Date: Mon, 10 Mar 2025 12:17:28 +0000 Subject: [PATCH 3/3] chore(release): v4.0.4-13 --- CHANGELOG.md | 13 +++++++++++++ package.json | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03f22b2..8759a19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,19 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## v4.0.4-13 + +[compare changes](https://git+https@github.com/quran-center/quran-meta/compare/v4.0.4-12...v4.0.4-13) + +### 🚀 Enhancements + +- Rename SurahMeta to SurahInfo (breaking change) (21303f7) +- Add updated SurahMeta (01ce7d5) + +### ❤️ Contributors + +- HG ([@husayt](https://github.com/husayt)) + ## v4.0.4-12 [compare changes](https://git+https@github.com/quran-center/quran-meta/compare/v4.0.4-11...v4.0.4-12) diff --git a/package.json b/package.json index aa5d9bd..ad380ba 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "surah", "juz" ], - "version": "4.0.4-12", + "version": "4.0.4-13", "license": "MIT", "jsdelivr": "./dist/index.mjs", "unpkg": "./dist/index.mjs",