@quranjs/api 1.5.0 → 1.6.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.
- package/README.md +4 -4
- package/dist/api.cjs.development.js +56 -25
- package/dist/api.cjs.development.js.map +1 -1
- package/dist/api.cjs.production.min.js +1 -1
- package/dist/api.cjs.production.min.js.map +1 -1
- package/dist/api.esm.js +56 -25
- package/dist/api.esm.js.map +1 -1
- package/dist/sdk/index.d.ts +12 -0
- package/dist/sdk/utils.d.ts +1 -1
- package/dist/sdk/v4/index.d.ts +12 -0
- package/dist/sdk/v4/verses.d.ts +13 -1
- package/package.json +2 -1
- package/src/sdk/utils.ts +2 -2
- package/src/sdk/v4/verses.ts +9 -10
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-

|
|
2
2
|
A library for fetching quran data from the [quran.com API][qdc-api]. This library also works on both Node.js and the browser.
|
|
3
3
|
|
|
4
4
|
[Checkout Docs][docs]
|
|
@@ -31,10 +31,10 @@ you can visit the [docs][docs] for more details.
|
|
|
31
31
|
|
|
32
32
|
[qdc-api]: https://quran.api-docs.io/
|
|
33
33
|
[docs]: https://quranjs.vercel.app/
|
|
34
|
-
[build-badge]: https://github.com/
|
|
35
|
-
[build]: https://github.com/
|
|
34
|
+
[build-badge]: https://github.com/quran/api-js/workflows/CI/badge.svg
|
|
35
|
+
[build]: https://github.com/quran/api-js/actions?query=workflow%3ACI
|
|
36
36
|
[license-badge]: https://badgen.net/github/license/quranjs/api
|
|
37
|
-
[license]: https://github.com/
|
|
37
|
+
[license]: https://github.com/quran/api-js/blob/master/LICENSE
|
|
38
38
|
[npm]: https://www.npmjs.com/package/@quranjs/api
|
|
39
39
|
[npm-badge]: https://badgen.net/npm/v/@quranjs/api
|
|
40
40
|
[downloads-badge]: https://img.shields.io/npm/dm/@quranjs/api.svg
|
|
@@ -1071,7 +1071,7 @@ var fetcher = /*#__PURE__*/function () {
|
|
|
1071
1071
|
}();
|
|
1072
1072
|
|
|
1073
1073
|
// this maps chapterNumber to verseCount
|
|
1074
|
-
var
|
|
1074
|
+
var versesMapping = {
|
|
1075
1075
|
'1': 7,
|
|
1076
1076
|
'2': 286,
|
|
1077
1077
|
'3': 200,
|
|
@@ -1290,7 +1290,7 @@ var isValidVerseKey = function isValidVerseKey(key) {
|
|
|
1290
1290
|
|
|
1291
1291
|
if (!chapterId || !verseId || !isValidChapterId(chapterId)) return false;
|
|
1292
1292
|
var parsedVerse = Number(verseId);
|
|
1293
|
-
var verseCount =
|
|
1293
|
+
var verseCount = versesMapping[chapterId];
|
|
1294
1294
|
if (!parsedVerse || parsedVerse <= 0 || parsedVerse > verseCount) return false;
|
|
1295
1295
|
return true;
|
|
1296
1296
|
};
|
|
@@ -1716,8 +1716,7 @@ var findByJuz = /*#__PURE__*/function () {
|
|
|
1716
1716
|
return function findByJuz(_x7, _x8) {
|
|
1717
1717
|
return _ref4.apply(this, arguments);
|
|
1718
1718
|
};
|
|
1719
|
-
}();
|
|
1720
|
-
|
|
1719
|
+
}();
|
|
1721
1720
|
/**
|
|
1722
1721
|
* Get all ayahs for a Hizb.
|
|
1723
1722
|
* @description https://quran.api-docs.io/v4/verses/by-hizb-number
|
|
@@ -1727,14 +1726,46 @@ var findByJuz = /*#__PURE__*/function () {
|
|
|
1727
1726
|
* quran.v4.verses.findByHizb('1')
|
|
1728
1727
|
* quran.v4.verses.findByHizb('29')
|
|
1729
1728
|
*/
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1729
|
+
|
|
1730
|
+
|
|
1731
|
+
var findByHizb = /*#__PURE__*/function () {
|
|
1732
|
+
var _ref5 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(hizb, options) {
|
|
1733
|
+
var params, url, _yield$fetcher5, verses;
|
|
1734
|
+
|
|
1735
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
1736
|
+
while (1) {
|
|
1737
|
+
switch (_context5.prev = _context5.next) {
|
|
1738
|
+
case 0:
|
|
1739
|
+
if (Utils.isValidHizb(hizb)) {
|
|
1740
|
+
_context5.next = 2;
|
|
1741
|
+
break;
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
throw new Error('Invalid hizb');
|
|
1745
|
+
|
|
1746
|
+
case 2:
|
|
1747
|
+
params = getVerseOptions(options);
|
|
1748
|
+
url = "/verses/by_hizb/" + hizb;
|
|
1749
|
+
_context5.next = 6;
|
|
1750
|
+
return fetcher(url, params);
|
|
1751
|
+
|
|
1752
|
+
case 6:
|
|
1753
|
+
_yield$fetcher5 = _context5.sent;
|
|
1754
|
+
verses = _yield$fetcher5.verses;
|
|
1755
|
+
return _context5.abrupt("return", verses);
|
|
1756
|
+
|
|
1757
|
+
case 9:
|
|
1758
|
+
case "end":
|
|
1759
|
+
return _context5.stop();
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
}, _callee5);
|
|
1763
|
+
}));
|
|
1764
|
+
|
|
1765
|
+
return function findByHizb(_x9, _x10) {
|
|
1766
|
+
return _ref5.apply(this, arguments);
|
|
1767
|
+
};
|
|
1768
|
+
}(); // TODO: uncomment when API is fixed
|
|
1738
1769
|
|
|
1739
1770
|
/**
|
|
1740
1771
|
* Get all ayahs for a Rub.
|
|
@@ -1763,32 +1794,32 @@ var findByJuz = /*#__PURE__*/function () {
|
|
|
1763
1794
|
|
|
1764
1795
|
|
|
1765
1796
|
var findRandom = /*#__PURE__*/function () {
|
|
1766
|
-
var
|
|
1767
|
-
var params, _yield$
|
|
1797
|
+
var _ref6 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(options) {
|
|
1798
|
+
var params, _yield$fetcher6, verse;
|
|
1768
1799
|
|
|
1769
|
-
return _regeneratorRuntime.wrap(function
|
|
1800
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
1770
1801
|
while (1) {
|
|
1771
|
-
switch (
|
|
1802
|
+
switch (_context6.prev = _context6.next) {
|
|
1772
1803
|
case 0:
|
|
1773
1804
|
params = getVerseOptions(options);
|
|
1774
|
-
|
|
1805
|
+
_context6.next = 3;
|
|
1775
1806
|
return fetcher('/verses/random', params);
|
|
1776
1807
|
|
|
1777
1808
|
case 3:
|
|
1778
|
-
_yield$
|
|
1779
|
-
verse = _yield$
|
|
1780
|
-
return
|
|
1809
|
+
_yield$fetcher6 = _context6.sent;
|
|
1810
|
+
verse = _yield$fetcher6.verse;
|
|
1811
|
+
return _context6.abrupt("return", verse);
|
|
1781
1812
|
|
|
1782
1813
|
case 6:
|
|
1783
1814
|
case "end":
|
|
1784
|
-
return
|
|
1815
|
+
return _context6.stop();
|
|
1785
1816
|
}
|
|
1786
1817
|
}
|
|
1787
|
-
},
|
|
1818
|
+
}, _callee6);
|
|
1788
1819
|
}));
|
|
1789
1820
|
|
|
1790
|
-
return function findRandom(
|
|
1791
|
-
return
|
|
1821
|
+
return function findRandom(_x11) {
|
|
1822
|
+
return _ref6.apply(this, arguments);
|
|
1792
1823
|
};
|
|
1793
1824
|
}();
|
|
1794
1825
|
|
|
@@ -1797,7 +1828,7 @@ var verses = {
|
|
|
1797
1828
|
findByChapter: findByChapter,
|
|
1798
1829
|
findByPage: findByPage,
|
|
1799
1830
|
findByJuz: findByJuz,
|
|
1800
|
-
|
|
1831
|
+
findByHizb: findByHizb,
|
|
1801
1832
|
// findByRub,
|
|
1802
1833
|
findRandom: findRandom
|
|
1803
1834
|
};
|