sahih-al-bukhari 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +201 -0
  2. package/bukhari.json +73373 -0
  3. package/index.js +68 -0
  4. package/package.json +34 -0
package/README.md ADDED
@@ -0,0 +1,201 @@
1
+ # Sahih al-Bukhari
2
+
3
+ A complete collection of Sahih al-Bukhari hadiths in JSON format with easy programmatic access for JavaScript/Node.js applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install sahih-al-bukhari
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Basic Import and Access
14
+
15
+ ```javascript
16
+ import bukhari from 'sahih-al-bukhari';
17
+
18
+ // Access hadiths by index (0-based)
19
+ console.log(bukhari[0]); // First hadith
20
+ console.log(bukhari[23]); // 24th hadith
21
+ console.log(bukhari[23][0]); // If you want the first property of the 24th hadith
22
+
23
+ // Get total number of hadiths
24
+ console.log(bukhari.length); // Total hadith count
25
+ ```
26
+
27
+ ### Accessing by Book
28
+
29
+ ```javascript
30
+ // Get all hadiths from a specific book
31
+ const book1 = bukhari.getByBook(1); // Book of Revelation
32
+ const book8 = bukhari.getByBook(8); // Book of Prayer
33
+
34
+ // Access books directly
35
+ const allBooks = bukhari.books;
36
+ const book2Hadiths = bukhari.books[2]; // All hadiths from book 2
37
+ ```
38
+
39
+ ### Accessing by Chapter
40
+
41
+ ```javascript
42
+ // Get hadiths from a specific chapter
43
+ const chapter1 = bukhari.getByChapter(1);
44
+ ```
45
+
46
+ ### Searching Hadiths
47
+
48
+ ```javascript
49
+ // Search in English text and narrator names
50
+ const prayerHadiths = bukhari.search('prayer');
51
+ const anasHadiths = bukhari.search('Anas');
52
+ const fastingHadiths = bukhari.search('fasting');
53
+ ```
54
+
55
+ ### Getting Random Hadith
56
+
57
+ ```javascript
58
+ // Get a random hadith
59
+ const randomHadith = bukhari.getRandom();
60
+ console.log(randomHadith.english.text);
61
+ ```
62
+
63
+ ### Accessing Metadata
64
+
65
+ ```javascript
66
+ // Get collection metadata
67
+ console.log(bukhari.metadata);
68
+ // Output:
69
+ // {
70
+ // "id": 1,
71
+ // "length": 7277,
72
+ // "arabic": {
73
+ // "title": "صحيح البخاري",
74
+ // "author": "الإمام محمد بن إسماعيل البخاري",
75
+ // "introduction": ""
76
+ // },
77
+ // "english": {
78
+ // "title": "Sahih al-Bukhari",
79
+ // "author": "Imam Muhammad ibn Ismail al-Bukhari",
80
+ // "introduction": ""
81
+ // }
82
+ // }
83
+
84
+ // Get chapters information
85
+ console.log(bukhari.chapters);
86
+ ```
87
+
88
+ ## Data Structure
89
+
90
+ Each hadith object has the following structure:
91
+
92
+ ```javascript
93
+ {
94
+ "bookId": 1,
95
+ "chapterId": 1,
96
+ "arabic": "حَدَّثَنَا...",
97
+ "english": {
98
+ "narrator": "Anas",
99
+ "text": "The Prophet (ﷺ) said..."
100
+ }
101
+ }
102
+ ```
103
+
104
+ ## Books Available
105
+
106
+ The collection includes the following books:
107
+
108
+ 1. Revelation (بدء الوحى)
109
+ 2. Belief (الإيمان)
110
+ 3. Knowledge (العلم)
111
+ 4. Ablution (الوضوء)
112
+ 5. Bathing (الغسل)
113
+ 6. Menstrual Periods (الحيض)
114
+ 7. Rubbing hands and feet with dust (التيمم)
115
+ 8. Prayer (الصلاة)
116
+ 9. Times of the Prayers (مواقيت الصلاة)
117
+ 10. Call to Prayers (الأذان)
118
+ ... and many more
119
+
120
+ ## Examples
121
+
122
+ ### Example 1: Find all hadiths about prayer
123
+
124
+ ```javascript
125
+ import bukhari from 'sahih-al-bukhari';
126
+
127
+ const prayerHadiths = bukhari.search('prayer');
128
+ console.log(`Found ${prayerHadiths.length} hadiths about prayer`);
129
+
130
+ prayerHadiths.slice(0, 3).forEach((hadith, index) => {
131
+ console.log(`\n${index + 1}. ${hadith.english.narrator}:`);
132
+ console.log(hadith.english.text);
133
+ });
134
+ ```
135
+
136
+ ### Example 2: Get first 10 hadiths from Book of Belief
137
+
138
+ ```javascript
139
+ import bukhari from 'sahih-al-bukhari';
140
+
141
+ const beliefHadiths = bukhari.getByBook(2);
142
+ const first10 = beliefHadiths.slice(0, 10);
143
+
144
+ first10.forEach((hadith, index) => {
145
+ console.log(`${index + 1}. ${hadith.english.narrator}:`);
146
+ console.log(hadith.english.text.substring(0, 100) + '...');
147
+ });
148
+ ```
149
+
150
+ ### Example 3: Random hadith of the day
151
+
152
+ ```javascript
153
+ import bukhari from 'sahih-al-bukhari';
154
+
155
+ function hadithOfTheDay() {
156
+ const hadith = bukhari.getRandom();
157
+ return {
158
+ narrator: hadith.english.narrator,
159
+ text: hadith.english.text,
160
+ book: hadith.bookId
161
+ };
162
+ }
163
+
164
+ console.log('Hadith of the Day:');
165
+ console.log(hadithOfTheDay());
166
+ ```
167
+
168
+ ## API Reference
169
+
170
+ ### Properties
171
+
172
+ - `length` - Total number of hadiths
173
+ - `books` - Object with hadiths grouped by book ID
174
+ - `metadata` - Collection metadata
175
+ - `chapters` - Array of chapter information
176
+
177
+ ### Methods
178
+
179
+ - `getByBook(bookId)` - Returns array of hadiths from specified book
180
+ - `getByChapter(chapterId)` - Returns array of hadiths from specified chapter
181
+ - `search(query)` - Returns array of hadiths matching the search query
182
+ - `getRandom()` - Returns a random hadith
183
+
184
+ ### Array Access
185
+
186
+ - `bukhari[index]` - Access hadith by numerical index (0-based)
187
+ - `bukhari[index][property]` - Access specific property of a hadith
188
+
189
+ ## License
190
+
191
+ MIT License
192
+
193
+ ## Contributing
194
+
195
+ Contributions are welcome! Please feel free to submit a Pull Request.
196
+
197
+ ## Acknowledgments
198
+
199
+ - Original data from Sahih al-Bukhari collection
200
+ - Translations by reputable Islamic scholars
201
+ - Formatted for programmatic access