source: trip-planner-front/node_modules/regenerator-runtime/runtime.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

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