source: imaps-frontend/node_modules/regenerator-runtime/runtime.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

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