@quranjs/api 1.6.0 → 1.7.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 (63) hide show
  1. package/dist/index.d.ts +553 -2
  2. package/dist/index.js +11 -6
  3. package/dist/index.js.map +1 -0
  4. package/dist/index.mjs +6 -0
  5. package/dist/index.mjs.map +1 -0
  6. package/package.json +24 -21
  7. package/src/sdk/utils.ts +18 -9
  8. package/src/sdk/v4/_fetcher.ts +58 -7
  9. package/src/sdk/v4/audio.ts +30 -50
  10. package/src/sdk/v4/chapters.ts +12 -15
  11. package/src/sdk/v4/juzs.ts +7 -2
  12. package/src/sdk/v4/resources.ts +27 -31
  13. package/src/sdk/v4/search.ts +14 -13
  14. package/src/sdk/v4/verses.ts +72 -50
  15. package/src/types/BaseApiOptions.ts +6 -0
  16. package/src/types/FetchFn.ts +1 -0
  17. package/src/types/index.ts +2 -0
  18. package/dist/api.cjs.development.js +0 -2754
  19. package/dist/api.cjs.development.js.map +0 -1
  20. package/dist/api.cjs.production.min.js +0 -2
  21. package/dist/api.cjs.production.min.js.map +0 -1
  22. package/dist/api.esm.js +0 -2746
  23. package/dist/api.esm.js.map +0 -1
  24. package/dist/sdk/index.d.ts +0 -195
  25. package/dist/sdk/utils.d.ts +0 -125
  26. package/dist/sdk/v4/_fetcher.d.ts +0 -3
  27. package/dist/sdk/v4/audio.d.ts +0 -52
  28. package/dist/sdk/v4/chapters.d.ts +0 -13
  29. package/dist/sdk/v4/index.d.ts +0 -185
  30. package/dist/sdk/v4/juzs.d.ts +0 -5
  31. package/dist/sdk/v4/resources.d.ts +0 -26
  32. package/dist/sdk/v4/search.d.ts +0 -22
  33. package/dist/sdk/v4/verses.d.ts +0 -76
  34. package/dist/types/ChapterId.d.ts +0 -4
  35. package/dist/types/HizbNumber.d.ts +0 -4
  36. package/dist/types/JuzNumber.d.ts +0 -4
  37. package/dist/types/PageNumber.d.ts +0 -4
  38. package/dist/types/RubNumber.d.ts +0 -4
  39. package/dist/types/VerseKey.d.ts +0 -2
  40. package/dist/types/api/ApiResponses.d.ts +0 -18
  41. package/dist/types/api/AudioData.d.ts +0 -17
  42. package/dist/types/api/AudioResponse.d.ts +0 -8
  43. package/dist/types/api/Chapter.d.ts +0 -14
  44. package/dist/types/api/ChapterInfo.d.ts +0 -8
  45. package/dist/types/api/Footnote.d.ts +0 -6
  46. package/dist/types/api/Juz.d.ts +0 -8
  47. package/dist/types/api/Pagination.d.ts +0 -7
  48. package/dist/types/api/Reciter.d.ts +0 -21
  49. package/dist/types/api/Resources.d.ts +0 -70
  50. package/dist/types/api/Segment.d.ts +0 -4
  51. package/dist/types/api/Tafsir.d.ts +0 -7
  52. package/dist/types/api/TafsirInfo.d.ts +0 -9
  53. package/dist/types/api/TranslatedName.d.ts +0 -4
  54. package/dist/types/api/Translation.d.ts +0 -17
  55. package/dist/types/api/Transliteration.d.ts +0 -4
  56. package/dist/types/api/Verse.d.ts +0 -32
  57. package/dist/types/api/Word.d.ts +0 -28
  58. package/dist/types/api/index.d.ts +0 -18
  59. package/dist/types/index.d.ts +0 -88
  60. package/dist/types/utils.d.ts +0 -5
  61. package/dist/utils/misc.d.ts +0 -1
  62. package/dist/utils/qs-stringify.d.ts +0 -21
  63. package/src/utils/qs-stringify.ts +0 -81
@@ -1,2754 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var fetch = require('cross-fetch');
6
- var humps = require('humps');
7
-
8
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
-
10
- var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch);
11
-
12
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
13
- try {
14
- var info = gen[key](arg);
15
- var value = info.value;
16
- } catch (error) {
17
- reject(error);
18
- return;
19
- }
20
-
21
- if (info.done) {
22
- resolve(value);
23
- } else {
24
- Promise.resolve(value).then(_next, _throw);
25
- }
26
- }
27
-
28
- function _asyncToGenerator(fn) {
29
- return function () {
30
- var self = this,
31
- args = arguments;
32
- return new Promise(function (resolve, reject) {
33
- var gen = fn.apply(self, args);
34
-
35
- function _next(value) {
36
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
37
- }
38
-
39
- function _throw(err) {
40
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
41
- }
42
-
43
- _next(undefined);
44
- });
45
- };
46
- }
47
-
48
- function _extends() {
49
- _extends = Object.assign || function (target) {
50
- for (var i = 1; i < arguments.length; i++) {
51
- var source = arguments[i];
52
-
53
- for (var key in source) {
54
- if (Object.prototype.hasOwnProperty.call(source, key)) {
55
- target[key] = source[key];
56
- }
57
- }
58
- }
59
-
60
- return target;
61
- };
62
-
63
- return _extends.apply(this, arguments);
64
- }
65
-
66
- var runtime = {exports: {}};
67
-
68
- /**
69
- * Copyright (c) 2014-present, Facebook, Inc.
70
- *
71
- * This source code is licensed under the MIT license found in the
72
- * LICENSE file in the root directory of this source tree.
73
- */
74
-
75
- (function (module) {
76
- var runtime = (function (exports) {
77
-
78
- var Op = Object.prototype;
79
- var hasOwn = Op.hasOwnProperty;
80
- var undefined$1; // More compressible than void 0.
81
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
82
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
83
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
84
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
85
-
86
- function define(obj, key, value) {
87
- Object.defineProperty(obj, key, {
88
- value: value,
89
- enumerable: true,
90
- configurable: true,
91
- writable: true
92
- });
93
- return obj[key];
94
- }
95
- try {
96
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
97
- define({}, "");
98
- } catch (err) {
99
- define = function(obj, key, value) {
100
- return obj[key] = value;
101
- };
102
- }
103
-
104
- function wrap(innerFn, outerFn, self, tryLocsList) {
105
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
106
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
107
- var generator = Object.create(protoGenerator.prototype);
108
- var context = new Context(tryLocsList || []);
109
-
110
- // The ._invoke method unifies the implementations of the .next,
111
- // .throw, and .return methods.
112
- generator._invoke = makeInvokeMethod(innerFn, self, context);
113
-
114
- return generator;
115
- }
116
- exports.wrap = wrap;
117
-
118
- // Try/catch helper to minimize deoptimizations. Returns a completion
119
- // record like context.tryEntries[i].completion. This interface could
120
- // have been (and was previously) designed to take a closure to be
121
- // invoked without arguments, but in all the cases we care about we
122
- // already have an existing method we want to call, so there's no need
123
- // to create a new function object. We can even get away with assuming
124
- // the method takes exactly one argument, since that happens to be true
125
- // in every case, so we don't have to touch the arguments object. The
126
- // only additional allocation required is the completion record, which
127
- // has a stable shape and so hopefully should be cheap to allocate.
128
- function tryCatch(fn, obj, arg) {
129
- try {
130
- return { type: "normal", arg: fn.call(obj, arg) };
131
- } catch (err) {
132
- return { type: "throw", arg: err };
133
- }
134
- }
135
-
136
- var GenStateSuspendedStart = "suspendedStart";
137
- var GenStateSuspendedYield = "suspendedYield";
138
- var GenStateExecuting = "executing";
139
- var GenStateCompleted = "completed";
140
-
141
- // Returning this object from the innerFn has the same effect as
142
- // breaking out of the dispatch switch statement.
143
- var ContinueSentinel = {};
144
-
145
- // Dummy constructor functions that we use as the .constructor and
146
- // .constructor.prototype properties for functions that return Generator
147
- // objects. For full spec compliance, you may wish to configure your
148
- // minifier not to mangle the names of these two functions.
149
- function Generator() {}
150
- function GeneratorFunction() {}
151
- function GeneratorFunctionPrototype() {}
152
-
153
- // This is a polyfill for %IteratorPrototype% for environments that
154
- // don't natively support it.
155
- var IteratorPrototype = {};
156
- define(IteratorPrototype, iteratorSymbol, function () {
157
- return this;
158
- });
159
-
160
- var getProto = Object.getPrototypeOf;
161
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
162
- if (NativeIteratorPrototype &&
163
- NativeIteratorPrototype !== Op &&
164
- hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
165
- // This environment has a native %IteratorPrototype%; use it instead
166
- // of the polyfill.
167
- IteratorPrototype = NativeIteratorPrototype;
168
- }
169
-
170
- var Gp = GeneratorFunctionPrototype.prototype =
171
- Generator.prototype = Object.create(IteratorPrototype);
172
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
173
- define(Gp, "constructor", GeneratorFunctionPrototype);
174
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
175
- GeneratorFunction.displayName = define(
176
- GeneratorFunctionPrototype,
177
- toStringTagSymbol,
178
- "GeneratorFunction"
179
- );
180
-
181
- // Helper for defining the .next, .throw, and .return methods of the
182
- // Iterator interface in terms of a single ._invoke method.
183
- function defineIteratorMethods(prototype) {
184
- ["next", "throw", "return"].forEach(function(method) {
185
- define(prototype, method, function(arg) {
186
- return this._invoke(method, arg);
187
- });
188
- });
189
- }
190
-
191
- exports.isGeneratorFunction = function(genFun) {
192
- var ctor = typeof genFun === "function" && genFun.constructor;
193
- return ctor
194
- ? ctor === GeneratorFunction ||
195
- // For the native GeneratorFunction constructor, the best we can
196
- // do is to check its .name property.
197
- (ctor.displayName || ctor.name) === "GeneratorFunction"
198
- : false;
199
- };
200
-
201
- exports.mark = function(genFun) {
202
- if (Object.setPrototypeOf) {
203
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
204
- } else {
205
- genFun.__proto__ = GeneratorFunctionPrototype;
206
- define(genFun, toStringTagSymbol, "GeneratorFunction");
207
- }
208
- genFun.prototype = Object.create(Gp);
209
- return genFun;
210
- };
211
-
212
- // Within the body of any async function, `await x` is transformed to
213
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
214
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
215
- // meant to be awaited.
216
- exports.awrap = function(arg) {
217
- return { __await: arg };
218
- };
219
-
220
- function AsyncIterator(generator, PromiseImpl) {
221
- function invoke(method, arg, resolve, reject) {
222
- var record = tryCatch(generator[method], generator, arg);
223
- if (record.type === "throw") {
224
- reject(record.arg);
225
- } else {
226
- var result = record.arg;
227
- var value = result.value;
228
- if (value &&
229
- typeof value === "object" &&
230
- hasOwn.call(value, "__await")) {
231
- return PromiseImpl.resolve(value.__await).then(function(value) {
232
- invoke("next", value, resolve, reject);
233
- }, function(err) {
234
- invoke("throw", err, resolve, reject);
235
- });
236
- }
237
-
238
- return PromiseImpl.resolve(value).then(function(unwrapped) {
239
- // When a yielded Promise is resolved, its final value becomes
240
- // the .value of the Promise<{value,done}> result for the
241
- // current iteration.
242
- result.value = unwrapped;
243
- resolve(result);
244
- }, function(error) {
245
- // If a rejected Promise was yielded, throw the rejection back
246
- // into the async generator function so it can be handled there.
247
- return invoke("throw", error, resolve, reject);
248
- });
249
- }
250
- }
251
-
252
- var previousPromise;
253
-
254
- function enqueue(method, arg) {
255
- function callInvokeWithMethodAndArg() {
256
- return new PromiseImpl(function(resolve, reject) {
257
- invoke(method, arg, resolve, reject);
258
- });
259
- }
260
-
261
- return previousPromise =
262
- // If enqueue has been called before, then we want to wait until
263
- // all previous Promises have been resolved before calling invoke,
264
- // so that results are always delivered in the correct order. If
265
- // enqueue has not been called before, then it is important to
266
- // call invoke immediately, without waiting on a callback to fire,
267
- // so that the async generator function has the opportunity to do
268
- // any necessary setup in a predictable way. This predictability
269
- // is why the Promise constructor synchronously invokes its
270
- // executor callback, and why async functions synchronously
271
- // execute code before the first await. Since we implement simple
272
- // async functions in terms of async generators, it is especially
273
- // important to get this right, even though it requires care.
274
- previousPromise ? previousPromise.then(
275
- callInvokeWithMethodAndArg,
276
- // Avoid propagating failures to Promises returned by later
277
- // invocations of the iterator.
278
- callInvokeWithMethodAndArg
279
- ) : callInvokeWithMethodAndArg();
280
- }
281
-
282
- // Define the unified helper method that is used to implement .next,
283
- // .throw, and .return (see defineIteratorMethods).
284
- this._invoke = enqueue;
285
- }
286
-
287
- defineIteratorMethods(AsyncIterator.prototype);
288
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
289
- return this;
290
- });
291
- exports.AsyncIterator = AsyncIterator;
292
-
293
- // Note that simple async functions are implemented on top of
294
- // AsyncIterator objects; they just return a Promise for the value of
295
- // the final result produced by the iterator.
296
- exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
297
- if (PromiseImpl === void 0) PromiseImpl = Promise;
298
-
299
- var iter = new AsyncIterator(
300
- wrap(innerFn, outerFn, self, tryLocsList),
301
- PromiseImpl
302
- );
303
-
304
- return exports.isGeneratorFunction(outerFn)
305
- ? iter // If outerFn is a generator, return the full iterator.
306
- : iter.next().then(function(result) {
307
- return result.done ? result.value : iter.next();
308
- });
309
- };
310
-
311
- function makeInvokeMethod(innerFn, self, context) {
312
- var state = GenStateSuspendedStart;
313
-
314
- return function invoke(method, arg) {
315
- if (state === GenStateExecuting) {
316
- throw new Error("Generator is already running");
317
- }
318
-
319
- if (state === GenStateCompleted) {
320
- if (method === "throw") {
321
- throw arg;
322
- }
323
-
324
- // Be forgiving, per 25.3.3.3.3 of the spec:
325
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
326
- return doneResult();
327
- }
328
-
329
- context.method = method;
330
- context.arg = arg;
331
-
332
- while (true) {
333
- var delegate = context.delegate;
334
- if (delegate) {
335
- var delegateResult = maybeInvokeDelegate(delegate, context);
336
- if (delegateResult) {
337
- if (delegateResult === ContinueSentinel) continue;
338
- return delegateResult;
339
- }
340
- }
341
-
342
- if (context.method === "next") {
343
- // Setting context._sent for legacy support of Babel's
344
- // function.sent implementation.
345
- context.sent = context._sent = context.arg;
346
-
347
- } else if (context.method === "throw") {
348
- if (state === GenStateSuspendedStart) {
349
- state = GenStateCompleted;
350
- throw context.arg;
351
- }
352
-
353
- context.dispatchException(context.arg);
354
-
355
- } else if (context.method === "return") {
356
- context.abrupt("return", context.arg);
357
- }
358
-
359
- state = GenStateExecuting;
360
-
361
- var record = tryCatch(innerFn, self, context);
362
- if (record.type === "normal") {
363
- // If an exception is thrown from innerFn, we leave state ===
364
- // GenStateExecuting and loop back for another invocation.
365
- state = context.done
366
- ? GenStateCompleted
367
- : GenStateSuspendedYield;
368
-
369
- if (record.arg === ContinueSentinel) {
370
- continue;
371
- }
372
-
373
- return {
374
- value: record.arg,
375
- done: context.done
376
- };
377
-
378
- } else if (record.type === "throw") {
379
- state = GenStateCompleted;
380
- // Dispatch the exception by looping back around to the
381
- // context.dispatchException(context.arg) call above.
382
- context.method = "throw";
383
- context.arg = record.arg;
384
- }
385
- }
386
- };
387
- }
388
-
389
- // Call delegate.iterator[context.method](context.arg) and handle the
390
- // result, either by returning a { value, done } result from the
391
- // delegate iterator, or by modifying context.method and context.arg,
392
- // setting context.delegate to null, and returning the ContinueSentinel.
393
- function maybeInvokeDelegate(delegate, context) {
394
- var method = delegate.iterator[context.method];
395
- if (method === undefined$1) {
396
- // A .throw or .return when the delegate iterator has no .throw
397
- // method always terminates the yield* loop.
398
- context.delegate = null;
399
-
400
- if (context.method === "throw") {
401
- // Note: ["return"] must be used for ES3 parsing compatibility.
402
- if (delegate.iterator["return"]) {
403
- // If the delegate iterator has a return method, give it a
404
- // chance to clean up.
405
- context.method = "return";
406
- context.arg = undefined$1;
407
- maybeInvokeDelegate(delegate, context);
408
-
409
- if (context.method === "throw") {
410
- // If maybeInvokeDelegate(context) changed context.method from
411
- // "return" to "throw", let that override the TypeError below.
412
- return ContinueSentinel;
413
- }
414
- }
415
-
416
- context.method = "throw";
417
- context.arg = new TypeError(
418
- "The iterator does not provide a 'throw' method");
419
- }
420
-
421
- return ContinueSentinel;
422
- }
423
-
424
- var record = tryCatch(method, delegate.iterator, context.arg);
425
-
426
- if (record.type === "throw") {
427
- context.method = "throw";
428
- context.arg = record.arg;
429
- context.delegate = null;
430
- return ContinueSentinel;
431
- }
432
-
433
- var info = record.arg;
434
-
435
- if (! info) {
436
- context.method = "throw";
437
- context.arg = new TypeError("iterator result is not an object");
438
- context.delegate = null;
439
- return ContinueSentinel;
440
- }
441
-
442
- if (info.done) {
443
- // Assign the result of the finished delegate to the temporary
444
- // variable specified by delegate.resultName (see delegateYield).
445
- context[delegate.resultName] = info.value;
446
-
447
- // Resume execution at the desired location (see delegateYield).
448
- context.next = delegate.nextLoc;
449
-
450
- // If context.method was "throw" but the delegate handled the
451
- // exception, let the outer generator proceed normally. If
452
- // context.method was "next", forget context.arg since it has been
453
- // "consumed" by the delegate iterator. If context.method was
454
- // "return", allow the original .return call to continue in the
455
- // outer generator.
456
- if (context.method !== "return") {
457
- context.method = "next";
458
- context.arg = undefined$1;
459
- }
460
-
461
- } else {
462
- // Re-yield the result returned by the delegate method.
463
- return info;
464
- }
465
-
466
- // The delegate iterator is finished, so forget it and continue with
467
- // the outer generator.
468
- context.delegate = null;
469
- return ContinueSentinel;
470
- }
471
-
472
- // Define Generator.prototype.{next,throw,return} in terms of the
473
- // unified ._invoke helper method.
474
- defineIteratorMethods(Gp);
475
-
476
- define(Gp, toStringTagSymbol, "Generator");
477
-
478
- // A Generator should always return itself as the iterator object when the
479
- // @@iterator function is called on it. Some browsers' implementations of the
480
- // iterator prototype chain incorrectly implement this, causing the Generator
481
- // object to not be returned from this call. This ensures that doesn't happen.
482
- // See https://github.com/facebook/regenerator/issues/274 for more details.
483
- define(Gp, iteratorSymbol, function() {
484
- return this;
485
- });
486
-
487
- define(Gp, "toString", function() {
488
- return "[object Generator]";
489
- });
490
-
491
- function pushTryEntry(locs) {
492
- var entry = { tryLoc: locs[0] };
493
-
494
- if (1 in locs) {
495
- entry.catchLoc = locs[1];
496
- }
497
-
498
- if (2 in locs) {
499
- entry.finallyLoc = locs[2];
500
- entry.afterLoc = locs[3];
501
- }
502
-
503
- this.tryEntries.push(entry);
504
- }
505
-
506
- function resetTryEntry(entry) {
507
- var record = entry.completion || {};
508
- record.type = "normal";
509
- delete record.arg;
510
- entry.completion = record;
511
- }
512
-
513
- function Context(tryLocsList) {
514
- // The root entry object (effectively a try statement without a catch
515
- // or a finally block) gives us a place to store values thrown from
516
- // locations where there is no enclosing try statement.
517
- this.tryEntries = [{ tryLoc: "root" }];
518
- tryLocsList.forEach(pushTryEntry, this);
519
- this.reset(true);
520
- }
521
-
522
- exports.keys = function(object) {
523
- var keys = [];
524
- for (var key in object) {
525
- keys.push(key);
526
- }
527
- keys.reverse();
528
-
529
- // Rather than returning an object with a next method, we keep
530
- // things simple and return the next function itself.
531
- return function next() {
532
- while (keys.length) {
533
- var key = keys.pop();
534
- if (key in object) {
535
- next.value = key;
536
- next.done = false;
537
- return next;
538
- }
539
- }
540
-
541
- // To avoid creating an additional object, we just hang the .value
542
- // and .done properties off the next function object itself. This
543
- // also ensures that the minifier will not anonymize the function.
544
- next.done = true;
545
- return next;
546
- };
547
- };
548
-
549
- function values(iterable) {
550
- if (iterable) {
551
- var iteratorMethod = iterable[iteratorSymbol];
552
- if (iteratorMethod) {
553
- return iteratorMethod.call(iterable);
554
- }
555
-
556
- if (typeof iterable.next === "function") {
557
- return iterable;
558
- }
559
-
560
- if (!isNaN(iterable.length)) {
561
- var i = -1, next = function next() {
562
- while (++i < iterable.length) {
563
- if (hasOwn.call(iterable, i)) {
564
- next.value = iterable[i];
565
- next.done = false;
566
- return next;
567
- }
568
- }
569
-
570
- next.value = undefined$1;
571
- next.done = true;
572
-
573
- return next;
574
- };
575
-
576
- return next.next = next;
577
- }
578
- }
579
-
580
- // Return an iterator with no values.
581
- return { next: doneResult };
582
- }
583
- exports.values = values;
584
-
585
- function doneResult() {
586
- return { value: undefined$1, done: true };
587
- }
588
-
589
- Context.prototype = {
590
- constructor: Context,
591
-
592
- reset: function(skipTempReset) {
593
- this.prev = 0;
594
- this.next = 0;
595
- // Resetting context._sent for legacy support of Babel's
596
- // function.sent implementation.
597
- this.sent = this._sent = undefined$1;
598
- this.done = false;
599
- this.delegate = null;
600
-
601
- this.method = "next";
602
- this.arg = undefined$1;
603
-
604
- this.tryEntries.forEach(resetTryEntry);
605
-
606
- if (!skipTempReset) {
607
- for (var name in this) {
608
- // Not sure about the optimal order of these conditions:
609
- if (name.charAt(0) === "t" &&
610
- hasOwn.call(this, name) &&
611
- !isNaN(+name.slice(1))) {
612
- this[name] = undefined$1;
613
- }
614
- }
615
- }
616
- },
617
-
618
- stop: function() {
619
- this.done = true;
620
-
621
- var rootEntry = this.tryEntries[0];
622
- var rootRecord = rootEntry.completion;
623
- if (rootRecord.type === "throw") {
624
- throw rootRecord.arg;
625
- }
626
-
627
- return this.rval;
628
- },
629
-
630
- dispatchException: function(exception) {
631
- if (this.done) {
632
- throw exception;
633
- }
634
-
635
- var context = this;
636
- function handle(loc, caught) {
637
- record.type = "throw";
638
- record.arg = exception;
639
- context.next = loc;
640
-
641
- if (caught) {
642
- // If the dispatched exception was caught by a catch block,
643
- // then let that catch block handle the exception normally.
644
- context.method = "next";
645
- context.arg = undefined$1;
646
- }
647
-
648
- return !! caught;
649
- }
650
-
651
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
652
- var entry = this.tryEntries[i];
653
- var record = entry.completion;
654
-
655
- if (entry.tryLoc === "root") {
656
- // Exception thrown outside of any try block that could handle
657
- // it, so set the completion value of the entire function to
658
- // throw the exception.
659
- return handle("end");
660
- }
661
-
662
- if (entry.tryLoc <= this.prev) {
663
- var hasCatch = hasOwn.call(entry, "catchLoc");
664
- var hasFinally = hasOwn.call(entry, "finallyLoc");
665
-
666
- if (hasCatch && hasFinally) {
667
- if (this.prev < entry.catchLoc) {
668
- return handle(entry.catchLoc, true);
669
- } else if (this.prev < entry.finallyLoc) {
670
- return handle(entry.finallyLoc);
671
- }
672
-
673
- } else if (hasCatch) {
674
- if (this.prev < entry.catchLoc) {
675
- return handle(entry.catchLoc, true);
676
- }
677
-
678
- } else if (hasFinally) {
679
- if (this.prev < entry.finallyLoc) {
680
- return handle(entry.finallyLoc);
681
- }
682
-
683
- } else {
684
- throw new Error("try statement without catch or finally");
685
- }
686
- }
687
- }
688
- },
689
-
690
- abrupt: function(type, arg) {
691
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
692
- var entry = this.tryEntries[i];
693
- if (entry.tryLoc <= this.prev &&
694
- hasOwn.call(entry, "finallyLoc") &&
695
- this.prev < entry.finallyLoc) {
696
- var finallyEntry = entry;
697
- break;
698
- }
699
- }
700
-
701
- if (finallyEntry &&
702
- (type === "break" ||
703
- type === "continue") &&
704
- finallyEntry.tryLoc <= arg &&
705
- arg <= finallyEntry.finallyLoc) {
706
- // Ignore the finally entry if control is not jumping to a
707
- // location outside the try/catch block.
708
- finallyEntry = null;
709
- }
710
-
711
- var record = finallyEntry ? finallyEntry.completion : {};
712
- record.type = type;
713
- record.arg = arg;
714
-
715
- if (finallyEntry) {
716
- this.method = "next";
717
- this.next = finallyEntry.finallyLoc;
718
- return ContinueSentinel;
719
- }
720
-
721
- return this.complete(record);
722
- },
723
-
724
- complete: function(record, afterLoc) {
725
- if (record.type === "throw") {
726
- throw record.arg;
727
- }
728
-
729
- if (record.type === "break" ||
730
- record.type === "continue") {
731
- this.next = record.arg;
732
- } else if (record.type === "return") {
733
- this.rval = this.arg = record.arg;
734
- this.method = "return";
735
- this.next = "end";
736
- } else if (record.type === "normal" && afterLoc) {
737
- this.next = afterLoc;
738
- }
739
-
740
- return ContinueSentinel;
741
- },
742
-
743
- finish: function(finallyLoc) {
744
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
745
- var entry = this.tryEntries[i];
746
- if (entry.finallyLoc === finallyLoc) {
747
- this.complete(entry.completion, entry.afterLoc);
748
- resetTryEntry(entry);
749
- return ContinueSentinel;
750
- }
751
- }
752
- },
753
-
754
- "catch": function(tryLoc) {
755
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
756
- var entry = this.tryEntries[i];
757
- if (entry.tryLoc === tryLoc) {
758
- var record = entry.completion;
759
- if (record.type === "throw") {
760
- var thrown = record.arg;
761
- resetTryEntry(entry);
762
- }
763
- return thrown;
764
- }
765
- }
766
-
767
- // The context.catch method must only be called with a location
768
- // argument that corresponds to a known catch block.
769
- throw new Error("illegal catch attempt");
770
- },
771
-
772
- delegateYield: function(iterable, resultName, nextLoc) {
773
- this.delegate = {
774
- iterator: values(iterable),
775
- resultName: resultName,
776
- nextLoc: nextLoc
777
- };
778
-
779
- if (this.method === "next") {
780
- // Deliberately forget the last sent value so that we don't
781
- // accidentally pass it on to the delegate.
782
- this.arg = undefined$1;
783
- }
784
-
785
- return ContinueSentinel;
786
- }
787
- };
788
-
789
- // Regardless of whether this script is executing as a CommonJS module
790
- // or not, return the runtime object so that we can declare the variable
791
- // regeneratorRuntime in the outer scope, which allows this module to be
792
- // injected easily by `bin/regenerator --include-runtime script.js`.
793
- return exports;
794
-
795
- }(
796
- // If this script is executing as a CommonJS module, use module.exports
797
- // as the regeneratorRuntime namespace. Otherwise create a new empty
798
- // object. Either way, the resulting object will be used to initialize
799
- // the regeneratorRuntime variable at the top of this file.
800
- module.exports
801
- ));
802
-
803
- try {
804
- regeneratorRuntime = runtime;
805
- } catch (accidentalStrictMode) {
806
- // This module should not be running in strict mode, so the above
807
- // assignment should always work unless something is misconfigured. Just
808
- // in case runtime.js accidentally runs in strict mode, in modern engines
809
- // we can explicitly access globalThis. In older engines we can escape
810
- // strict mode using a global Function call. This could conceivably fail
811
- // if a Content Security Policy forbids using Function, but in that case
812
- // the proper solution is to fix the accidental strict mode problem. If
813
- // you've misconfigured your bundler to force strict mode and applied a
814
- // CSP to forbid Function, and you're not willing to fix either of those
815
- // problems, please detail your unique predicament in a GitHub issue.
816
- if (typeof globalThis === "object") {
817
- globalThis.regeneratorRuntime = runtime;
818
- } else {
819
- Function("r", "regeneratorRuntime = r")(runtime);
820
- }
821
- }
822
- }(runtime));
823
-
824
- var _regeneratorRuntime = runtime.exports;
825
-
826
- exports.CharType = void 0;
827
-
828
- (function (CharType) {
829
- CharType["Word"] = "word";
830
- CharType["End"] = "end";
831
- CharType["Pause"] = "pause";
832
- CharType["Sajdah"] = "sajdah";
833
- CharType["RubElHizb"] = "rub-el-hizb";
834
- })(exports.CharType || (exports.CharType = {}));
835
-
836
- exports.Language = void 0;
837
-
838
- (function (Language) {
839
- Language["ARABIC"] = "ar";
840
- Language["ENGLISH"] = "en";
841
- Language["URDU"] = "ur";
842
- Language["BENGALI"] = "bn";
843
- Language["TURKISH"] = "tr";
844
- Language["SPANISH"] = "es";
845
- Language["GERMAN"] = "de";
846
- Language["BOSNIAN"] = "bs";
847
- Language["RUSSIAN"] = "ru";
848
- Language["ALBANIAN_AL"] = "al";
849
- Language["FRENCH"] = "fr";
850
- Language["DUTCH"] = "nl";
851
- Language["TAMIL"] = "ta";
852
- Language["TAJIK"] = "tg";
853
- Language["INDONESIAN"] = "id";
854
- Language["UZBEK"] = "uz";
855
- Language["VIETNAMESE"] = "vi";
856
- Language["CHINESE"] = "zh";
857
- Language["ITALIAN"] = "it";
858
- Language["JAPANESE"] = "ja";
859
- Language["MALAYALAM"] = "ml";
860
- Language["AMHARIC"] = "am";
861
- Language["KAZAKH"] = "kk";
862
- Language["PORTUGUESE"] = "pt";
863
- Language["TAGALOG"] = "tl";
864
- Language["THAI"] = "th";
865
- Language["KOREAN"] = "ko";
866
- Language["HINDI"] = "hi";
867
- Language["KURDISH"] = "ku";
868
- Language["HAUSA"] = "ha";
869
- Language["AZERI"] = "az";
870
- Language["SWAHILI"] = "sw";
871
- Language["PERSIAN"] = "fa";
872
- Language["SERBIAN"] = "sr";
873
- Language["MARANAO"] = "mrn";
874
- Language["AMAZIGH"] = "zgh";
875
- Language["ASSAMESE"] = "as";
876
- Language["BULGARIAN"] = "bg";
877
- Language["CHECHEN"] = "ce";
878
- Language["CZECH"] = "cs";
879
- Language["DIVEHI"] = "dv";
880
- Language["DHIVEHI"] = "dv";
881
- Language["MALDIVIAN"] = "dv";
882
- Language["FINNISH"] = "fi";
883
- Language["GUJAARATI"] = "gu";
884
- Language["HEBREW"] = "he";
885
- Language["GEORGIAN"] = "ka";
886
- Language["CENTRAL_KHMER"] = "km";
887
- Language["GANDA"] = "lg";
888
- Language["MARATHI"] = "mr";
889
- Language["YORUBA"] = "yo";
890
- Language["MALAY"] = "ms";
891
- Language["NEPALI"] = "ne";
892
- Language["SWEDISH"] = "sv";
893
- Language["TELUGU"] = "te";
894
- Language["TATAR"] = "tt";
895
- Language["UIGHUR"] = "ug";
896
- Language["UYGHUR"] = "ug";
897
- Language["UKRAINIAN"] = "uk";
898
- Language["NORWEGIAN"] = "no";
899
- Language["OROMO"] = "om";
900
- Language["POLISH"] = "pl";
901
- Language["PASHTO"] = "ps";
902
- Language["ROMANIAN"] = "ro";
903
- Language["SINDHI"] = "sd";
904
- Language["NORTHERN_SAMI"] = "se";
905
- Language["SINHALA"] = "si";
906
- Language["SINHALESE"] = "si";
907
- Language["SOMALI"] = "so";
908
- Language["ALBANIAN_SQ"] = "sq";
909
- })(exports.Language || (exports.Language = {}));
910
-
911
- exports.QuranFont = void 0;
912
-
913
- (function (QuranFont) {
914
- QuranFont["MadaniV1"] = "code_v1";
915
- QuranFont["MadaniV2"] = "code_v2";
916
- QuranFont["Uthmani"] = "text_uthmani";
917
- })(exports.QuranFont || (exports.QuranFont = {}));
918
-
919
- // Reference: https://github.com/billjs/query-string/blob/master/src/index.ts
920
- var defaultStringifyFunction = function defaultStringifyFunction(_key, value) {
921
- return value;
922
- };
923
-
924
- var defaultEq = '=';
925
- var defaultSep = '&';
926
- var defaultConfig = {
927
- eq: defaultEq,
928
- sep: defaultSep,
929
- prefix: '',
930
- fn: defaultStringifyFunction
931
- };
932
- /**
933
- * Given a query object, return the query string
934
- * See qs-stringify.test.ts for examples
935
- *
936
- * @param {QueryObject} obj a query object to be converted to a query string
937
- * @param {Config} config optional configuration
938
- * @returns {string} query string
939
- *
940
- * @example
941
- * stringify({a: 1, b: 2}) // returns 'a=1&b=s'
942
- */
943
-
944
- function stringify(obj, config) {
945
- if (config === void 0) {
946
- config = defaultConfig;
947
- }
948
-
949
- var _defaultConfig$config = _extends({}, defaultConfig, config),
950
- eq = _defaultConfig$config.eq,
951
- sep = _defaultConfig$config.sep,
952
- fn = _defaultConfig$config.fn,
953
- prefix = _defaultConfig$config.prefix;
954
-
955
- if (obj == null || !isObject(obj)) {
956
- return '';
957
- }
958
-
959
- return Object.entries(obj).filter(function (_ref) {
960
- var value = _ref[1];
961
- return value !== null;
962
- }) // filter out null values
963
- .map(function (_ref2) {
964
- var key = _ref2[0],
965
- value = _ref2[1];
966
- if (Array.isArray(value)) return encode(key, value.join(','), {
967
- eq: eq,
968
- fn: fn,
969
- prefix: prefix
970
- });
971
- if (isObject(value)) return stringify(value, {
972
- eq: eq,
973
- sep: sep,
974
- fn: fn,
975
- prefix: getKey(key, prefix)
976
- });
977
- return encode(key, value, {
978
- eq: eq,
979
- fn: fn,
980
- prefix: prefix
981
- });
982
- }).join(sep);
983
- } // encode the key and add prefix if necessary
984
-
985
-
986
- var getKey = function getKey(key, prefix) {
987
- if (prefix === void 0) {
988
- prefix = '';
989
- }
990
-
991
- var encodedKey = encodeURIComponent(key);
992
- if (prefix) return prefix + "[" + encodedKey + "]";
993
- return encodedKey;
994
- }; // encode the key and value of a query object
995
-
996
-
997
- var encode = function encode(key, value, _ref3) {
998
- var _ref3$eq = _ref3.eq,
999
- eq = _ref3$eq === void 0 ? defaultEq : _ref3$eq,
1000
- _ref3$fn = _ref3.fn,
1001
- fn = _ref3$fn === void 0 ? defaultStringifyFunction : _ref3$fn,
1002
- _ref3$prefix = _ref3.prefix,
1003
- prefix = _ref3$prefix === void 0 ? '' : _ref3$prefix;
1004
- var newValue = encodeURIComponent(fn(key, value));
1005
- var newKey = getKey(key, prefix);
1006
- return [newKey, newValue].join(eq);
1007
- }; // check if the given value is an object
1008
-
1009
-
1010
- function isObject(obj) {
1011
- var type = typeof obj;
1012
- return obj && (type === 'object' || type === 'function') || false;
1013
- }
1014
-
1015
- var removeBeginningSlash = function removeBeginningSlash(url) {
1016
- return url.startsWith('/') ? url.slice(1) : url;
1017
- };
1018
-
1019
- var API_BASE_URL = 'https://api.quran.com/api/v4/';
1020
- var makeUrl = function makeUrl(url, params) {
1021
- var baseUrl = "" + API_BASE_URL + removeBeginningSlash(url);
1022
- if (!params) return baseUrl;
1023
- var decamelizedKeys = humps.decamelizeKeys(params);
1024
- var paramsString = stringify(decamelizedKeys);
1025
- if (!paramsString) return baseUrl;
1026
- return baseUrl + "?" + paramsString;
1027
- };
1028
- var fetcher = /*#__PURE__*/function () {
1029
- var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(url, params) {
1030
- var res, json;
1031
- return _regeneratorRuntime.wrap(function _callee$(_context) {
1032
- while (1) {
1033
- switch (_context.prev = _context.next) {
1034
- case 0:
1035
- if (params === void 0) {
1036
- params = {};
1037
- }
1038
-
1039
- _context.next = 3;
1040
- return fetch__default["default"](makeUrl(url, params));
1041
-
1042
- case 3:
1043
- res = _context.sent;
1044
-
1045
- if (!(res.status >= 400)) {
1046
- _context.next = 6;
1047
- break;
1048
- }
1049
-
1050
- throw new Error(res.status + " " + res.statusText);
1051
-
1052
- case 6:
1053
- _context.next = 8;
1054
- return res.json();
1055
-
1056
- case 8:
1057
- json = _context.sent;
1058
- return _context.abrupt("return", humps.camelizeKeys(json));
1059
-
1060
- case 10:
1061
- case "end":
1062
- return _context.stop();
1063
- }
1064
- }
1065
- }, _callee);
1066
- }));
1067
-
1068
- return function fetcher(_x, _x2) {
1069
- return _ref.apply(this, arguments);
1070
- };
1071
- }();
1072
-
1073
- // this maps chapterNumber to verseCount
1074
- var versesMapping = {
1075
- '1': 7,
1076
- '2': 286,
1077
- '3': 200,
1078
- '4': 176,
1079
- '5': 120,
1080
- '6': 165,
1081
- '7': 206,
1082
- '8': 75,
1083
- '9': 129,
1084
- '10': 109,
1085
- '11': 123,
1086
- '12': 111,
1087
- '13': 43,
1088
- '14': 52,
1089
- '15': 99,
1090
- '16': 128,
1091
- '17': 111,
1092
- '18': 110,
1093
- '19': 98,
1094
- '20': 135,
1095
- '21': 112,
1096
- '22': 78,
1097
- '23': 118,
1098
- '24': 64,
1099
- '25': 77,
1100
- '26': 227,
1101
- '27': 93,
1102
- '28': 88,
1103
- '29': 69,
1104
- '30': 60,
1105
- '31': 34,
1106
- '32': 30,
1107
- '33': 73,
1108
- '34': 54,
1109
- '35': 45,
1110
- '36': 83,
1111
- '37': 182,
1112
- '38': 88,
1113
- '39': 75,
1114
- '40': 85,
1115
- '41': 54,
1116
- '42': 53,
1117
- '43': 89,
1118
- '44': 59,
1119
- '45': 37,
1120
- '46': 35,
1121
- '47': 38,
1122
- '48': 29,
1123
- '49': 18,
1124
- '50': 45,
1125
- '51': 60,
1126
- '52': 49,
1127
- '53': 62,
1128
- '54': 55,
1129
- '55': 78,
1130
- '56': 96,
1131
- '57': 29,
1132
- '58': 22,
1133
- '59': 24,
1134
- '60': 13,
1135
- '61': 14,
1136
- '62': 11,
1137
- '63': 11,
1138
- '64': 18,
1139
- '65': 12,
1140
- '66': 12,
1141
- '67': 30,
1142
- '68': 52,
1143
- '69': 52,
1144
- '70': 44,
1145
- '71': 28,
1146
- '72': 28,
1147
- '73': 20,
1148
- '74': 56,
1149
- '75': 40,
1150
- '76': 31,
1151
- '77': 50,
1152
- '78': 40,
1153
- '79': 46,
1154
- '80': 42,
1155
- '81': 29,
1156
- '82': 19,
1157
- '83': 36,
1158
- '84': 25,
1159
- '85': 22,
1160
- '86': 17,
1161
- '87': 19,
1162
- '88': 26,
1163
- '89': 30,
1164
- '90': 20,
1165
- '91': 15,
1166
- '92': 21,
1167
- '93': 11,
1168
- '94': 8,
1169
- '95': 8,
1170
- '96': 19,
1171
- '97': 5,
1172
- '98': 8,
1173
- '99': 8,
1174
- '100': 11,
1175
- '101': 11,
1176
- '102': 8,
1177
- '103': 3,
1178
- '104': 9,
1179
- '105': 5,
1180
- '106': 4,
1181
- '107': 7,
1182
- '108': 3,
1183
- '109': 6,
1184
- '110': 3,
1185
- '111': 5,
1186
- '112': 4,
1187
- '113': 5,
1188
- '114': 6
1189
- };
1190
- /**
1191
- * Validates chapter id
1192
- * @param id chapter id
1193
- * @example
1194
- isValidChapterId('1') // true
1195
- isValidChapterId('114') // true
1196
- isValidChapterId('0') // false
1197
- isValidChapterId('-1') // false
1198
- isValidChapterId('200') // false
1199
- */
1200
-
1201
- var isValidChapterId = function isValidChapterId(id) {
1202
- var parsedId = typeof id === 'number' ? id : Number(id);
1203
- if (!parsedId || parsedId <= 0 || parsedId > 114) return false;
1204
- return true;
1205
- };
1206
- /**
1207
- * Validates juz number
1208
- * @param juz juz number
1209
- * @example
1210
- isValidJuz('1') // true
1211
- isValidJuz('30') // true
1212
- isValidJuz('0') // false
1213
- isValidJuz('-1') // false
1214
- isValidJuz('200') // false
1215
- */
1216
-
1217
-
1218
- var isValidJuz = function isValidJuz(juz) {
1219
- var parsedJuz = typeof juz === 'number' ? juz : Number(juz);
1220
- if (!parsedJuz || parsedJuz <= 0 || parsedJuz > 30) return false;
1221
- return true;
1222
- };
1223
- /**
1224
- * Validates rub number
1225
- * @param rub rub number
1226
- * @example
1227
- isValidRub('1') // true
1228
- isValidRub('240') // true
1229
- isValidRub('0') // false
1230
- isValidRub('-1') // false
1231
- isValidRub('300') // false
1232
- */
1233
-
1234
-
1235
- var isValidRub = function isValidRub(rub) {
1236
- var parsedRub = typeof rub === 'number' ? rub : Number(rub);
1237
- if (!parsedRub || parsedRub <= 0 || parsedRub > 240) return false;
1238
- return true;
1239
- };
1240
- /**
1241
- * Validates hizb number
1242
- * @param hizb hizb number
1243
- * @example
1244
- isValidHizb('1') // true
1245
- isValidHizb('60') // true
1246
- isValidHizb('0') // false
1247
- isValidHizb('-1') // false
1248
- isValidHizb('200') // false
1249
- */
1250
-
1251
-
1252
- var isValidHizb = function isValidHizb(hizb) {
1253
- var parsedHizb = typeof hizb === 'number' ? hizb : Number(hizb);
1254
- if (!parsedHizb || parsedHizb <= 0 || parsedHizb > 60) return false;
1255
- return true;
1256
- };
1257
- /**
1258
- * Validates mushaf page number
1259
- * @param page mushaf page number
1260
- * @example
1261
- isValidQuranPage('1') // true
1262
- isValidQuranPage('604') // true
1263
- isValidQuranPage('0') // false
1264
- isValidQuranPage('-1') // false
1265
- isValidQuranPage('1000') // false
1266
- */
1267
-
1268
-
1269
- var isValidQuranPage = function isValidQuranPage(page) {
1270
- var parsedPage = typeof page === 'number' ? page : Number(page);
1271
- if (!parsedPage || parsedPage <= 0 || parsedPage > 604) return false;
1272
- return true;
1273
- };
1274
- /**
1275
- * Validates verse key
1276
- * @param key colon separated verse key (chapter:verse)
1277
- * @example
1278
- isValidVerseKey('1:1') // true
1279
- isValidVerseKey('30:1') // true
1280
- isValidVerseKey('0') // false
1281
- isValidVerseKey('1:-') // false
1282
- isValidVerseKey('1_1') // false
1283
- */
1284
-
1285
-
1286
- var isValidVerseKey = function isValidVerseKey(key) {
1287
- var _key$trim$split = key.trim().split(':'),
1288
- chapterId = _key$trim$split[0],
1289
- verseId = _key$trim$split[1];
1290
-
1291
- if (!chapterId || !verseId || !isValidChapterId(chapterId)) return false;
1292
- var parsedVerse = Number(verseId);
1293
- var verseCount = versesMapping[chapterId];
1294
- if (!parsedVerse || parsedVerse <= 0 || parsedVerse > verseCount) return false;
1295
- return true;
1296
- };
1297
-
1298
- var Utils = {
1299
- isValidChapterId: isValidChapterId,
1300
- isValidJuz: isValidJuz,
1301
- isValidRub: isValidRub,
1302
- isValidHizb: isValidHizb,
1303
- isValidQuranPage: isValidQuranPage,
1304
- isValidVerseKey: isValidVerseKey
1305
- };
1306
-
1307
- var defaultOptions$2 = {
1308
- language: exports.Language.ARABIC
1309
- };
1310
-
1311
- var getChapterOptions = function getChapterOptions(options) {
1312
- if (options === void 0) {
1313
- options = {};
1314
- }
1315
-
1316
- var _final = _extends({}, defaultOptions$2, options);
1317
-
1318
- return _final;
1319
- };
1320
- /**
1321
- * Get all chapters.
1322
- * @description https://quran.api-docs.io/v4/chapters/list-chapters
1323
- * @param {GetChapterOptions} options
1324
- * @example
1325
- * quran.v4.chapters.findAll()
1326
- */
1327
-
1328
-
1329
- var findAll$1 = /*#__PURE__*/function () {
1330
- var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
1331
- var params, _yield$fetcher, chapters;
1332
-
1333
- return _regeneratorRuntime.wrap(function _callee$(_context) {
1334
- while (1) {
1335
- switch (_context.prev = _context.next) {
1336
- case 0:
1337
- params = getChapterOptions(options);
1338
- _context.next = 3;
1339
- return fetcher('/chapters', params);
1340
-
1341
- case 3:
1342
- _yield$fetcher = _context.sent;
1343
- chapters = _yield$fetcher.chapters;
1344
- return _context.abrupt("return", chapters);
1345
-
1346
- case 6:
1347
- case "end":
1348
- return _context.stop();
1349
- }
1350
- }
1351
- }, _callee);
1352
- }));
1353
-
1354
- return function findAll(_x) {
1355
- return _ref.apply(this, arguments);
1356
- };
1357
- }();
1358
- /**
1359
- * Get chapter by id.
1360
- * @description https://quran.api-docs.io/v4/chapters/get-chapter
1361
- * @param {ChapterId} id chapter id, minimum 1, maximum 114
1362
- * @param {GetChapterOptions} options
1363
- * @example
1364
- * quran.v4.chapters.findById('1')
1365
- * quran.v4.chapters.findById('114')
1366
- */
1367
-
1368
-
1369
- var findById = /*#__PURE__*/function () {
1370
- var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(id, options) {
1371
- var params, _yield$fetcher2, chapter;
1372
-
1373
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
1374
- while (1) {
1375
- switch (_context2.prev = _context2.next) {
1376
- case 0:
1377
- if (Utils.isValidChapterId(id)) {
1378
- _context2.next = 2;
1379
- break;
1380
- }
1381
-
1382
- throw new Error('Invalid chapter id');
1383
-
1384
- case 2:
1385
- params = getChapterOptions(options);
1386
- _context2.next = 5;
1387
- return fetcher("/chapters/" + id, params);
1388
-
1389
- case 5:
1390
- _yield$fetcher2 = _context2.sent;
1391
- chapter = _yield$fetcher2.chapter;
1392
- return _context2.abrupt("return", chapter);
1393
-
1394
- case 8:
1395
- case "end":
1396
- return _context2.stop();
1397
- }
1398
- }
1399
- }, _callee2);
1400
- }));
1401
-
1402
- return function findById(_x2, _x3) {
1403
- return _ref2.apply(this, arguments);
1404
- };
1405
- }();
1406
- /**
1407
- * Get chapter info by id.
1408
- * @description https://quran.api-docs.io/v4/chapters/chapter_info
1409
- * @param {ChapterId} id chapter id, minimum 1, maximum 114
1410
- * @param {GetChapterOptions} options
1411
- * @example
1412
- * quran.v4.chapters.findInfoById('1')
1413
- * quran.v4.chapters.findInfoById('114')
1414
- */
1415
-
1416
-
1417
- var findInfoById = /*#__PURE__*/function () {
1418
- var _ref3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(id, options) {
1419
- var params, _yield$fetcher3, chapterInfo;
1420
-
1421
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
1422
- while (1) {
1423
- switch (_context3.prev = _context3.next) {
1424
- case 0:
1425
- if (Utils.isValidChapterId(id)) {
1426
- _context3.next = 2;
1427
- break;
1428
- }
1429
-
1430
- throw new Error('Invalid chapter id');
1431
-
1432
- case 2:
1433
- params = getChapterOptions(options);
1434
- _context3.next = 5;
1435
- return fetcher("/chapters/" + id + "/info", params);
1436
-
1437
- case 5:
1438
- _yield$fetcher3 = _context3.sent;
1439
- chapterInfo = _yield$fetcher3.chapterInfo;
1440
- return _context3.abrupt("return", chapterInfo);
1441
-
1442
- case 8:
1443
- case "end":
1444
- return _context3.stop();
1445
- }
1446
- }
1447
- }, _callee3);
1448
- }));
1449
-
1450
- return function findInfoById(_x4, _x5) {
1451
- return _ref3.apply(this, arguments);
1452
- };
1453
- }();
1454
-
1455
- var chapters = {
1456
- findAll: findAll$1,
1457
- findById: findById,
1458
- findInfoById: findInfoById
1459
- };
1460
-
1461
- var defaultOptions$1 = {
1462
- language: exports.Language.ARABIC,
1463
- perPage: 50
1464
- };
1465
-
1466
- var getVerseOptions = function getVerseOptions(options) {
1467
- if (options === void 0) {
1468
- options = {};
1469
- }
1470
-
1471
- var initial = _extends({}, defaultOptions$1, options);
1472
-
1473
- var result = {
1474
- language: initial.language,
1475
- perPage: initial.perPage
1476
- };
1477
- if (initial.page) result.page = initial.page;
1478
- if (initial.words !== undefined) result.words = initial.words;
1479
- if (initial.translations) result.translations = initial.translations.join(',');
1480
- if (initial.tafsirs) result.tafsirs = initial.tafsirs.join(',');
1481
-
1482
- if (initial.fields) {
1483
- var fields = [];
1484
-
1485
- for (var _i = 0, _Object$entries = Object.entries(initial.fields); _i < _Object$entries.length; _i++) {
1486
- var _Object$entries$_i = _Object$entries[_i],
1487
- key = _Object$entries$_i[0],
1488
- value = _Object$entries$_i[1];
1489
- if (value) fields.push(humps.decamelize(key));
1490
- }
1491
-
1492
- result.fields = fields.join(',');
1493
- }
1494
-
1495
- if (initial.wordFields) {
1496
- var wordFields = [];
1497
-
1498
- for (var _i2 = 0, _Object$entries2 = Object.entries(initial.wordFields); _i2 < _Object$entries2.length; _i2++) {
1499
- var _Object$entries2$_i = _Object$entries2[_i2],
1500
- _key = _Object$entries2$_i[0],
1501
- _value = _Object$entries2$_i[1];
1502
- if (_value) wordFields.push(humps.decamelize(_key));
1503
- }
1504
-
1505
- result.wordFields = wordFields.join(',');
1506
- }
1507
-
1508
- if (initial.translationFields) {
1509
- var translationFields = [];
1510
-
1511
- for (var _i3 = 0, _Object$entries3 = Object.entries(initial.translationFields); _i3 < _Object$entries3.length; _i3++) {
1512
- var _Object$entries3$_i = _Object$entries3[_i3],
1513
- _key2 = _Object$entries3$_i[0],
1514
- _value2 = _Object$entries3$_i[1];
1515
- if (_value2) translationFields.push(humps.decamelize(_key2));
1516
- }
1517
-
1518
- result.translationFields = translationFields.join(',');
1519
- }
1520
-
1521
- if (initial.reciter) result.audio = initial.reciter;
1522
- return result;
1523
- };
1524
- /**
1525
- * Get a specific ayah with key. Key is combination of surah number and ayah number.
1526
- * @description https://quran.api-docs.io/v4/verses/by-specific-verse-by-key
1527
- * @param {VerseKey} key - surah number and ayah number separated by a colon.
1528
- * @param {GetVerseOptions} options
1529
- * @example
1530
- * quran.v4.verses.findByKey('1:1')
1531
- * quran.v4.verses.findByKey('101:5')
1532
- */
1533
-
1534
-
1535
- var findByKey = /*#__PURE__*/function () {
1536
- var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(key, options) {
1537
- var params, url, _yield$fetcher, verse;
1538
-
1539
- return _regeneratorRuntime.wrap(function _callee$(_context) {
1540
- while (1) {
1541
- switch (_context.prev = _context.next) {
1542
- case 0:
1543
- if (Utils.isValidVerseKey(key)) {
1544
- _context.next = 2;
1545
- break;
1546
- }
1547
-
1548
- throw new Error('Invalid verse key');
1549
-
1550
- case 2:
1551
- params = getVerseOptions(options);
1552
- url = "/verses/by_key/" + key;
1553
- _context.next = 6;
1554
- return fetcher(url, params);
1555
-
1556
- case 6:
1557
- _yield$fetcher = _context.sent;
1558
- verse = _yield$fetcher.verse;
1559
- return _context.abrupt("return", verse);
1560
-
1561
- case 9:
1562
- case "end":
1563
- return _context.stop();
1564
- }
1565
- }
1566
- }, _callee);
1567
- }));
1568
-
1569
- return function findByKey(_x, _x2) {
1570
- return _ref.apply(this, arguments);
1571
- };
1572
- }();
1573
- /**
1574
- * Get all ayahs for a specific chapter (surah).
1575
- * @description https://quran.api-docs.io/v4/verses/by_chapter
1576
- * @param {ChapterId} id - chapter id (surah number)
1577
- * @param {GetVerseOptions} options
1578
- * @example
1579
- * quran.v4.verses.findByChapter('1')
1580
- * quran.v4.verses.findByChapter('101')
1581
- */
1582
-
1583
-
1584
- var findByChapter = /*#__PURE__*/function () {
1585
- var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(id, options) {
1586
- var params, url, _yield$fetcher2, verses;
1587
-
1588
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
1589
- while (1) {
1590
- switch (_context2.prev = _context2.next) {
1591
- case 0:
1592
- if (Utils.isValidChapterId(id)) {
1593
- _context2.next = 2;
1594
- break;
1595
- }
1596
-
1597
- throw new Error('Invalid chapter id');
1598
-
1599
- case 2:
1600
- params = getVerseOptions(options);
1601
- url = "/verses/by_chapter/" + id;
1602
- _context2.next = 6;
1603
- return fetcher(url, params);
1604
-
1605
- case 6:
1606
- _yield$fetcher2 = _context2.sent;
1607
- verses = _yield$fetcher2.verses;
1608
- return _context2.abrupt("return", verses);
1609
-
1610
- case 9:
1611
- case "end":
1612
- return _context2.stop();
1613
- }
1614
- }
1615
- }, _callee2);
1616
- }));
1617
-
1618
- return function findByChapter(_x3, _x4) {
1619
- return _ref2.apply(this, arguments);
1620
- };
1621
- }();
1622
- /**
1623
- * Get all ayahs for a specific page in the Quran.
1624
- * @description https://quran.api-docs.io/v4/verses/by-page
1625
- * @param {PageNumber} page - Quran page number
1626
- * @param {GetVerseOptions} options
1627
- * @example
1628
- * quran.v4.verses.findByPage('1')
1629
- * quran.v4.verses.findByPage('101')
1630
- */
1631
-
1632
-
1633
- var findByPage = /*#__PURE__*/function () {
1634
- var _ref3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(page, options) {
1635
- var params, url, _yield$fetcher3, verses;
1636
-
1637
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
1638
- while (1) {
1639
- switch (_context3.prev = _context3.next) {
1640
- case 0:
1641
- if (Utils.isValidQuranPage(page)) {
1642
- _context3.next = 2;
1643
- break;
1644
- }
1645
-
1646
- throw new Error('Invalid page');
1647
-
1648
- case 2:
1649
- params = getVerseOptions(options);
1650
- url = "/verses/by_page/" + page;
1651
- _context3.next = 6;
1652
- return fetcher(url, params);
1653
-
1654
- case 6:
1655
- _yield$fetcher3 = _context3.sent;
1656
- verses = _yield$fetcher3.verses;
1657
- return _context3.abrupt("return", verses);
1658
-
1659
- case 9:
1660
- case "end":
1661
- return _context3.stop();
1662
- }
1663
- }
1664
- }, _callee3);
1665
- }));
1666
-
1667
- return function findByPage(_x5, _x6) {
1668
- return _ref3.apply(this, arguments);
1669
- };
1670
- }();
1671
- /**
1672
- * Get all ayahs for a Juz.
1673
- * @description https://quran.api-docs.io/v4/verses/by-juz
1674
- * @param {JuzNumber} id - juz number
1675
- * @param {GetVerseOptions} options
1676
- * @example
1677
- * quran.v4.verses.findByJuz('1')
1678
- * quran.v4.verses.findByJuz('29')
1679
- */
1680
-
1681
-
1682
- var findByJuz = /*#__PURE__*/function () {
1683
- var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(juz, options) {
1684
- var params, url, _yield$fetcher4, verses;
1685
-
1686
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
1687
- while (1) {
1688
- switch (_context4.prev = _context4.next) {
1689
- case 0:
1690
- if (Utils.isValidJuz(juz)) {
1691
- _context4.next = 2;
1692
- break;
1693
- }
1694
-
1695
- throw new Error('Invalid juz');
1696
-
1697
- case 2:
1698
- params = getVerseOptions(options);
1699
- url = "/verses/by_juz/" + juz;
1700
- _context4.next = 6;
1701
- return fetcher(url, params);
1702
-
1703
- case 6:
1704
- _yield$fetcher4 = _context4.sent;
1705
- verses = _yield$fetcher4.verses;
1706
- return _context4.abrupt("return", verses);
1707
-
1708
- case 9:
1709
- case "end":
1710
- return _context4.stop();
1711
- }
1712
- }
1713
- }, _callee4);
1714
- }));
1715
-
1716
- return function findByJuz(_x7, _x8) {
1717
- return _ref4.apply(this, arguments);
1718
- };
1719
- }();
1720
- /**
1721
- * Get all ayahs for a Hizb.
1722
- * @description https://quran.api-docs.io/v4/verses/by-hizb-number
1723
- * @param {HizbNumber} hizb - hizb number
1724
- * @param {GetVerseOptions} options
1725
- * @example
1726
- * quran.v4.verses.findByHizb('1')
1727
- * quran.v4.verses.findByHizb('29')
1728
- */
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
1769
-
1770
- /**
1771
- * Get all ayahs for a Rub.
1772
- * @description https://quran.api-docs.io/v4/verses/by-rub-number
1773
- * @param {RubNumber} rub - rub number
1774
- * @param {GetVerseOptions} options
1775
- * @example
1776
- * quran.v4.verses.findByRub('1')
1777
- * quran.v4.verses.findByRub('29')
1778
- */
1779
- // const findByRub = async (rub: RubNumber, options?: GetVerseOptions) => {
1780
- // if (!Utils.isValidRub(rub)) throw new Error('Invalid rub');
1781
- // const params = getVerseOptions(options);
1782
- // const url = `/verses/by_rub/${rub}`;
1783
- // const { verses } = await fetcher<{ verses: Verse[] }>(url, params);
1784
- // return verses;
1785
- // };
1786
-
1787
- /**
1788
- * Get a random ayah.
1789
- * @description https://quran.api-docs.io/v4/verses/random
1790
- * @param {GetVerseOptions} options
1791
- * @example
1792
- * quran.v4.verses.findRandom()
1793
- */
1794
-
1795
-
1796
- var findRandom = /*#__PURE__*/function () {
1797
- var _ref6 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(options) {
1798
- var params, _yield$fetcher6, verse;
1799
-
1800
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
1801
- while (1) {
1802
- switch (_context6.prev = _context6.next) {
1803
- case 0:
1804
- params = getVerseOptions(options);
1805
- _context6.next = 3;
1806
- return fetcher('/verses/random', params);
1807
-
1808
- case 3:
1809
- _yield$fetcher6 = _context6.sent;
1810
- verse = _yield$fetcher6.verse;
1811
- return _context6.abrupt("return", verse);
1812
-
1813
- case 6:
1814
- case "end":
1815
- return _context6.stop();
1816
- }
1817
- }
1818
- }, _callee6);
1819
- }));
1820
-
1821
- return function findRandom(_x11) {
1822
- return _ref6.apply(this, arguments);
1823
- };
1824
- }();
1825
-
1826
- var verses = {
1827
- findByKey: findByKey,
1828
- findByChapter: findByChapter,
1829
- findByPage: findByPage,
1830
- findByJuz: findByJuz,
1831
- findByHizb: findByHizb,
1832
- // findByRub,
1833
- findRandom: findRandom
1834
- };
1835
-
1836
- /**
1837
- * Get All Juzs
1838
- * @description https://quran.api-docs.io/v4/juz/get-all-juzs
1839
- * @example
1840
- * quran.v4.juzs.findAll()
1841
- */
1842
-
1843
- var findAll = /*#__PURE__*/function () {
1844
- var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
1845
- var _yield$fetcher, juzs;
1846
-
1847
- return _regeneratorRuntime.wrap(function _callee$(_context) {
1848
- while (1) {
1849
- switch (_context.prev = _context.next) {
1850
- case 0:
1851
- _context.next = 2;
1852
- return fetcher('/juzs');
1853
-
1854
- case 2:
1855
- _yield$fetcher = _context.sent;
1856
- juzs = _yield$fetcher.juzs;
1857
- return _context.abrupt("return", juzs);
1858
-
1859
- case 5:
1860
- case "end":
1861
- return _context.stop();
1862
- }
1863
- }
1864
- }, _callee);
1865
- }));
1866
-
1867
- return function findAll() {
1868
- return _ref.apply(this, arguments);
1869
- };
1870
- }();
1871
-
1872
- var juzs = {
1873
- findAll: findAll
1874
- };
1875
-
1876
- var defaultChapterRecitationsOptions = {
1877
- language: exports.Language.ARABIC
1878
- };
1879
-
1880
- var getChapterRecitationsOptions = function getChapterRecitationsOptions(options) {
1881
- if (options === void 0) {
1882
- options = {};
1883
- }
1884
-
1885
- var _final = _extends({}, defaultChapterRecitationsOptions, options);
1886
-
1887
- return _final;
1888
- };
1889
-
1890
- var defaultVerseRecitationsOptions = {
1891
- language: exports.Language.ARABIC
1892
- };
1893
-
1894
- var getVerseRecitationsOptions = function getVerseRecitationsOptions(options) {
1895
- if (options === void 0) {
1896
- options = {};
1897
- }
1898
-
1899
- var initial = _extends({}, defaultVerseRecitationsOptions, options);
1900
-
1901
- var _final2 = {
1902
- language: initial.language
1903
- };
1904
-
1905
- if (initial.fields) {
1906
- var fields = [];
1907
-
1908
- for (var _i = 0, _Object$entries = Object.entries(initial.fields); _i < _Object$entries.length; _i++) {
1909
- var _Object$entries$_i = _Object$entries[_i],
1910
- key = _Object$entries$_i[0],
1911
- value = _Object$entries$_i[1];
1912
- if (value) fields.push(humps.decamelize(key));
1913
- }
1914
-
1915
- _final2.fields = fields.join(',');
1916
- }
1917
-
1918
- return _final2;
1919
- };
1920
- /**
1921
- * Get all chapter recitations for specific reciter
1922
- * @description https://quran.api-docs.io/v4/audio-recitations/list-of-all-surah-audio-files-for-specific-reciter
1923
- * @param {string} reciterId
1924
- * @param {GetChapterRecitationOptions} options
1925
- * @example
1926
- * quran.v4.audio.findAllChapterRecitations('2')
1927
- */
1928
-
1929
-
1930
- var findAllChapterRecitations = /*#__PURE__*/function () {
1931
- var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(reciterId, options) {
1932
- var params, _yield$fetcher, audioFiles;
1933
-
1934
- return _regeneratorRuntime.wrap(function _callee$(_context) {
1935
- while (1) {
1936
- switch (_context.prev = _context.next) {
1937
- case 0:
1938
- params = getChapterRecitationsOptions(options);
1939
- _context.next = 3;
1940
- return fetcher("/chapter_recitations/" + reciterId, params);
1941
-
1942
- case 3:
1943
- _yield$fetcher = _context.sent;
1944
- audioFiles = _yield$fetcher.audioFiles;
1945
- return _context.abrupt("return", audioFiles);
1946
-
1947
- case 6:
1948
- case "end":
1949
- return _context.stop();
1950
- }
1951
- }
1952
- }, _callee);
1953
- }));
1954
-
1955
- return function findAllChapterRecitations(_x, _x2) {
1956
- return _ref.apply(this, arguments);
1957
- };
1958
- }();
1959
- /**
1960
- * Get chapter recitation for specific reciter and a specific chapter
1961
- * @description https://quran.api-docs.io/v4/audio-recitations/get-single-surah-audio-for-specific-reciter
1962
- * @param {ChapterId} chapterId
1963
- * @param {string} reciterId
1964
- * @param {GetChapterRecitationOptions} options
1965
- * @example
1966
- * quran.v4.audio.findChapterRecitationById('1', '2') // first chapter recitation for reciter 2
1967
- */
1968
-
1969
-
1970
- var findChapterRecitationById = /*#__PURE__*/function () {
1971
- var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(chapterId, reciterId, options) {
1972
- var params, _yield$fetcher2, audioFile;
1973
-
1974
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
1975
- while (1) {
1976
- switch (_context2.prev = _context2.next) {
1977
- case 0:
1978
- if (Utils.isValidChapterId(chapterId)) {
1979
- _context2.next = 2;
1980
- break;
1981
- }
1982
-
1983
- throw new Error('Invalid chapter id');
1984
-
1985
- case 2:
1986
- params = getChapterRecitationsOptions(options);
1987
- _context2.next = 5;
1988
- return fetcher("/chapter_recitations/" + reciterId + "/" + chapterId, params);
1989
-
1990
- case 5:
1991
- _yield$fetcher2 = _context2.sent;
1992
- audioFile = _yield$fetcher2.audioFile;
1993
- return _context2.abrupt("return", audioFile);
1994
-
1995
- case 8:
1996
- case "end":
1997
- return _context2.stop();
1998
- }
1999
- }
2000
- }, _callee2);
2001
- }));
2002
-
2003
- return function findChapterRecitationById(_x3, _x4, _x5) {
2004
- return _ref2.apply(this, arguments);
2005
- };
2006
- }();
2007
- /**
2008
- * Get all verse audio files for a specific reciter and a specific chapter
2009
- * @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-surah
2010
- * @param {ChapterId} chapterId
2011
- * @param {string} recitationId
2012
- * @param {GetVerseRecitationOptions} options
2013
- * @example
2014
- * quran.v4.audio.findVerseRecitationsByChapter('1', '2')
2015
- */
2016
-
2017
-
2018
- var findVerseRecitationsByChapter = /*#__PURE__*/function () {
2019
- var _ref3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(chapterId, recitationId, options) {
2020
- var params, data;
2021
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
2022
- while (1) {
2023
- switch (_context3.prev = _context3.next) {
2024
- case 0:
2025
- if (Utils.isValidChapterId(chapterId)) {
2026
- _context3.next = 2;
2027
- break;
2028
- }
2029
-
2030
- throw new Error('Invalid chapter id');
2031
-
2032
- case 2:
2033
- params = getVerseRecitationsOptions(options);
2034
- _context3.next = 5;
2035
- return fetcher("/recitations/" + recitationId + "/by_chapter/" + chapterId, params);
2036
-
2037
- case 5:
2038
- data = _context3.sent;
2039
- return _context3.abrupt("return", data);
2040
-
2041
- case 7:
2042
- case "end":
2043
- return _context3.stop();
2044
- }
2045
- }
2046
- }, _callee3);
2047
- }));
2048
-
2049
- return function findVerseRecitationsByChapter(_x6, _x7, _x8) {
2050
- return _ref3.apply(this, arguments);
2051
- };
2052
- }();
2053
- /**
2054
- * Get all verse audio files for a specific reciter and a specific juz
2055
- * @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-juz
2056
- * @param {JuzNumber} juz
2057
- * @param {string} recitationId
2058
- * @param {GetRecitationsOptions} options
2059
- * @example
2060
- * quran.v4.audio.findVerseRecitationsByJuz('1', '2')
2061
- */
2062
-
2063
-
2064
- var findVerseRecitationsByJuz = /*#__PURE__*/function () {
2065
- var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(juz, recitationId, options) {
2066
- var params, data;
2067
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
2068
- while (1) {
2069
- switch (_context4.prev = _context4.next) {
2070
- case 0:
2071
- if (Utils.isValidJuz(juz)) {
2072
- _context4.next = 2;
2073
- break;
2074
- }
2075
-
2076
- throw new Error('Invalid juz');
2077
-
2078
- case 2:
2079
- params = getVerseRecitationsOptions(options);
2080
- _context4.next = 5;
2081
- return fetcher("/recitations/" + recitationId + "/by_juz/" + juz, params);
2082
-
2083
- case 5:
2084
- data = _context4.sent;
2085
- return _context4.abrupt("return", data);
2086
-
2087
- case 7:
2088
- case "end":
2089
- return _context4.stop();
2090
- }
2091
- }
2092
- }, _callee4);
2093
- }));
2094
-
2095
- return function findVerseRecitationsByJuz(_x9, _x10, _x11) {
2096
- return _ref4.apply(this, arguments);
2097
- };
2098
- }();
2099
- /**
2100
- * Get all verse audio files for a specific reciter and a specific mushaf page
2101
- * @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-madani-mushaf-page
2102
- * @param {PageNumber} page
2103
- * @param {string} recitationId
2104
- * @param {GetVerseRecitationOptions} options
2105
- * @example
2106
- * quran.v4.audio.findVerseRecitationsByPage('1', '2')
2107
- */
2108
-
2109
-
2110
- var findVerseRecitationsByPage = /*#__PURE__*/function () {
2111
- var _ref5 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(page, recitationId, options) {
2112
- var params, data;
2113
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
2114
- while (1) {
2115
- switch (_context5.prev = _context5.next) {
2116
- case 0:
2117
- if (Utils.isValidQuranPage(page)) {
2118
- _context5.next = 2;
2119
- break;
2120
- }
2121
-
2122
- throw new Error('Invalid page');
2123
-
2124
- case 2:
2125
- params = getVerseRecitationsOptions(options);
2126
- _context5.next = 5;
2127
- return fetcher("/recitations/" + recitationId + "/by_page/" + page, params);
2128
-
2129
- case 5:
2130
- data = _context5.sent;
2131
- return _context5.abrupt("return", data);
2132
-
2133
- case 7:
2134
- case "end":
2135
- return _context5.stop();
2136
- }
2137
- }
2138
- }, _callee5);
2139
- }));
2140
-
2141
- return function findVerseRecitationsByPage(_x12, _x13, _x14) {
2142
- return _ref5.apply(this, arguments);
2143
- };
2144
- }();
2145
- /**
2146
- * Get all verse audio files for a specific reciter and a specific rub
2147
- * @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-rub
2148
- * @param {RubNumber} rub
2149
- * @param {string} recitationId
2150
- * @param {GetVerseRecitationOptions} options
2151
- * @example
2152
- * quran.v4.audio.findVerseRecitationsByRub('1', '2')
2153
- */
2154
-
2155
-
2156
- var findVerseRecitationsByRub = /*#__PURE__*/function () {
2157
- var _ref6 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(rub, recitationId, options) {
2158
- var params, data;
2159
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
2160
- while (1) {
2161
- switch (_context6.prev = _context6.next) {
2162
- case 0:
2163
- if (Utils.isValidRub(rub)) {
2164
- _context6.next = 2;
2165
- break;
2166
- }
2167
-
2168
- throw new Error('Invalid rub');
2169
-
2170
- case 2:
2171
- params = getVerseRecitationsOptions(options);
2172
- _context6.next = 5;
2173
- return fetcher("/recitations/" + recitationId + "/by_rub/" + rub, params);
2174
-
2175
- case 5:
2176
- data = _context6.sent;
2177
- return _context6.abrupt("return", data);
2178
-
2179
- case 7:
2180
- case "end":
2181
- return _context6.stop();
2182
- }
2183
- }
2184
- }, _callee6);
2185
- }));
2186
-
2187
- return function findVerseRecitationsByRub(_x15, _x16, _x17) {
2188
- return _ref6.apply(this, arguments);
2189
- };
2190
- }();
2191
- /**
2192
- * Get all verse audio files for a specific reciter and a specific hizb
2193
- * @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-hizb
2194
- * @param {HizbNumber} hizb
2195
- * @param {string} recitationId
2196
- * @param {GetVerseRecitationOptions} options
2197
- * @example
2198
- * quran.v4.audio.findVerseRecitationsByHizb('1', '2')
2199
- */
2200
-
2201
-
2202
- var findVerseRecitationsByHizb = /*#__PURE__*/function () {
2203
- var _ref7 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(hizb, recitationId, options) {
2204
- var params, data;
2205
- return _regeneratorRuntime.wrap(function _callee7$(_context7) {
2206
- while (1) {
2207
- switch (_context7.prev = _context7.next) {
2208
- case 0:
2209
- if (Utils.isValidHizb(hizb)) {
2210
- _context7.next = 2;
2211
- break;
2212
- }
2213
-
2214
- throw new Error('Invalid hizb');
2215
-
2216
- case 2:
2217
- params = getVerseRecitationsOptions(options);
2218
- _context7.next = 5;
2219
- return fetcher("/recitations/" + recitationId + "/by_hizb/" + hizb, params);
2220
-
2221
- case 5:
2222
- data = _context7.sent;
2223
- return _context7.abrupt("return", data);
2224
-
2225
- case 7:
2226
- case "end":
2227
- return _context7.stop();
2228
- }
2229
- }
2230
- }, _callee7);
2231
- }));
2232
-
2233
- return function findVerseRecitationsByHizb(_x18, _x19, _x20) {
2234
- return _ref7.apply(this, arguments);
2235
- };
2236
- }();
2237
- /**
2238
- * Get all verse audio files for a specific reciter and a specific verse
2239
- * @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-ayah
2240
- * @param {VerseKey} key
2241
- * @param {string} recitationId
2242
- * @param {GetVerseRecitationOptions} options
2243
- * @example
2244
- * quran.v4.audio.findVerseRecitationsByKey('1:1', '2')
2245
- */
2246
-
2247
-
2248
- var findVerseRecitationsByKey = /*#__PURE__*/function () {
2249
- var _ref8 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(key, recitationId, options) {
2250
- var params, data;
2251
- return _regeneratorRuntime.wrap(function _callee8$(_context8) {
2252
- while (1) {
2253
- switch (_context8.prev = _context8.next) {
2254
- case 0:
2255
- if (Utils.isValidVerseKey(key)) {
2256
- _context8.next = 2;
2257
- break;
2258
- }
2259
-
2260
- throw new Error('Invalid verse key');
2261
-
2262
- case 2:
2263
- params = getVerseRecitationsOptions(options);
2264
- _context8.next = 5;
2265
- return fetcher("/recitations/" + recitationId + "/by_ayah/" + key, params);
2266
-
2267
- case 5:
2268
- data = _context8.sent;
2269
- return _context8.abrupt("return", data);
2270
-
2271
- case 7:
2272
- case "end":
2273
- return _context8.stop();
2274
- }
2275
- }
2276
- }, _callee8);
2277
- }));
2278
-
2279
- return function findVerseRecitationsByKey(_x21, _x22, _x23) {
2280
- return _ref8.apply(this, arguments);
2281
- };
2282
- }();
2283
-
2284
- var audio = {
2285
- findAllChapterRecitations: findAllChapterRecitations,
2286
- findChapterRecitationById: findChapterRecitationById,
2287
- findVerseRecitationsByChapter: findVerseRecitationsByChapter,
2288
- findVerseRecitationsByJuz: findVerseRecitationsByJuz,
2289
- findVerseRecitationsByPage: findVerseRecitationsByPage,
2290
- findVerseRecitationsByRub: findVerseRecitationsByRub,
2291
- findVerseRecitationsByHizb: findVerseRecitationsByHizb,
2292
- findVerseRecitationsByKey: findVerseRecitationsByKey
2293
- };
2294
-
2295
- var defaultOptions = {
2296
- language: exports.Language.ARABIC
2297
- };
2298
-
2299
- var getResourcesOptions = function getResourcesOptions(options) {
2300
- if (options === void 0) {
2301
- options = {};
2302
- }
2303
-
2304
- var _final = _extends({}, defaultOptions, options);
2305
-
2306
- return _final;
2307
- };
2308
- /**
2309
- * Get all recitations.
2310
- * @description https://quran.api-docs.io/v4/resources/recitations
2311
- * @param {GetResourceOptions} options
2312
- * @example
2313
- * quran.v4.resources.findAllRecitations()
2314
- */
2315
-
2316
-
2317
- var findAllRecitations = /*#__PURE__*/function () {
2318
- var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
2319
- var params, _yield$fetcher, recitations;
2320
-
2321
- return _regeneratorRuntime.wrap(function _callee$(_context) {
2322
- while (1) {
2323
- switch (_context.prev = _context.next) {
2324
- case 0:
2325
- params = getResourcesOptions(options);
2326
- _context.next = 3;
2327
- return fetcher('/resources/recitations', params);
2328
-
2329
- case 3:
2330
- _yield$fetcher = _context.sent;
2331
- recitations = _yield$fetcher.recitations;
2332
- return _context.abrupt("return", recitations);
2333
-
2334
- case 6:
2335
- case "end":
2336
- return _context.stop();
2337
- }
2338
- }
2339
- }, _callee);
2340
- }));
2341
-
2342
- return function findAllRecitations(_x) {
2343
- return _ref.apply(this, arguments);
2344
- };
2345
- }(); // TODO: uncomment when API is ready
2346
-
2347
- /**
2348
- * Get all recitation info.
2349
- * @description https://quran.api-docs.io/v4/resources/recitation-info
2350
- * @param {string} id recitation id
2351
- * @param {GetResourceOptions} options
2352
- * @example
2353
- * quran.v4.resources.findRecitationInfo('1')
2354
- */
2355
- // const findRecitationInfo = async (id: string, options?: GetResourceOptions) => {
2356
- // const params = getResourcesOptions(options);
2357
- // const { info } = await fetcher<{
2358
- // info: RecitationInfoResource;
2359
- // }>(`/resources/recitations/${id}/info`, params);
2360
- // return info;
2361
- // };
2362
-
2363
- /**
2364
- * Get all translations.
2365
- * @description https://quran.api-docs.io/v4/resources/translations
2366
- * @param {GetResourceOptions} options
2367
- * @example
2368
- * quran.v4.resources.findAllTranslations()
2369
- */
2370
-
2371
-
2372
- var findAllTranslations = /*#__PURE__*/function () {
2373
- var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(options) {
2374
- var params, _yield$fetcher2, translations;
2375
-
2376
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
2377
- while (1) {
2378
- switch (_context2.prev = _context2.next) {
2379
- case 0:
2380
- params = getResourcesOptions(options);
2381
- _context2.next = 3;
2382
- return fetcher('/resources/translations', params);
2383
-
2384
- case 3:
2385
- _yield$fetcher2 = _context2.sent;
2386
- translations = _yield$fetcher2.translations;
2387
- return _context2.abrupt("return", translations);
2388
-
2389
- case 6:
2390
- case "end":
2391
- return _context2.stop();
2392
- }
2393
- }
2394
- }, _callee2);
2395
- }));
2396
-
2397
- return function findAllTranslations(_x2) {
2398
- return _ref2.apply(this, arguments);
2399
- };
2400
- }(); // TODO: uncomment when API is ready
2401
-
2402
- /**
2403
- * Get translation info.
2404
- * @description https://quran.api-docs.io/v4/resources/translation-info
2405
- * @param {string} id translation id
2406
- * @param {GetResourceOptions} options
2407
- * @example
2408
- * quran.v4.resources.findTranslationInfo('169')
2409
- */
2410
- // const findTranslationInfo = async (id: string, options?: GetResourceOptions) => {
2411
- // const params = getResourcesOptions(options);
2412
- // const { info } = await fetcher<{
2413
- // info: TranslationInfoResource;
2414
- // }>(`/resources/translations/${id}/info`, params);
2415
- // return info;
2416
- // };
2417
-
2418
- /**
2419
- * Get all tafsirs.
2420
- * @description https://quran.api-docs.io/v4/resources/tafsirs
2421
- * @param {GetResourceOptions} options
2422
- * @example
2423
- * quran.v4.resources.findAllTafsirs()
2424
- */
2425
-
2426
-
2427
- var findAllTafsirs = /*#__PURE__*/function () {
2428
- var _ref3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(options) {
2429
- var params, _yield$fetcher3, tafsirs;
2430
-
2431
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
2432
- while (1) {
2433
- switch (_context3.prev = _context3.next) {
2434
- case 0:
2435
- params = getResourcesOptions(options);
2436
- _context3.next = 3;
2437
- return fetcher('/resources/tafsirs', params);
2438
-
2439
- case 3:
2440
- _yield$fetcher3 = _context3.sent;
2441
- tafsirs = _yield$fetcher3.tafsirs;
2442
- return _context3.abrupt("return", tafsirs);
2443
-
2444
- case 6:
2445
- case "end":
2446
- return _context3.stop();
2447
- }
2448
- }
2449
- }, _callee3);
2450
- }));
2451
-
2452
- return function findAllTafsirs(_x3) {
2453
- return _ref3.apply(this, arguments);
2454
- };
2455
- }(); // TODO: uncomment when API is ready
2456
-
2457
- /**
2458
- * Get tafsir info.
2459
- * @description https://quran.api-docs.io/v4/resources/tafsirs-info
2460
- * @param {string} id tafsir id
2461
- * @param {GetResourceOptions} options
2462
- * @example
2463
- * quran.v4.resources.findTranslationInfo('1')
2464
- */
2465
- // const findTafsirInfo = async (id: string, options?: GetResourceOptions) => {
2466
- // const params = getResourcesOptions(options);
2467
- // const { info } = await fetcher<{
2468
- // info: TafsirInfoResource;
2469
- // }>(`/resources/tafsirs/${id}/info`, params);
2470
- // return info;
2471
- // };
2472
-
2473
- /**
2474
- * Get all recitation styles.
2475
- * @description https://quran.api-docs.io/v4/resources/recitation-styles
2476
- * @example
2477
- * quran.v4.resources.findAllRecitationStyles()
2478
- */
2479
-
2480
-
2481
- var findAllRecitationStyles = /*#__PURE__*/function () {
2482
- var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
2483
- var _yield$fetcher4, recitationStyles;
2484
-
2485
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
2486
- while (1) {
2487
- switch (_context4.prev = _context4.next) {
2488
- case 0:
2489
- _context4.next = 2;
2490
- return fetcher('/resources/recitation_styles');
2491
-
2492
- case 2:
2493
- _yield$fetcher4 = _context4.sent;
2494
- recitationStyles = _yield$fetcher4.recitationStyles;
2495
- return _context4.abrupt("return", recitationStyles);
2496
-
2497
- case 5:
2498
- case "end":
2499
- return _context4.stop();
2500
- }
2501
- }
2502
- }, _callee4);
2503
- }));
2504
-
2505
- return function findAllRecitationStyles() {
2506
- return _ref4.apply(this, arguments);
2507
- };
2508
- }();
2509
- /**
2510
- * Get all languages.
2511
- * @description https://quran.api-docs.io/v4/resources/languages
2512
- * @param {GetResourceOptions} options
2513
- * @example
2514
- * quran.v4.resources.findAllLanguages()
2515
- */
2516
-
2517
-
2518
- var findAllLanguages = /*#__PURE__*/function () {
2519
- var _ref5 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(options) {
2520
- var params, _yield$fetcher5, languages;
2521
-
2522
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
2523
- while (1) {
2524
- switch (_context5.prev = _context5.next) {
2525
- case 0:
2526
- params = getResourcesOptions(options);
2527
- _context5.next = 3;
2528
- return fetcher('/resources/languages', params);
2529
-
2530
- case 3:
2531
- _yield$fetcher5 = _context5.sent;
2532
- languages = _yield$fetcher5.languages;
2533
- return _context5.abrupt("return", languages);
2534
-
2535
- case 6:
2536
- case "end":
2537
- return _context5.stop();
2538
- }
2539
- }
2540
- }, _callee5);
2541
- }));
2542
-
2543
- return function findAllLanguages(_x4) {
2544
- return _ref5.apply(this, arguments);
2545
- };
2546
- }();
2547
- /**
2548
- * Get all chapter infos.
2549
- * @description https://quran.api-docs.io/v4/resources/chapter-info
2550
- * @param {GetResourceOptions} options
2551
- * @example
2552
- * quran.v4.resources.findAllChapterInfos()
2553
- */
2554
-
2555
-
2556
- var findAllChapterInfos = /*#__PURE__*/function () {
2557
- var _ref6 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(options) {
2558
- var params, _yield$fetcher6, chapterInfos;
2559
-
2560
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
2561
- while (1) {
2562
- switch (_context6.prev = _context6.next) {
2563
- case 0:
2564
- params = getResourcesOptions(options);
2565
- _context6.next = 3;
2566
- return fetcher('/resources/chapter_infos', params);
2567
-
2568
- case 3:
2569
- _yield$fetcher6 = _context6.sent;
2570
- chapterInfos = _yield$fetcher6.chapterInfos;
2571
- return _context6.abrupt("return", chapterInfos);
2572
-
2573
- case 6:
2574
- case "end":
2575
- return _context6.stop();
2576
- }
2577
- }
2578
- }, _callee6);
2579
- }));
2580
-
2581
- return function findAllChapterInfos(_x5) {
2582
- return _ref6.apply(this, arguments);
2583
- };
2584
- }();
2585
- /**
2586
- * Get verse media.
2587
- * @description https://quran.api-docs.io/v4/resources/verse_media
2588
- * @param {GetResourceOptions} options
2589
- * @example
2590
- * quran.v4.resources.findVerseMedia()
2591
- */
2592
-
2593
-
2594
- var findVerseMedia = /*#__PURE__*/function () {
2595
- var _ref7 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(options) {
2596
- var params, _yield$fetcher7, verseMedia;
2597
-
2598
- return _regeneratorRuntime.wrap(function _callee7$(_context7) {
2599
- while (1) {
2600
- switch (_context7.prev = _context7.next) {
2601
- case 0:
2602
- params = getResourcesOptions(options);
2603
- _context7.next = 3;
2604
- return fetcher("/resources/verse_media", params);
2605
-
2606
- case 3:
2607
- _yield$fetcher7 = _context7.sent;
2608
- verseMedia = _yield$fetcher7.verseMedia;
2609
- return _context7.abrupt("return", verseMedia);
2610
-
2611
- case 6:
2612
- case "end":
2613
- return _context7.stop();
2614
- }
2615
- }
2616
- }, _callee7);
2617
- }));
2618
-
2619
- return function findVerseMedia(_x6) {
2620
- return _ref7.apply(this, arguments);
2621
- };
2622
- }();
2623
- /**
2624
- * Get all chapter reciters.
2625
- * @description https://quran.api-docs.io/v4/resources/list-of-chapter-reciters
2626
- * @param {GetResourceOptions} options
2627
- * @example
2628
- * quran.v4.resources.findAllChapterReciters()
2629
- */
2630
-
2631
-
2632
- var findAllChapterReciters = /*#__PURE__*/function () {
2633
- var _ref8 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(options) {
2634
- var params, _yield$fetcher8, reciters;
2635
-
2636
- return _regeneratorRuntime.wrap(function _callee8$(_context8) {
2637
- while (1) {
2638
- switch (_context8.prev = _context8.next) {
2639
- case 0:
2640
- params = getResourcesOptions(options);
2641
- _context8.next = 3;
2642
- return fetcher("/resources/chapter_reciters", params);
2643
-
2644
- case 3:
2645
- _yield$fetcher8 = _context8.sent;
2646
- reciters = _yield$fetcher8.reciters;
2647
- return _context8.abrupt("return", reciters);
2648
-
2649
- case 6:
2650
- case "end":
2651
- return _context8.stop();
2652
- }
2653
- }
2654
- }, _callee8);
2655
- }));
2656
-
2657
- return function findAllChapterReciters(_x7) {
2658
- return _ref8.apply(this, arguments);
2659
- };
2660
- }();
2661
-
2662
- var resources = {
2663
- findAllRecitations: findAllRecitations,
2664
- findAllTranslations: findAllTranslations,
2665
- findAllTafsirs: findAllTafsirs,
2666
- findAllRecitationStyles: findAllRecitationStyles,
2667
- findAllLanguages: findAllLanguages,
2668
- findVerseMedia: findVerseMedia,
2669
- findAllChapterReciters: findAllChapterReciters,
2670
- findAllChapterInfos: findAllChapterInfos // findRecitationInfo
2671
- // findTranslationInfo
2672
- // findTafsirInfo
2673
-
2674
- };
2675
-
2676
- var defaultSearchOptions = {
2677
- language: exports.Language.ARABIC,
2678
- size: 30
2679
- };
2680
-
2681
- var getSearchOptions = function getSearchOptions(q, options) {
2682
- if (options === void 0) {
2683
- options = {};
2684
- }
2685
-
2686
- var all = _extends({}, defaultSearchOptions, options, {
2687
- q: q
2688
- });
2689
-
2690
- return all;
2691
- };
2692
- /**
2693
- * Search
2694
- * @description https://quran.api-docs.io/v4/search/KfCmk4KQYbtyK9adj
2695
- * @param {string} q search query
2696
- * @param {SearchOptions} options
2697
- * @example
2698
- * quran.v4.search.search('نور')
2699
- * quran.v4.search.search('نور', { language: Language.ENGLISH })
2700
- * quran.v4.search.search('نور', { language: Language.ENGLISH, size: 10 })
2701
- * quran.v4.search.search('نور', { language: Language.ENGLISH, page: 2 })
2702
- */
2703
-
2704
-
2705
- var search = /*#__PURE__*/function () {
2706
- var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(q, options) {
2707
- var params, _yield$fetcher, search;
2708
-
2709
- return _regeneratorRuntime.wrap(function _callee$(_context) {
2710
- while (1) {
2711
- switch (_context.prev = _context.next) {
2712
- case 0:
2713
- params = getSearchOptions(q, options);
2714
- _context.next = 3;
2715
- return fetcher('/search', params);
2716
-
2717
- case 3:
2718
- _yield$fetcher = _context.sent;
2719
- search = _yield$fetcher.search;
2720
- return _context.abrupt("return", search);
2721
-
2722
- case 6:
2723
- case "end":
2724
- return _context.stop();
2725
- }
2726
- }
2727
- }, _callee);
2728
- }));
2729
-
2730
- return function search(_x, _x2) {
2731
- return _ref.apply(this, arguments);
2732
- };
2733
- }();
2734
-
2735
- var searchApi = {
2736
- search: search
2737
- };
2738
-
2739
- var v4 = {
2740
- chapters: chapters,
2741
- verses: verses,
2742
- juzs: juzs,
2743
- audio: audio,
2744
- resources: resources,
2745
- search: searchApi
2746
- };
2747
-
2748
- var quran = {
2749
- v4: v4,
2750
- utils: Utils
2751
- };
2752
-
2753
- exports.quran = quran;
2754
- //# sourceMappingURL=api.cjs.development.js.map