Skip to content

Commit dec4ac4

Browse files
committed
feat: exposed findJuzAndShift, findJuzAndShiftByAyahId, getJuzMeta, getRubAlHizb, getRubAlHizbByAyahId
1 parent 5d72db3 commit dec4ac4

File tree

6 files changed

+26
-18
lines changed

6 files changed

+26
-18
lines changed

src/findRangeAroundAyah.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { JuzList } from "./lists/juzList"
77
import { PageList } from "./lists/pageList"
88
import { RukuList } from "./lists/rukuList"
99
import { SurahList } from "./lists/surahList"
10-
import { AyahId, AyahRange, Juz, Page, Ruku, Surah } from "./types"
10+
import { AyahId, AyahRange, Juz, Page, RangeMode, Ruku, Surah } from "./types"
1111

1212
/**
1313
* Finds the range of ayahs surrounding a given ayah based on specified mode
@@ -23,7 +23,7 @@ import { AyahId, AyahRange, Juz, Page, Ruku, Surah } from "./types"
2323
*/
2424
export function findRangeAroundAyah(
2525
ayahId: AyahId,
26-
mode: "juz" | "surah" | "ayah" | "page" | "ruku" | "all"
26+
mode: RangeMode
2727
): AyahRange {
2828
switch (mode) {
2929
case "juz": {

src/findRangeAroundSurahAyah.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { findAyahIdBySurah } from "./findAyahIdBySurah"
22
import { findRangeAroundAyah } from "./findRangeAroundAyah"
33
import { SurahList } from "./lists/surahList"
4-
import { AyahId, AyahNo, AyahRange, Surah } from "./types"
4+
import { AyahId, AyahNo, AyahRange, RangeMode, Surah } from "./types"
55
import { checkValidSurah } from "./validation"
66

77
/**
@@ -15,7 +15,7 @@ import { checkValidSurah } from "./validation"
1515
export function findRangeAroundSurahAyah(
1616
surah: Surah,
1717
ayah: AyahNo,
18-
mode: "juz" | "surah" | "ayah" | "page" | "all"
18+
mode: RangeMode
1919
): AyahRange {
2020
checkValidSurah(surah)
2121
if (mode === "surah") {

src/getAyahMeta.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { findPagebyAyahId } from "./findPagebyAyahId"
22
import { findSurahAyahByAyahId } from "./findSurahAyahByAyahId"
3-
import { getRubAlHizbMetaByAyahId } from "./getRubAlHizbMetaByAyahId"
3+
import { getRubAlHizbByAyahId } from "./getRubAlHizbByAyahId"
44
import { HizbQuarterList } from "./lists/hizbQuarterList"
55
import { JuzList } from "./lists/juzList"
66
import { PageList } from "./lists/pageList"
@@ -21,7 +21,7 @@ import { checkValidAyahId } from "./validation"
2121
export function getAyahMeta(ayahId: AyahId): AyahMeta {
2222
checkValidAyahId(ayahId)
2323

24-
const quarterData = getRubAlHizbMetaByAyahId(ayahId)
24+
const quarterData = getRubAlHizbByAyahId(ayahId)
2525
const [surah, ayah] = findSurahAyahByAyahId(ayahId)
2626
const page: Page = findPagebyAyahId(ayahId)
2727

src/getJuzMeta.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { findSurahAyahByAyahId } from "./findSurahAyahByAyahId"
22
import { JuzList } from "./lists/juzList"
3-
import { AyahId, JuzMeta } from "./types"
3+
import { AyahId, Juz, JuzMeta } from "./types"
44
import { checkValidJuz } from "./validation"
55

66
/**
@@ -10,7 +10,7 @@ import { checkValidJuz } from "./validation"
1010
* @returns An object containing the Juz number, first ayah, and last ayah in the Juz
1111
* @throws RangeError If the Juz number is not between 1 and 30
1212
*/
13-
export function getJuzMeta(juzNum: number): JuzMeta {
13+
export function getJuzMeta(juzNum: Juz): JuzMeta {
1414
checkValidJuz(juzNum)
1515

1616
const [firstAyahId, nextJuzAyahId]: [AyahId, AyahId] = [

src/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// Quran Meta
22

33
export type { QuranMeta } from "./const"
4-
export type { AyahCountBetweenJuzSurah, AyahId, AyahMeta, AyahNo, AyahRange, HizbId, Juz, JuzHizb, SurahJuzMeta, JuzPart, Manzil, Page, PageMeta, RubAlHizbId, Ruku, Sajda, SajdaType, Surah, SurahAyah, SurahAyahSegment, SurahMeta, SurahName } from "./types"
4+
export type { 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"
55

66
export { ayahStringSplitter, string2NumberSplitter, string2NumberSplitterStrict } from "./ayahStringSplitter"
77
export { surahStringParser } from "./surahStringParser"
88
export { meta } from "./const"
99
export { findAyahIdBySurah } from "./findAyahIdBySurah"
1010
export { findJuz } from "./findJuz"
11-
export { findJuzAndShift } from "./findJuzAndShift"
11+
export { findJuzAndShift, findJuzAndShiftByAyahId } from "./findJuzAndShift"
1212
export { findJuzByAyahId } from "./findJuzByAyahId"
1313
export { findJuzMetaBySurah } from "./findJuzMetaBySurah"
1414
export { findPage } from "./findPage"
@@ -23,11 +23,14 @@ export { findSurahByAyahId } from "./findSurahByAyahId"
2323
export { getAyahCountInSurah } from "./getAyahCountInSurah"
2424
export { getAyahMeta } from "./getAyahMeta"
2525
export { getAyahMetasForSurah } from "./getAyahMetasForSurah"
26+
export { getJuzMeta } from "./getJuzMeta"
2627
export { getList } from "./getList"
2728
export { getPageMeta } from "./getPageMeta"
2829
export { getRukuMeta } from "./getRukuMeta"
30+
export { getRubAlHizb } from "./getRubAlHizb"
2931
export { getRubAlHizbMeta } from "./getRubAlHizbMeta"
3032
export { getRubAlHizbMetaByAyahId } from "./getRubAlHizbMetaByAyahId"
33+
export { getRubAlHizbByAyahId } from "./getRubAlHizbByAyahId"
3134
export { getSurahMeta } from "./getSurahMeta"
3235
export { isAyahJuzFirst } from "./isAyahJuzFirst"
3336
export { isAyahPageFirst } from "./isAyahPageFirst"

src/types.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,26 +83,29 @@ export type Juz = NumericRange<0, typeof meta.numJuzs>
8383
*/
8484
export type JuzPart = NumericRange<1, typeof meta.numRubsInJuz>
8585

86+
export type RangeMeta = {
87+
firstAyahId: AyahId
88+
lastAyahId: AyahId
89+
first: SurahAyah
90+
last: SurahAyah
91+
}
92+
8693
/**
8794
* Represents the structure of a Juz and Hizb combination in the Quran
8895
*/
89-
export type JuzHizb = {
96+
export type RubAlHizb = {
9097
juz: Juz
9198
juzPart: JuzPart
9299
hizbId: HizbId
93100
rubAlHizbId: RubAlHizbId
94101
}
102+
103+
export type RubAlHizbMeta = RubAlHizb & RangeMeta
104+
95105
export type SurahAyah = [Surah, AyahNo]
96106
export type AyahRange = [AyahId, AyahId]
97107
export type SurahAyahSegment = [Surah, AyahNo | [AyahNo, AyahNo]]
98108

99-
export type RangeMeta = {
100-
firstAyahId: AyahId
101-
lastAyahId: AyahId
102-
first: SurahAyah
103-
last: SurahAyah
104-
}
105-
106109
export type PageMeta = {
107110
pageNum: Page
108111
} & RangeMeta
@@ -139,6 +142,8 @@ export type SurahMeta = [
139142
]
140143
export type SurahName = [name: string, translitName: string]
141144

145+
export type RangeMode = "juz" | "surah" | "ayah" | "page" | "ruku" | "all"
146+
142147
export type AyahMeta = {
143148
juz: Juz
144149
juzPart: JuzPart // 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8

0 commit comments

Comments
 (0)