runtime.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  1. /**
  2. * Copyright (c) 2014-present, Facebook, Inc.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. var runtime = (function (exports) {
  8. "use strict";
  9. var Op = Object.prototype;
  10. var hasOwn = Op.hasOwnProperty;
  11. var defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; };
  12. var undefined; // More compressible than void 0.
  13. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  14. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  15. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  16. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  17. function define(obj, key, value) {
  18. Object.defineProperty(obj, key, {
  19. value: value,
  20. enumerable: true,
  21. configurable: true,
  22. writable: true
  23. });
  24. return obj[key];
  25. }
  26. try {
  27. // IE 8 has a broken Object.defineProperty that only works on DOM objects.
  28. define({}, "");
  29. } catch (err) {
  30. define = function(obj, key, value) {
  31. return obj[key] = value;
  32. };
  33. }
  34. function wrap(innerFn, outerFn, self, tryLocsList) {
  35. // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
  36. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  37. var generator = Object.create(protoGenerator.prototype);
  38. var context = new Context(tryLocsList || []);
  39. // The ._invoke method unifies the implementations of the .next,
  40. // .throw, and .return methods.
  41. defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) });
  42. return generator;
  43. }
  44. exports.wrap = wrap;
  45. // Try/catch helper to minimize deoptimizations. Returns a completion
  46. // record like context.tryEntries[i].completion. This interface could
  47. // have been (and was previously) designed to take a closure to be
  48. // invoked without arguments, but in all the cases we care about we
  49. // already have an existing method we want to call, so there's no need
  50. // to create a new function object. We can even get away with assuming
  51. // the method takes exactly one argument, since that happens to be true
  52. // in every case, so we don't have to touch the arguments object. The
  53. // only additional allocation required is the completion record, which
  54. // has a stable shape and so hopefully should be cheap to allocate.
  55. function tryCatch(fn, obj, arg) {
  56. try {
  57. return { type: "normal", arg: fn.call(obj, arg) };
  58. } catch (err) {
  59. return { type: "throw", arg: err };
  60. }
  61. }
  62. var GenStateSuspendedStart = "suspendedStart";
  63. var GenStateSuspendedYield = "suspendedYield";
  64. var GenStateExecuting = "executing";
  65. var GenStateCompleted = "completed";
  66. // Returning this object from the innerFn has the same effect as
  67. // breaking out of the dispatch switch statement.
  68. var ContinueSentinel = {};
  69. // Dummy constructor functions that we use as the .constructor and
  70. // .constructor.prototype properties for functions that return Generator
  71. // objects. For full spec compliance, you may wish to configure your
  72. // minifier not to mangle the names of these two functions.
  73. function Generator() {}
  74. function GeneratorFunction() {}
  75. function GeneratorFunctionPrototype() {}
  76. // This is a polyfill for %IteratorPrototype% for environments that
  77. // don't natively support it.
  78. var IteratorPrototype = {};
  79. define(IteratorPrototype, iteratorSymbol, function () {
  80. return this;
  81. });
  82. var getProto = Object.getPrototypeOf;
  83. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  84. if (NativeIteratorPrototype &&
  85. NativeIteratorPrototype !== Op &&
  86. hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  87. // This environment has a native %IteratorPrototype%; use it instead
  88. // of the polyfill.
  89. IteratorPrototype = NativeIteratorPrototype;
  90. }
  91. var Gp = GeneratorFunctionPrototype.prototype =
  92. Generator.prototype = Object.create(IteratorPrototype);
  93. GeneratorFunction.prototype = GeneratorFunctionPrototype;
  94. defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: true });
  95. defineProperty(
  96. GeneratorFunctionPrototype,
  97. "constructor",
  98. { value: GeneratorFunction, configurable: true }
  99. );
  100. GeneratorFunction.displayName = define(
  101. GeneratorFunctionPrototype,
  102. toStringTagSymbol,
  103. "GeneratorFunction"
  104. );
  105. // Helper for defining the .next, .throw, and .return methods of the
  106. // Iterator interface in terms of a single ._invoke method.
  107. function defineIteratorMethods(prototype) {
  108. ["next", "throw", "return"].forEach(function(method) {
  109. define(prototype, method, function(arg) {
  110. return this._invoke(method, arg);
  111. });
  112. });
  113. }
  114. exports.isGeneratorFunction = function(genFun) {
  115. var ctor = typeof genFun === "function" && genFun.constructor;
  116. return ctor
  117. ? ctor === GeneratorFunction ||
  118. // For the native GeneratorFunction constructor, the best we can
  119. // do is to check its .name property.
  120. (ctor.displayName || ctor.name) === "GeneratorFunction"
  121. : false;
  122. };
  123. exports.mark = function(genFun) {
  124. if (Object.setPrototypeOf) {
  125. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  126. } else {
  127. genFun.__proto__ = GeneratorFunctionPrototype;
  128. define(genFun, toStringTagSymbol, "GeneratorFunction");
  129. }
  130. genFun.prototype = Object.create(Gp);
  131. return genFun;
  132. };
  133. // Within the body of any async function, `await x` is transformed to
  134. // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
  135. // `hasOwn.call(value, "__await")` to determine if the yielded value is
  136. // meant to be awaited.
  137. exports.awrap = function(arg) {
  138. return { __await: arg };
  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. return PromiseImpl.resolve(value).then(function(unwrapped) {
  158. // When a yielded Promise is resolved, its final value becomes
  159. // the .value of the Promise<{value,done}> result for the
  160. // current iteration.
  161. result.value = unwrapped;
  162. resolve(result);
  163. }, function(error) {
  164. // If a rejected Promise was yielded, throw the rejection back
  165. // into the async generator function so it can be handled there.
  166. return invoke("throw", error, resolve, reject);
  167. });
  168. }
  169. }
  170. var previousPromise;
  171. function enqueue(method, arg) {
  172. function callInvokeWithMethodAndArg() {
  173. return new PromiseImpl(function(resolve, reject) {
  174. invoke(method, arg, resolve, reject);
  175. });
  176. }
  177. return previousPromise =
  178. // If enqueue has been called before, then we want to wait until
  179. // all previous Promises have been resolved before calling invoke,
  180. // so that results are always delivered in the correct order. If
  181. // enqueue has not been called before, then it is important to
  182. // call invoke immediately, without waiting on a callback to fire,
  183. // so that the async generator function has the opportunity to do
  184. // any necessary setup in a predictable way. This predictability
  185. // is why the Promise constructor synchronously invokes its
  186. // executor callback, and why async functions synchronously
  187. // execute code before the first await. Since we implement simple
  188. // async functions in terms of async generators, it is especially
  189. // important to get this right, even though it requires care.
  190. previousPromise ? previousPromise.then(
  191. callInvokeWithMethodAndArg,
  192. // Avoid propagating failures to Promises returned by later
  193. // invocations of the iterator.
  194. callInvokeWithMethodAndArg
  195. ) : callInvokeWithMethodAndArg();
  196. }
  197. // Define the unified helper method that is used to implement .next,
  198. // .throw, and .return (see defineIteratorMethods).
  199. defineProperty(this, "_invoke", { value: enqueue });
  200. }
  201. defineIteratorMethods(AsyncIterator.prototype);
  202. define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  203. return this;
  204. });
  205. exports.AsyncIterator = AsyncIterator;
  206. // Note that simple async functions are implemented on top of
  207. // AsyncIterator objects; they just return a Promise for the value of
  208. // the final result produced by the iterator.
  209. exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  210. if (PromiseImpl === void 0) PromiseImpl = Promise;
  211. var iter = new AsyncIterator(
  212. wrap(innerFn, outerFn, self, tryLocsList),
  213. PromiseImpl
  214. );
  215. return exports.isGeneratorFunction(outerFn)
  216. ? iter // If outerFn is a generator, return the full iterator.
  217. : iter.next().then(function(result) {
  218. return result.done ? result.value : iter.next();
  219. });
  220. };
  221. function makeInvokeMethod(innerFn, self, context) {
  222. var state = GenStateSuspendedStart;
  223. return function invoke(method, arg) {
  224. if (state === GenStateExecuting) {
  225. throw new Error("Generator is already running");
  226. }
  227. if (state === GenStateCompleted) {
  228. if (method === "throw") {
  229. throw arg;
  230. }
  231. // Be forgiving, per GeneratorResume behavior specified since ES2015:
  232. // ES2015 spec, step 3: https://262.ecma-international.org/6.0/#sec-generatorresume
  233. // Latest spec, step 2: https://tc39.es/ecma262/#sec-generatorresume
  234. return doneResult();
  235. }
  236. context.method = method;
  237. context.arg = arg;
  238. while (true) {
  239. var delegate = context.delegate;
  240. if (delegate) {
  241. var delegateResult = maybeInvokeDelegate(delegate, context);
  242. if (delegateResult) {
  243. if (delegateResult === ContinueSentinel) continue;
  244. return delegateResult;
  245. }
  246. }
  247. if (context.method === "next") {
  248. // Setting context._sent for legacy support of Babel's
  249. // function.sent implementation.
  250. context.sent = context._sent = context.arg;
  251. } else if (context.method === "throw") {
  252. if (state === GenStateSuspendedStart) {
  253. state = GenStateCompleted;
  254. throw context.arg;
  255. }
  256. context.dispatchException(context.arg);
  257. } else if (context.method === "return") {
  258. context.abrupt("return", context.arg);
  259. }
  260. state = GenStateExecuting;
  261. var record = tryCatch(innerFn, self, context);
  262. if (record.type === "normal") {
  263. // If an exception is thrown from innerFn, we leave state ===
  264. // GenStateExecuting and loop back for another invocation.
  265. state = context.done
  266. ? GenStateCompleted
  267. : GenStateSuspendedYield;
  268. if (record.arg === ContinueSentinel) {
  269. continue;
  270. }
  271. return {
  272. value: record.arg,
  273. done: context.done
  274. };
  275. } else if (record.type === "throw") {
  276. state = GenStateCompleted;
  277. // Dispatch the exception by looping back around to the
  278. // context.dispatchException(context.arg) call above.
  279. context.method = "throw";
  280. context.arg = record.arg;
  281. }
  282. }
  283. };
  284. }
  285. // Call delegate.iterator[context.method](context.arg) and handle the
  286. // result, either by returning a { value, done } result from the
  287. // delegate iterator, or by modifying context.method and context.arg,
  288. // setting context.delegate to null, and returning the ContinueSentinel.
  289. function maybeInvokeDelegate(delegate, context) {
  290. var methodName = context.method;
  291. var method = delegate.iterator[methodName];
  292. if (method === undefined) {
  293. // A .throw or .return when the delegate iterator has no .throw
  294. // method, or a missing .next method, always terminate the
  295. // yield* loop.
  296. context.delegate = null;
  297. // Note: ["return"] must be used for ES3 parsing compatibility.
  298. if (methodName === "throw" && delegate.iterator["return"]) {
  299. // If the delegate iterator has a return method, give it a
  300. // chance to clean up.
  301. context.method = "return";
  302. context.arg = undefined;
  303. maybeInvokeDelegate(delegate, context);
  304. if (context.method === "throw") {
  305. // If maybeInvokeDelegate(context) changed context.method from
  306. // "return" to "throw", let that override the TypeError below.
  307. return ContinueSentinel;
  308. }
  309. }
  310. if (methodName !== "return") {
  311. context.method = "throw";
  312. context.arg = new TypeError(
  313. "The iterator does not provide a '" + methodName + "' method");
  314. }
  315. return ContinueSentinel;
  316. }
  317. var record = tryCatch(method, delegate.iterator, context.arg);
  318. if (record.type === "throw") {
  319. context.method = "throw";
  320. context.arg = record.arg;
  321. context.delegate = null;
  322. return ContinueSentinel;
  323. }
  324. var info = record.arg;
  325. if (! info) {
  326. context.method = "throw";
  327. context.arg = new TypeError("iterator result is not an object");
  328. context.delegate = null;
  329. return ContinueSentinel;
  330. }
  331. if (info.done) {
  332. // Assign the result of the finished delegate to the temporary
  333. // variable specified by delegate.resultName (see delegateYield).
  334. context[delegate.resultName] = info.value;
  335. // Resume execution at the desired location (see delegateYield).
  336. context.next = delegate.nextLoc;
  337. // If context.method was "throw" but the delegate handled the
  338. // exception, let the outer generator proceed normally. If
  339. // context.method was "next", forget context.arg since it has been
  340. // "consumed" by the delegate iterator. If context.method was
  341. // "return", allow the original .return call to continue in the
  342. // outer generator.
  343. if (context.method !== "return") {
  344. context.method = "next";
  345. context.arg = undefined;
  346. }
  347. } else {
  348. // Re-yield the result returned by the delegate method.
  349. return info;
  350. }
  351. // The delegate iterator is finished, so forget it and continue with
  352. // the outer generator.
  353. context.delegate = null;
  354. return ContinueSentinel;
  355. }
  356. // Define Generator.prototype.{next,throw,return} in terms of the
  357. // unified ._invoke helper method.
  358. defineIteratorMethods(Gp);
  359. define(Gp, toStringTagSymbol, "Generator");
  360. // A Generator should always return itself as the iterator object when the
  361. // @@iterator function is called on it. Some browsers' implementations of the
  362. // iterator prototype chain incorrectly implement this, causing the Generator
  363. // object to not be returned from this call. This ensures that doesn't happen.
  364. // See https://github.com/facebook/regenerator/issues/274 for more details.
  365. define(Gp, iteratorSymbol, function() {
  366. return this;
  367. });
  368. define(Gp, "toString", function() {
  369. return "[object Generator]";
  370. });
  371. function pushTryEntry(locs) {
  372. var entry = { tryLoc: locs[0] };
  373. if (1 in locs) {
  374. entry.catchLoc = locs[1];
  375. }
  376. if (2 in locs) {
  377. entry.finallyLoc = locs[2];
  378. entry.afterLoc = locs[3];
  379. }
  380. this.tryEntries.push(entry);
  381. }
  382. function resetTryEntry(entry) {
  383. var record = entry.completion || {};
  384. record.type = "normal";
  385. delete record.arg;
  386. entry.completion = record;
  387. }
  388. function Context(tryLocsList) {
  389. // The root entry object (effectively a try statement without a catch
  390. // or a finally block) gives us a place to store values thrown from
  391. // locations where there is no enclosing try statement.
  392. this.tryEntries = [{ tryLoc: "root" }];
  393. tryLocsList.forEach(pushTryEntry, this);
  394. this.reset(true);
  395. }
  396. exports.keys = function(val) {
  397. var object = Object(val);
  398. var keys = [];
  399. for (var key in object) {
  400. keys.push(key);
  401. }
  402. keys.reverse();
  403. // Rather than returning an object with a next method, we keep
  404. // things simple and return the next function itself.
  405. return function next() {
  406. while (keys.length) {
  407. var key = keys.pop();
  408. if (key in object) {
  409. next.value = key;
  410. next.done = false;
  411. return next;
  412. }
  413. }
  414. // To avoid creating an additional object, we just hang the .value
  415. // and .done properties off the next function object itself. This
  416. // also ensures that the minifier will not anonymize the function.
  417. next.done = true;
  418. return next;
  419. };
  420. };
  421. function values(iterable) {
  422. if (iterable != null) {
  423. var iteratorMethod = iterable[iteratorSymbol];
  424. if (iteratorMethod) {
  425. return iteratorMethod.call(iterable);
  426. }
  427. if (typeof iterable.next === "function") {
  428. return iterable;
  429. }
  430. if (!isNaN(iterable.length)) {
  431. var i = -1, next = function next() {
  432. while (++i < iterable.length) {
  433. if (hasOwn.call(iterable, i)) {
  434. next.value = iterable[i];
  435. next.done = false;
  436. return next;
  437. }
  438. }
  439. next.value = undefined;
  440. next.done = true;
  441. return next;
  442. };
  443. return next.next = next;
  444. }
  445. }
  446. throw new TypeError(typeof iterable + " is not iterable");
  447. }
  448. exports.values = values;
  449. function doneResult() {
  450. return { value: undefined, done: true };
  451. }
  452. Context.prototype = {
  453. constructor: Context,
  454. reset: function(skipTempReset) {
  455. this.prev = 0;
  456. this.next = 0;
  457. // Resetting context._sent for legacy support of Babel's
  458. // function.sent implementation.
  459. this.sent = this._sent = undefined;
  460. this.done = false;
  461. this.delegate = null;
  462. this.method = "next";
  463. this.arg = undefined;
  464. this.tryEntries.forEach(resetTryEntry);
  465. if (!skipTempReset) {
  466. for (var name in this) {
  467. // Not sure about the optimal order of these conditions:
  468. if (name.charAt(0) === "t" &&
  469. hasOwn.call(this, name) &&
  470. !isNaN(+name.slice(1))) {
  471. this[name] = undefined;
  472. }
  473. }
  474. }
  475. },
  476. stop: function() {
  477. this.done = true;
  478. var rootEntry = this.tryEntries[0];
  479. var rootRecord = rootEntry.completion;
  480. if (rootRecord.type === "throw") {
  481. throw rootRecord.arg;
  482. }
  483. return this.rval;
  484. },
  485. dispatchException: function(exception) {
  486. if (this.done) {
  487. throw exception;
  488. }
  489. var context = this;
  490. function handle(loc, caught) {
  491. record.type = "throw";
  492. record.arg = exception;
  493. context.next = loc;
  494. if (caught) {
  495. // If the dispatched exception was caught by a catch block,
  496. // then let that catch block handle the exception normally.
  497. context.method = "next";
  498. context.arg = undefined;
  499. }
  500. return !! caught;
  501. }
  502. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  503. var entry = this.tryEntries[i];
  504. var record = entry.completion;
  505. if (entry.tryLoc === "root") {
  506. // Exception thrown outside of any try block that could handle
  507. // it, so set the completion value of the entire function to
  508. // throw the exception.
  509. return handle("end");
  510. }
  511. if (entry.tryLoc <= this.prev) {
  512. var hasCatch = hasOwn.call(entry, "catchLoc");
  513. var hasFinally = hasOwn.call(entry, "finallyLoc");
  514. if (hasCatch && hasFinally) {
  515. if (this.prev < entry.catchLoc) {
  516. return handle(entry.catchLoc, true);
  517. } else if (this.prev < entry.finallyLoc) {
  518. return handle(entry.finallyLoc);
  519. }
  520. } else if (hasCatch) {
  521. if (this.prev < entry.catchLoc) {
  522. return handle(entry.catchLoc, true);
  523. }
  524. } else if (hasFinally) {
  525. if (this.prev < entry.finallyLoc) {
  526. return handle(entry.finallyLoc);
  527. }
  528. } else {
  529. throw new Error("try statement without catch or finally");
  530. }
  531. }
  532. }
  533. },
  534. abrupt: function(type, arg) {
  535. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  536. var entry = this.tryEntries[i];
  537. if (entry.tryLoc <= this.prev &&
  538. hasOwn.call(entry, "finallyLoc") &&
  539. this.prev < entry.finallyLoc) {
  540. var finallyEntry = entry;
  541. break;
  542. }
  543. }
  544. if (finallyEntry &&
  545. (type === "break" ||
  546. type === "continue") &&
  547. finallyEntry.tryLoc <= arg &&
  548. arg <= finallyEntry.finallyLoc) {
  549. // Ignore the finally entry if control is not jumping to a
  550. // location outside the try/catch block.
  551. finallyEntry = null;
  552. }
  553. var record = finallyEntry ? finallyEntry.completion : {};
  554. record.type = type;
  555. record.arg = arg;
  556. if (finallyEntry) {
  557. this.method = "next";
  558. this.next = finallyEntry.finallyLoc;
  559. return ContinueSentinel;
  560. }
  561. return this.complete(record);
  562. },
  563. complete: function(record, afterLoc) {
  564. if (record.type === "throw") {
  565. throw record.arg;
  566. }
  567. if (record.type === "break" ||
  568. record.type === "continue") {
  569. this.next = record.arg;
  570. } else if (record.type === "return") {
  571. this.rval = this.arg = record.arg;
  572. this.method = "return";
  573. this.next = "end";
  574. } else if (record.type === "normal" && afterLoc) {
  575. this.next = afterLoc;
  576. }
  577. return ContinueSentinel;
  578. },
  579. finish: function(finallyLoc) {
  580. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  581. var entry = this.tryEntries[i];
  582. if (entry.finallyLoc === finallyLoc) {
  583. this.complete(entry.completion, entry.afterLoc);
  584. resetTryEntry(entry);
  585. return ContinueSentinel;
  586. }
  587. }
  588. },
  589. "catch": function(tryLoc) {
  590. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  591. var entry = this.tryEntries[i];
  592. if (entry.tryLoc === tryLoc) {
  593. var record = entry.completion;
  594. if (record.type === "throw") {
  595. var thrown = record.arg;
  596. resetTryEntry(entry);
  597. }
  598. return thrown;
  599. }
  600. }
  601. // The context.catch method must only be called with a location
  602. // argument that corresponds to a known catch block.
  603. throw new Error("illegal catch attempt");
  604. },
  605. delegateYield: function(iterable, resultName, nextLoc) {
  606. this.delegate = {
  607. iterator: values(iterable),
  608. resultName: resultName,
  609. nextLoc: nextLoc
  610. };
  611. if (this.method === "next") {
  612. // Deliberately forget the last sent value so that we don't
  613. // accidentally pass it on to the delegate.
  614. this.arg = undefined;
  615. }
  616. return ContinueSentinel;
  617. }
  618. };
  619. // Regardless of whether this script is executing as a CommonJS module
  620. // or not, return the runtime object so that we can declare the variable
  621. // regeneratorRuntime in the outer scope, which allows this module to be
  622. // injected easily by `bin/regenerator --include-runtime script.js`.
  623. return exports;
  624. }(
  625. // If this script is executing as a CommonJS module, use module.exports
  626. // as the regeneratorRuntime namespace. Otherwise create a new empty
  627. // object. Either way, the resulting object will be used to initialize
  628. // the regeneratorRuntime variable at the top of this file.
  629. typeof module === "object" ? module.exports : {}
  630. ));
  631. try {
  632. regeneratorRuntime = runtime;
  633. } catch (accidentalStrictMode) {
  634. // This module should not be running in strict mode, so the above
  635. // assignment should always work unless something is misconfigured. Just
  636. // in case runtime.js accidentally runs in strict mode, in modern engines
  637. // we can explicitly access globalThis. In older engines we can escape
  638. // strict mode using a global Function call. This could conceivably fail
  639. // if a Content Security Policy forbids using Function, but in that case
  640. // the proper solution is to fix the accidental strict mode problem. If
  641. // you've misconfigured your bundler to force strict mode and applied a
  642. // CSP to forbid Function, and you're not willing to fix either of those
  643. // problems, please detail your unique predicament in a GitHub issue.
  644. if (typeof globalThis === "object") {
  645. globalThis.regeneratorRuntime = runtime;
  646. } else {
  647. Function("r", "regeneratorRuntime = r")(runtime);
  648. }
  649. }