1 | import _Symbol from "core-js-pure/features/symbol/index.js";
|
---|
2 | import _Symbol$asyncIterator from "core-js-pure/features/symbol/async-iterator.js";
|
---|
3 | import _Symbol$iterator from "core-js-pure/features/symbol/iterator.js";
|
---|
4 | import _Promise from "core-js-pure/features/promise/index.js";
|
---|
5 | export default function _asyncIterator(r) {
|
---|
6 | var n,
|
---|
7 | t,
|
---|
8 | o,
|
---|
9 | e = 2;
|
---|
10 | for ("undefined" != typeof _Symbol && (t = _Symbol$asyncIterator, o = _Symbol$iterator); e--;) {
|
---|
11 | if (t && null != (n = r[t])) return n.call(r);
|
---|
12 | if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r));
|
---|
13 | t = "@@asyncIterator", o = "@@iterator";
|
---|
14 | }
|
---|
15 | throw new TypeError("Object is not async iterable");
|
---|
16 | }
|
---|
17 | function AsyncFromSyncIterator(r) {
|
---|
18 | function AsyncFromSyncIteratorContinuation(r) {
|
---|
19 | if (Object(r) !== r) return _Promise.reject(new TypeError(r + " is not an object."));
|
---|
20 | var n = r.done;
|
---|
21 | return _Promise.resolve(r.value).then(function (r) {
|
---|
22 | return {
|
---|
23 | value: r,
|
---|
24 | done: n
|
---|
25 | };
|
---|
26 | });
|
---|
27 | }
|
---|
28 | return AsyncFromSyncIterator = function AsyncFromSyncIterator(r) {
|
---|
29 | this.s = r, this.n = r.next;
|
---|
30 | }, AsyncFromSyncIterator.prototype = {
|
---|
31 | s: null,
|
---|
32 | n: null,
|
---|
33 | next: function next() {
|
---|
34 | return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
|
---|
35 | },
|
---|
36 | "return": function _return(r) {
|
---|
37 | var n = this.s["return"];
|
---|
38 | return void 0 === n ? _Promise.resolve({
|
---|
39 | value: r,
|
---|
40 | done: !0
|
---|
41 | }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
---|
42 | },
|
---|
43 | "throw": function _throw(r) {
|
---|
44 | var n = this.s["return"];
|
---|
45 | return void 0 === n ? _Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
|
---|
46 | }
|
---|
47 | }, new AsyncFromSyncIterator(r);
|
---|
48 | } |
---|