regeneratorRuntime.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. var _typeof = require("./typeof.js")["default"];
  2. function _regeneratorRuntime() {
  3. "use strict";
  4. /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
  5. module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
  6. return exports;
  7. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  8. var exports = {},
  9. Op = Object.prototype,
  10. hasOwn = Op.hasOwnProperty,
  11. $Symbol = "function" == typeof Symbol ? Symbol : {},
  12. iteratorSymbol = $Symbol.iterator || "@@iterator",
  13. asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
  14. toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  15. function define(obj, key, value) {
  16. return Object.defineProperty(obj, key, {
  17. value: value,
  18. enumerable: !0,
  19. configurable: !0,
  20. writable: !0
  21. }), obj[key];
  22. }
  23. try {
  24. define({}, "");
  25. } catch (err) {
  26. define = function define(obj, key, value) {
  27. return obj[key] = value;
  28. };
  29. }
  30. function wrap(innerFn, outerFn, self, tryLocsList) {
  31. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
  32. generator = Object.create(protoGenerator.prototype),
  33. context = new Context(tryLocsList || []);
  34. return generator._invoke = function (innerFn, self, context) {
  35. var state = "suspendedStart";
  36. return function (method, arg) {
  37. if ("executing" === state) throw new Error("Generator is already running");
  38. if ("completed" === state) {
  39. if ("throw" === method) throw arg;
  40. return doneResult();
  41. }
  42. for (context.method = method, context.arg = arg;;) {
  43. var delegate = context.delegate;
  44. if (delegate) {
  45. var delegateResult = maybeInvokeDelegate(delegate, context);
  46. if (delegateResult) {
  47. if (delegateResult === ContinueSentinel) continue;
  48. return delegateResult;
  49. }
  50. }
  51. if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
  52. if ("suspendedStart" === state) throw state = "completed", context.arg;
  53. context.dispatchException(context.arg);
  54. } else "return" === context.method && context.abrupt("return", context.arg);
  55. state = "executing";
  56. var record = tryCatch(innerFn, self, context);
  57. if ("normal" === record.type) {
  58. if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
  59. return {
  60. value: record.arg,
  61. done: context.done
  62. };
  63. }
  64. "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
  65. }
  66. };
  67. }(innerFn, self, context), generator;
  68. }
  69. function tryCatch(fn, obj, arg) {
  70. try {
  71. return {
  72. type: "normal",
  73. arg: fn.call(obj, arg)
  74. };
  75. } catch (err) {
  76. return {
  77. type: "throw",
  78. arg: err
  79. };
  80. }
  81. }
  82. exports.wrap = wrap;
  83. var ContinueSentinel = {};
  84. function Generator() {}
  85. function GeneratorFunction() {}
  86. function GeneratorFunctionPrototype() {}
  87. var IteratorPrototype = {};
  88. define(IteratorPrototype, iteratorSymbol, function () {
  89. return this;
  90. });
  91. var getProto = Object.getPrototypeOf,
  92. NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  93. NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
  94. var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
  95. function defineIteratorMethods(prototype) {
  96. ["next", "throw", "return"].forEach(function (method) {
  97. define(prototype, method, function (arg) {
  98. return this._invoke(method, arg);
  99. });
  100. });
  101. }
  102. function AsyncIterator(generator, PromiseImpl) {
  103. function invoke(method, arg, resolve, reject) {
  104. var record = tryCatch(generator[method], generator, arg);
  105. if ("throw" !== record.type) {
  106. var result = record.arg,
  107. value = result.value;
  108. return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
  109. invoke("next", value, resolve, reject);
  110. }, function (err) {
  111. invoke("throw", err, resolve, reject);
  112. }) : PromiseImpl.resolve(value).then(function (unwrapped) {
  113. result.value = unwrapped, resolve(result);
  114. }, function (error) {
  115. return invoke("throw", error, resolve, reject);
  116. });
  117. }
  118. reject(record.arg);
  119. }
  120. var previousPromise;
  121. this._invoke = function (method, arg) {
  122. function callInvokeWithMethodAndArg() {
  123. return new PromiseImpl(function (resolve, reject) {
  124. invoke(method, arg, resolve, reject);
  125. });
  126. }
  127. return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  128. };
  129. }
  130. function maybeInvokeDelegate(delegate, context) {
  131. var method = delegate.iterator[context.method];
  132. if (undefined === method) {
  133. if (context.delegate = null, "throw" === context.method) {
  134. if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
  135. context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
  136. }
  137. return ContinueSentinel;
  138. }
  139. var record = tryCatch(method, delegate.iterator, context.arg);
  140. if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
  141. var info = record.arg;
  142. return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
  143. }
  144. function pushTryEntry(locs) {
  145. var entry = {
  146. tryLoc: locs[0]
  147. };
  148. 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
  149. }
  150. function resetTryEntry(entry) {
  151. var record = entry.completion || {};
  152. record.type = "normal", delete record.arg, entry.completion = record;
  153. }
  154. function Context(tryLocsList) {
  155. this.tryEntries = [{
  156. tryLoc: "root"
  157. }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
  158. }
  159. function values(iterable) {
  160. if (iterable) {
  161. var iteratorMethod = iterable[iteratorSymbol];
  162. if (iteratorMethod) return iteratorMethod.call(iterable);
  163. if ("function" == typeof iterable.next) return iterable;
  164. if (!isNaN(iterable.length)) {
  165. var i = -1,
  166. next = function next() {
  167. for (; ++i < iterable.length;) {
  168. if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
  169. }
  170. return next.value = undefined, next.done = !0, next;
  171. };
  172. return next.next = next;
  173. }
  174. }
  175. return {
  176. next: doneResult
  177. };
  178. }
  179. function doneResult() {
  180. return {
  181. value: undefined,
  182. done: !0
  183. };
  184. }
  185. return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
  186. var ctor = "function" == typeof genFun && genFun.constructor;
  187. return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
  188. }, exports.mark = function (genFun) {
  189. return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
  190. }, exports.awrap = function (arg) {
  191. return {
  192. __await: arg
  193. };
  194. }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  195. return this;
  196. }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  197. void 0 === PromiseImpl && (PromiseImpl = Promise);
  198. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  199. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  200. return result.done ? result.value : iter.next();
  201. });
  202. }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
  203. return this;
  204. }), define(Gp, "toString", function () {
  205. return "[object Generator]";
  206. }), exports.keys = function (object) {
  207. var keys = [];
  208. for (var key in object) {
  209. keys.push(key);
  210. }
  211. return keys.reverse(), function next() {
  212. for (; keys.length;) {
  213. var key = keys.pop();
  214. if (key in object) return next.value = key, next.done = !1, next;
  215. }
  216. return next.done = !0, next;
  217. };
  218. }, exports.values = values, Context.prototype = {
  219. constructor: Context,
  220. reset: function reset(skipTempReset) {
  221. if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
  222. "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
  223. }
  224. },
  225. stop: function stop() {
  226. this.done = !0;
  227. var rootRecord = this.tryEntries[0].completion;
  228. if ("throw" === rootRecord.type) throw rootRecord.arg;
  229. return this.rval;
  230. },
  231. dispatchException: function dispatchException(exception) {
  232. if (this.done) throw exception;
  233. var context = this;
  234. function handle(loc, caught) {
  235. return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
  236. }
  237. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  238. var entry = this.tryEntries[i],
  239. record = entry.completion;
  240. if ("root" === entry.tryLoc) return handle("end");
  241. if (entry.tryLoc <= this.prev) {
  242. var hasCatch = hasOwn.call(entry, "catchLoc"),
  243. hasFinally = hasOwn.call(entry, "finallyLoc");
  244. if (hasCatch && hasFinally) {
  245. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  246. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  247. } else if (hasCatch) {
  248. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  249. } else {
  250. if (!hasFinally) throw new Error("try statement without catch or finally");
  251. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  252. }
  253. }
  254. }
  255. },
  256. abrupt: function abrupt(type, arg) {
  257. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  258. var entry = this.tryEntries[i];
  259. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  260. var finallyEntry = entry;
  261. break;
  262. }
  263. }
  264. finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
  265. var record = finallyEntry ? finallyEntry.completion : {};
  266. return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
  267. },
  268. complete: function complete(record, afterLoc) {
  269. if ("throw" === record.type) throw record.arg;
  270. return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
  271. },
  272. finish: function finish(finallyLoc) {
  273. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  274. var entry = this.tryEntries[i];
  275. if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
  276. }
  277. },
  278. "catch": function _catch(tryLoc) {
  279. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  280. var entry = this.tryEntries[i];
  281. if (entry.tryLoc === tryLoc) {
  282. var record = entry.completion;
  283. if ("throw" === record.type) {
  284. var thrown = record.arg;
  285. resetTryEntry(entry);
  286. }
  287. return thrown;
  288. }
  289. }
  290. throw new Error("illegal catch attempt");
  291. },
  292. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  293. return this.delegate = {
  294. iterator: values(iterable),
  295. resultName: resultName,
  296. nextLoc: nextLoc
  297. }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
  298. }
  299. }, exports;
  300. }
  301. module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;