regeneratorRuntime.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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 methodName = context.method,
  139. method = delegate.iterator[methodName];
  140. if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
  141. var record = tryCatch(method, delegate.iterator, context.arg);
  142. if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
  143. var info = record.arg;
  144. 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);
  145. }
  146. function pushTryEntry(locs) {
  147. var entry = {
  148. tryLoc: locs[0]
  149. };
  150. 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
  151. }
  152. function resetTryEntry(entry) {
  153. var record = entry.completion || {};
  154. record.type = "normal", delete record.arg, entry.completion = record;
  155. }
  156. function Context(tryLocsList) {
  157. this.tryEntries = [{
  158. tryLoc: "root"
  159. }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
  160. }
  161. function values(iterable) {
  162. if (iterable) {
  163. var iteratorMethod = iterable[iteratorSymbol];
  164. if (iteratorMethod) return iteratorMethod.call(iterable);
  165. if ("function" == typeof iterable.next) return iterable;
  166. if (!isNaN(iterable.length)) {
  167. var i = -1,
  168. next = function next() {
  169. for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
  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, defineProperty(Gp, "constructor", {
  186. value: GeneratorFunctionPrototype,
  187. configurable: !0
  188. }), defineProperty(GeneratorFunctionPrototype, "constructor", {
  189. value: GeneratorFunction,
  190. configurable: !0
  191. }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
  192. var ctor = "function" == typeof genFun && genFun.constructor;
  193. return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
  194. }, exports.mark = function (genFun) {
  195. return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
  196. }, exports.awrap = function (arg) {
  197. return {
  198. __await: arg
  199. };
  200. }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  201. return this;
  202. }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  203. void 0 === PromiseImpl && (PromiseImpl = Promise);
  204. var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
  205. return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
  206. return result.done ? result.value : iter.next();
  207. });
  208. }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
  209. return this;
  210. }), define(Gp, "toString", function () {
  211. return "[object Generator]";
  212. }), exports.keys = function (val) {
  213. var object = Object(val),
  214. keys = [];
  215. for (var key in object) keys.push(key);
  216. return keys.reverse(), function next() {
  217. for (; keys.length;) {
  218. var key = keys.pop();
  219. if (key in object) return next.value = key, next.done = !1, next;
  220. }
  221. return next.done = !0, next;
  222. };
  223. }, exports.values = values, Context.prototype = {
  224. constructor: Context,
  225. reset: function reset(skipTempReset) {
  226. 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) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
  227. },
  228. stop: function stop() {
  229. this.done = !0;
  230. var rootRecord = this.tryEntries[0].completion;
  231. if ("throw" === rootRecord.type) throw rootRecord.arg;
  232. return this.rval;
  233. },
  234. dispatchException: function dispatchException(exception) {
  235. if (this.done) throw exception;
  236. var context = this;
  237. function handle(loc, caught) {
  238. return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
  239. }
  240. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  241. var entry = this.tryEntries[i],
  242. record = entry.completion;
  243. if ("root" === entry.tryLoc) return handle("end");
  244. if (entry.tryLoc <= this.prev) {
  245. var hasCatch = hasOwn.call(entry, "catchLoc"),
  246. hasFinally = hasOwn.call(entry, "finallyLoc");
  247. if (hasCatch && hasFinally) {
  248. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  249. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  250. } else if (hasCatch) {
  251. if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
  252. } else {
  253. if (!hasFinally) throw new Error("try statement without catch or finally");
  254. if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
  255. }
  256. }
  257. }
  258. },
  259. abrupt: function abrupt(type, arg) {
  260. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  261. var entry = this.tryEntries[i];
  262. if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
  263. var finallyEntry = entry;
  264. break;
  265. }
  266. }
  267. finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
  268. var record = finallyEntry ? finallyEntry.completion : {};
  269. return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
  270. },
  271. complete: function complete(record, afterLoc) {
  272. if ("throw" === record.type) throw record.arg;
  273. 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;
  274. },
  275. finish: function finish(finallyLoc) {
  276. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  277. var entry = this.tryEntries[i];
  278. if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
  279. }
  280. },
  281. "catch": function _catch(tryLoc) {
  282. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  283. var entry = this.tryEntries[i];
  284. if (entry.tryLoc === tryLoc) {
  285. var record = entry.completion;
  286. if ("throw" === record.type) {
  287. var thrown = record.arg;
  288. resetTryEntry(entry);
  289. }
  290. return thrown;
  291. }
  292. }
  293. throw new Error("illegal catch attempt");
  294. },
  295. delegateYield: function delegateYield(iterable, resultName, nextLoc) {
  296. return this.delegate = {
  297. iterator: values(iterable),
  298. resultName: resultName,
  299. nextLoc: nextLoc
  300. }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
  301. }
  302. }, exports;
  303. }
  304. module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;