1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | var runtime = (function (exports) {
|
9 | "use strict";
|
10 |
|
11 | var Op = Object.prototype;
|
12 | var hasOwn = Op.hasOwnProperty;
|
13 | var undefined;
|
14 | var $Symbol = typeof Symbol === "function" ? Symbol : {};
|
15 | var iteratorSymbol = $Symbol.iterator || "@@iterator";
|
16 | var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
|
17 | var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
18 |
|
19 | function wrap(innerFn, outerFn, self, tryLocsList) {
|
20 |
|
21 | var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
|
22 | var generator = Object.create(protoGenerator.prototype);
|
23 | var context = new Context(tryLocsList || []);
|
24 |
|
25 |
|
26 |
|
27 | generator._invoke = makeInvokeMethod(innerFn, self, context);
|
28 |
|
29 | return generator;
|
30 | }
|
31 | exports.wrap = wrap;
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 | function tryCatch(fn, obj, arg) {
|
44 | try {
|
45 | return { type: "normal", arg: fn.call(obj, arg) };
|
46 | } catch (err) {
|
47 | return { type: "throw", arg: err };
|
48 | }
|
49 | }
|
50 |
|
51 | var GenStateSuspendedStart = "suspendedStart";
|
52 | var GenStateSuspendedYield = "suspendedYield";
|
53 | var GenStateExecuting = "executing";
|
54 | var GenStateCompleted = "completed";
|
55 |
|
56 |
|
57 |
|
58 | var ContinueSentinel = {};
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 | function Generator() {}
|
65 | function GeneratorFunction() {}
|
66 | function GeneratorFunctionPrototype() {}
|
67 |
|
68 |
|
69 |
|
70 | var IteratorPrototype = {};
|
71 | IteratorPrototype[iteratorSymbol] = function () {
|
72 | return this;
|
73 | };
|
74 |
|
75 | var getProto = Object.getPrototypeOf;
|
76 | var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
77 | if (NativeIteratorPrototype &&
|
78 | NativeIteratorPrototype !== Op &&
|
79 | hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
|
80 |
|
81 |
|
82 | IteratorPrototype = NativeIteratorPrototype;
|
83 | }
|
84 |
|
85 | function ensureDefaultToStringTag(object, defaultValue) {
|
86 |
|
87 | return toStringTagSymbol in object
|
88 | ? object[toStringTagSymbol]
|
89 | : object[toStringTagSymbol] = defaultValue;
|
90 | }
|
91 |
|
92 | var Gp = GeneratorFunctionPrototype.prototype =
|
93 | Generator.prototype = Object.create(IteratorPrototype);
|
94 | GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
|
95 | GeneratorFunctionPrototype.constructor = GeneratorFunction;
|
96 | GeneratorFunction.displayName = ensureDefaultToStringTag(
|
97 | GeneratorFunctionPrototype,
|
98 | "GeneratorFunction"
|
99 | );
|
100 |
|
101 |
|
102 |
|
103 | function defineIteratorMethods(prototype) {
|
104 | ["next", "throw", "return"].forEach(function(method) {
|
105 | prototype[method] = function(arg) {
|
106 | return this._invoke(method, arg);
|
107 | };
|
108 | });
|
109 | }
|
110 |
|
111 | exports.isGeneratorFunction = function(genFun) {
|
112 | var ctor = typeof genFun === "function" && genFun.constructor;
|
113 | return ctor
|
114 | ? ctor === GeneratorFunction ||
|
115 |
|
116 |
|
117 | (ctor.displayName || ctor.name) === "GeneratorFunction"
|
118 | : false;
|
119 | };
|
120 |
|
121 | exports.mark = function(genFun) {
|
122 | if (Object.setPrototypeOf) {
|
123 | Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
|
124 | } else {
|
125 | genFun.__proto__ = GeneratorFunctionPrototype;
|
126 | ensureDefaultToStringTag(genFun, "GeneratorFunction");
|
127 | }
|
128 | genFun.prototype = Object.create(Gp);
|
129 | return genFun;
|
130 | };
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 | exports.awrap = function(arg) {
|
137 | return { __await: arg };
|
138 | };
|
139 |
|
140 | function AsyncIterator(generator, PromiseImpl) {
|
141 | function invoke(method, arg, resolve, reject) {
|
142 | var record = tryCatch(generator[method], generator, arg);
|
143 | if (record.type === "throw") {
|
144 | reject(record.arg);
|
145 | } else {
|
146 | var result = record.arg;
|
147 | var value = result.value;
|
148 | if (value &&
|
149 | typeof value === "object" &&
|
150 | hasOwn.call(value, "__await")) {
|
151 | return PromiseImpl.resolve(value.__await).then(function(value) {
|
152 | invoke("next", value, resolve, reject);
|
153 | }, function(err) {
|
154 | invoke("throw", err, resolve, reject);
|
155 | });
|
156 | }
|
157 |
|
158 | return PromiseImpl.resolve(value).then(function(unwrapped) {
|
159 |
|
160 |
|
161 |
|
162 | result.value = unwrapped;
|
163 | resolve(result);
|
164 | }, function(error) {
|
165 |
|
166 |
|
167 | return invoke("throw", error, resolve, reject);
|
168 | });
|
169 | }
|
170 | }
|
171 |
|
172 | var previousPromise;
|
173 |
|
174 | function enqueue(method, arg) {
|
175 | function callInvokeWithMethodAndArg() {
|
176 | return new PromiseImpl(function(resolve, reject) {
|
177 | invoke(method, arg, resolve, reject);
|
178 | });
|
179 | }
|
180 |
|
181 | return previousPromise =
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 |
|
194 | previousPromise ? previousPromise.then(
|
195 | callInvokeWithMethodAndArg,
|
196 |
|
197 |
|
198 | callInvokeWithMethodAndArg
|
199 | ) : callInvokeWithMethodAndArg();
|
200 | }
|
201 |
|
202 |
|
203 |
|
204 | this._invoke = enqueue;
|
205 | }
|
206 |
|
207 | defineIteratorMethods(AsyncIterator.prototype);
|
208 | AsyncIterator.prototype[asyncIteratorSymbol] = function () {
|
209 | return this;
|
210 | };
|
211 | exports.AsyncIterator = AsyncIterator;
|
212 |
|
213 |
|
214 |
|
215 |
|
216 | exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
217 | if (PromiseImpl === void 0) PromiseImpl = Promise;
|
218 |
|
219 | var iter = new AsyncIterator(
|
220 | wrap(innerFn, outerFn, self, tryLocsList),
|
221 | PromiseImpl
|
222 | );
|
223 |
|
224 | return exports.isGeneratorFunction(outerFn)
|
225 | ? iter
|
226 | : iter.next().then(function(result) {
|
227 | return result.done ? result.value : iter.next();
|
228 | });
|
229 | };
|
230 |
|
231 | function makeInvokeMethod(innerFn, self, context) {
|
232 | var state = GenStateSuspendedStart;
|
233 |
|
234 | return function invoke(method, arg) {
|
235 | if (state === GenStateExecuting) {
|
236 | throw new Error("Generator is already running");
|
237 | }
|
238 |
|
239 | if (state === GenStateCompleted) {
|
240 | if (method === "throw") {
|
241 | throw arg;
|
242 | }
|
243 |
|
244 |
|
245 |
|
246 | return doneResult();
|
247 | }
|
248 |
|
249 | context.method = method;
|
250 | context.arg = arg;
|
251 |
|
252 | while (true) {
|
253 | var delegate = context.delegate;
|
254 | if (delegate) {
|
255 | var delegateResult = maybeInvokeDelegate(delegate, context);
|
256 | if (delegateResult) {
|
257 | if (delegateResult === ContinueSentinel) continue;
|
258 | return delegateResult;
|
259 | }
|
260 | }
|
261 |
|
262 | if (context.method === "next") {
|
263 |
|
264 |
|
265 | context.sent = context._sent = context.arg;
|
266 |
|
267 | } else if (context.method === "throw") {
|
268 | if (state === GenStateSuspendedStart) {
|
269 | state = GenStateCompleted;
|
270 | throw context.arg;
|
271 | }
|
272 |
|
273 | context.dispatchException(context.arg);
|
274 |
|
275 | } else if (context.method === "return") {
|
276 | context.abrupt("return", context.arg);
|
277 | }
|
278 |
|
279 | state = GenStateExecuting;
|
280 |
|
281 | var record = tryCatch(innerFn, self, context);
|
282 | if (record.type === "normal") {
|
283 |
|
284 |
|
285 | state = context.done
|
286 | ? GenStateCompleted
|
287 | : GenStateSuspendedYield;
|
288 |
|
289 | if (record.arg === ContinueSentinel) {
|
290 | continue;
|
291 | }
|
292 |
|
293 | return {
|
294 | value: record.arg,
|
295 | done: context.done
|
296 | };
|
297 |
|
298 | } else if (record.type === "throw") {
|
299 | state = GenStateCompleted;
|
300 |
|
301 |
|
302 | context.method = "throw";
|
303 | context.arg = record.arg;
|
304 | }
|
305 | }
|
306 | };
|
307 | }
|
308 |
|
309 |
|
310 |
|
311 |
|
312 |
|
313 | function maybeInvokeDelegate(delegate, context) {
|
314 | var method = delegate.iterator[context.method];
|
315 | if (method === undefined) {
|
316 |
|
317 |
|
318 | context.delegate = null;
|
319 |
|
320 | if (context.method === "throw") {
|
321 |
|
322 | if (delegate.iterator["return"]) {
|
323 |
|
324 |
|
325 | context.method = "return";
|
326 | context.arg = undefined;
|
327 | maybeInvokeDelegate(delegate, context);
|
328 |
|
329 | if (context.method === "throw") {
|
330 |
|
331 |
|
332 | return ContinueSentinel;
|
333 | }
|
334 | }
|
335 |
|
336 | context.method = "throw";
|
337 | context.arg = new TypeError(
|
338 | "The iterator does not provide a 'throw' method");
|
339 | }
|
340 |
|
341 | return ContinueSentinel;
|
342 | }
|
343 |
|
344 | var record = tryCatch(method, delegate.iterator, context.arg);
|
345 |
|
346 | if (record.type === "throw") {
|
347 | context.method = "throw";
|
348 | context.arg = record.arg;
|
349 | context.delegate = null;
|
350 | return ContinueSentinel;
|
351 | }
|
352 |
|
353 | var info = record.arg;
|
354 |
|
355 | if (! info) {
|
356 | context.method = "throw";
|
357 | context.arg = new TypeError("iterator result is not an object");
|
358 | context.delegate = null;
|
359 | return ContinueSentinel;
|
360 | }
|
361 |
|
362 | if (info.done) {
|
363 |
|
364 |
|
365 | context[delegate.resultName] = info.value;
|
366 |
|
367 |
|
368 | context.next = delegate.nextLoc;
|
369 |
|
370 |
|
371 |
|
372 |
|
373 |
|
374 |
|
375 |
|
376 | if (context.method !== "return") {
|
377 | context.method = "next";
|
378 | context.arg = undefined;
|
379 | }
|
380 |
|
381 | } else {
|
382 |
|
383 | return info;
|
384 | }
|
385 |
|
386 |
|
387 |
|
388 | context.delegate = null;
|
389 | return ContinueSentinel;
|
390 | }
|
391 |
|
392 |
|
393 |
|
394 | defineIteratorMethods(Gp);
|
395 |
|
396 | ensureDefaultToStringTag(Gp, "Generator");
|
397 |
|
398 |
|
399 |
|
400 |
|
401 |
|
402 |
|
403 | Gp[iteratorSymbol] = function() {
|
404 | return this;
|
405 | };
|
406 |
|
407 | Gp.toString = function() {
|
408 | return "[object Generator]";
|
409 | };
|
410 |
|
411 | function pushTryEntry(locs) {
|
412 | var entry = { tryLoc: locs[0] };
|
413 |
|
414 | if (1 in locs) {
|
415 | entry.catchLoc = locs[1];
|
416 | }
|
417 |
|
418 | if (2 in locs) {
|
419 | entry.finallyLoc = locs[2];
|
420 | entry.afterLoc = locs[3];
|
421 | }
|
422 |
|
423 | this.tryEntries.push(entry);
|
424 | }
|
425 |
|
426 | function resetTryEntry(entry) {
|
427 | var record = entry.completion || {};
|
428 | record.type = "normal";
|
429 | delete record.arg;
|
430 | entry.completion = record;
|
431 | }
|
432 |
|
433 | function Context(tryLocsList) {
|
434 |
|
435 |
|
436 |
|
437 | this.tryEntries = [{ tryLoc: "root" }];
|
438 | tryLocsList.forEach(pushTryEntry, this);
|
439 | this.reset(true);
|
440 | }
|
441 |
|
442 | exports.keys = function(object) {
|
443 | var keys = [];
|
444 | for (var key in object) {
|
445 | keys.push(key);
|
446 | }
|
447 | keys.reverse();
|
448 |
|
449 |
|
450 |
|
451 | return function next() {
|
452 | while (keys.length) {
|
453 | var key = keys.pop();
|
454 | if (key in object) {
|
455 | next.value = key;
|
456 | next.done = false;
|
457 | return next;
|
458 | }
|
459 | }
|
460 |
|
461 |
|
462 |
|
463 |
|
464 | next.done = true;
|
465 | return next;
|
466 | };
|
467 | };
|
468 |
|
469 | function values(iterable) {
|
470 | if (iterable) {
|
471 | var iteratorMethod = iterable[iteratorSymbol];
|
472 | if (iteratorMethod) {
|
473 | return iteratorMethod.call(iterable);
|
474 | }
|
475 |
|
476 | if (typeof iterable.next === "function") {
|
477 | return iterable;
|
478 | }
|
479 |
|
480 | if (!isNaN(iterable.length)) {
|
481 | var i = -1, next = function next() {
|
482 | while (++i < iterable.length) {
|
483 | if (hasOwn.call(iterable, i)) {
|
484 | next.value = iterable[i];
|
485 | next.done = false;
|
486 | return next;
|
487 | }
|
488 | }
|
489 |
|
490 | next.value = undefined;
|
491 | next.done = true;
|
492 |
|
493 | return next;
|
494 | };
|
495 |
|
496 | return next.next = next;
|
497 | }
|
498 | }
|
499 |
|
500 |
|
501 | return { next: doneResult };
|
502 | }
|
503 | exports.values = values;
|
504 |
|
505 | function doneResult() {
|
506 | return { value: undefined, done: true };
|
507 | }
|
508 |
|
509 | Context.prototype = {
|
510 | constructor: Context,
|
511 |
|
512 | reset: function(skipTempReset) {
|
513 | this.prev = 0;
|
514 | this.next = 0;
|
515 |
|
516 |
|
517 | this.sent = this._sent = undefined;
|
518 | this.done = false;
|
519 | this.delegate = null;
|
520 |
|
521 | this.method = "next";
|
522 | this.arg = undefined;
|
523 |
|
524 | this.tryEntries.forEach(resetTryEntry);
|
525 |
|
526 | if (!skipTempReset) {
|
527 | for (var name in this) {
|
528 |
|
529 | if (name.charAt(0) === "t" &&
|
530 | hasOwn.call(this, name) &&
|
531 | !isNaN(+name.slice(1))) {
|
532 | this[name] = undefined;
|
533 | }
|
534 | }
|
535 | }
|
536 | },
|
537 |
|
538 | stop: function() {
|
539 | this.done = true;
|
540 |
|
541 | var rootEntry = this.tryEntries[0];
|
542 | var rootRecord = rootEntry.completion;
|
543 | if (rootRecord.type === "throw") {
|
544 | throw rootRecord.arg;
|
545 | }
|
546 |
|
547 | return this.rval;
|
548 | },
|
549 |
|
550 | dispatchException: function(exception) {
|
551 | if (this.done) {
|
552 | throw exception;
|
553 | }
|
554 |
|
555 | var context = this;
|
556 | function handle(loc, caught) {
|
557 | record.type = "throw";
|
558 | record.arg = exception;
|
559 | context.next = loc;
|
560 |
|
561 | if (caught) {
|
562 |
|
563 |
|
564 | context.method = "next";
|
565 | context.arg = undefined;
|
566 | }
|
567 |
|
568 | return !! caught;
|
569 | }
|
570 |
|
571 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
572 | var entry = this.tryEntries[i];
|
573 | var record = entry.completion;
|
574 |
|
575 | if (entry.tryLoc === "root") {
|
576 |
|
577 |
|
578 |
|
579 | return handle("end");
|
580 | }
|
581 |
|
582 | if (entry.tryLoc <= this.prev) {
|
583 | var hasCatch = hasOwn.call(entry, "catchLoc");
|
584 | var hasFinally = hasOwn.call(entry, "finallyLoc");
|
585 |
|
586 | if (hasCatch && hasFinally) {
|
587 | if (this.prev < entry.catchLoc) {
|
588 | return handle(entry.catchLoc, true);
|
589 | } else if (this.prev < entry.finallyLoc) {
|
590 | return handle(entry.finallyLoc);
|
591 | }
|
592 |
|
593 | } else if (hasCatch) {
|
594 | if (this.prev < entry.catchLoc) {
|
595 | return handle(entry.catchLoc, true);
|
596 | }
|
597 |
|
598 | } else if (hasFinally) {
|
599 | if (this.prev < entry.finallyLoc) {
|
600 | return handle(entry.finallyLoc);
|
601 | }
|
602 |
|
603 | } else {
|
604 | throw new Error("try statement without catch or finally");
|
605 | }
|
606 | }
|
607 | }
|
608 | },
|
609 |
|
610 | abrupt: function(type, arg) {
|
611 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
612 | var entry = this.tryEntries[i];
|
613 | if (entry.tryLoc <= this.prev &&
|
614 | hasOwn.call(entry, "finallyLoc") &&
|
615 | this.prev < entry.finallyLoc) {
|
616 | var finallyEntry = entry;
|
617 | break;
|
618 | }
|
619 | }
|
620 |
|
621 | if (finallyEntry &&
|
622 | (type === "break" ||
|
623 | type === "continue") &&
|
624 | finallyEntry.tryLoc <= arg &&
|
625 | arg <= finallyEntry.finallyLoc) {
|
626 |
|
627 |
|
628 | finallyEntry = null;
|
629 | }
|
630 |
|
631 | var record = finallyEntry ? finallyEntry.completion : {};
|
632 | record.type = type;
|
633 | record.arg = arg;
|
634 |
|
635 | if (finallyEntry) {
|
636 | this.method = "next";
|
637 | this.next = finallyEntry.finallyLoc;
|
638 | return ContinueSentinel;
|
639 | }
|
640 |
|
641 | return this.complete(record);
|
642 | },
|
643 |
|
644 | complete: function(record, afterLoc) {
|
645 | if (record.type === "throw") {
|
646 | throw record.arg;
|
647 | }
|
648 |
|
649 | if (record.type === "break" ||
|
650 | record.type === "continue") {
|
651 | this.next = record.arg;
|
652 | } else if (record.type === "return") {
|
653 | this.rval = this.arg = record.arg;
|
654 | this.method = "return";
|
655 | this.next = "end";
|
656 | } else if (record.type === "normal" && afterLoc) {
|
657 | this.next = afterLoc;
|
658 | }
|
659 |
|
660 | return ContinueSentinel;
|
661 | },
|
662 |
|
663 | finish: function(finallyLoc) {
|
664 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
665 | var entry = this.tryEntries[i];
|
666 | if (entry.finallyLoc === finallyLoc) {
|
667 | this.complete(entry.completion, entry.afterLoc);
|
668 | resetTryEntry(entry);
|
669 | return ContinueSentinel;
|
670 | }
|
671 | }
|
672 | },
|
673 |
|
674 | "catch": function(tryLoc) {
|
675 | for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
676 | var entry = this.tryEntries[i];
|
677 | if (entry.tryLoc === tryLoc) {
|
678 | var record = entry.completion;
|
679 | if (record.type === "throw") {
|
680 | var thrown = record.arg;
|
681 | resetTryEntry(entry);
|
682 | }
|
683 | return thrown;
|
684 | }
|
685 | }
|
686 |
|
687 |
|
688 |
|
689 | throw new Error("illegal catch attempt");
|
690 | },
|
691 |
|
692 | delegateYield: function(iterable, resultName, nextLoc) {
|
693 | this.delegate = {
|
694 | iterator: values(iterable),
|
695 | resultName: resultName,
|
696 | nextLoc: nextLoc
|
697 | };
|
698 |
|
699 | if (this.method === "next") {
|
700 |
|
701 |
|
702 | this.arg = undefined;
|
703 | }
|
704 |
|
705 | return ContinueSentinel;
|
706 | }
|
707 | };
|
708 |
|
709 |
|
710 |
|
711 |
|
712 |
|
713 | return exports;
|
714 |
|
715 | }(
|
716 |
|
717 |
|
718 |
|
719 |
|
720 | typeof module === "object" ? module.exports : {}
|
721 | ));
|
722 |
|
723 | try {
|
724 | regeneratorRuntime = runtime;
|
725 | } catch (accidentalStrictMode) {
|
726 |
|
727 |
|
728 |
|
729 |
|
730 |
|
731 |
|
732 |
|
733 |
|
734 |
|
735 | Function("r", "regeneratorRuntime = r")(runtime);
|
736 | }
|