regeneratorRuntime.js 14 KB

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