@quranjs/api 1.0.1 → 1.0.2

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