UNPKG

13 kBJavaScriptView Raw
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 */!function(a){"use strict";function b(a,b,c,e){// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
7var f=b&&b.prototype instanceof d?b:d,g=Object.create(f.prototype),h=new m(e||[]);return g._invoke=i(a,c,h),g}// Try/catch helper to minimize deoptimizations. Returns a completion
8// record like context.tryEntries[i].completion. This interface could
9// have been (and was previously) designed to take a closure to be
10// invoked without arguments, but in all the cases we care about we
11// already have an existing method we want to call, so there's no need
12// to create a new function object. We can even get away with assuming
13// the method takes exactly one argument, since that happens to be true
14// in every case, so we don't have to touch the arguments object. The
15// only additional allocation required is the completion record, which
16// has a stable shape and so hopefully should be cheap to allocate.
17function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}// Dummy constructor functions that we use as the .constructor and
18// .constructor.prototype properties for functions that return Generator
19// objects. For full spec compliance, you may wish to configure your
20// minifier not to mangle the names of these two functions.
21function d(){}function e(){}function f(){}// This is a polyfill for %IteratorPrototype% for environments that
22// don't natively support it.
23// Helper for defining the .next, .throw, and .return methods of the
24// Iterator interface in terms of a single ._invoke method.
25function g(a){["next","throw","return"].forEach(function(b){a[b]=function(a){return this._invoke(b,a)}})}function h(a){function b(d,e,f,g){var h=c(a[d],a,e);if("throw"===h.type)g(h.arg);else{var i=h.arg,j=i.value;return j&&"object"===typeof j&&q.call(j,"__await")?Promise.resolve(j.__await).then(function(a){b("next",a,f,g)},function(a){b("throw",a,f,g)}):Promise.resolve(j).then(function(a){// When a yielded Promise is resolved, its final value becomes
26// the .value of the Promise<{value,done}> result for the
27// current iteration. If the Promise is rejected, however, the
28// result for this iteration will be rejected with the same
29// reason. Note that rejections of yielded Promises are not
30// thrown back into the generator function, as is the case
31// when an awaited Promise is rejected. This difference in
32// behavior between yield and await is important, because it
33// allows the consumer to decide what to do with the yielded
34// rejection (swallow it and continue, manually .throw it back
35// into the generator, abandon iteration, whatever). With
36// await, by contrast, there is no opportunity to examine the
37// rejection reason outside the generator function, so the
38// only option is to throw it from the await expression, and
39// let the generator function handle the exception.
40i.value=a,f(i)},g)}}function d(a,c){function d(){return new Promise(function(d,e){b(a,c,d,e)})}return e=// If enqueue has been called before, then we want to wait until
41// all previous Promises have been resolved before calling invoke,
42// so that results are always delivered in the correct order. If
43// enqueue has not been called before, then it is important to
44// call invoke immediately, without waiting on a callback to fire,
45// so that the async generator function has the opportunity to do
46// any necessary setup in a predictable way. This predictability
47// is why the Promise constructor synchronously invokes its
48// executor callback, and why async functions synchronously
49// execute code before the first await. Since we implement simple
50// async functions in terms of async generators, it is especially
51// important to get this right, even though it requires care.
52e?e.then(d,// Avoid propagating failures to Promises returned by later
53// invocations of the iterator.
54d):d()}// Define the unified helper method that is used to implement .next,
55// .throw, and .return (see defineIteratorMethods).
56var e;this._invoke=d}function i(a,b,d){var e="suspendedStart";return function(f,g){if(e==="executing")throw new Error("Generator is already running");if("completed"===e){if("throw"===f)throw g;// Be forgiving, per 25.3.3.3.3 of the spec:
57// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
58return o()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var i=j(h,d);if(i){if(i===x)continue;return i}}if("next"===d.method)// Setting context._sent for legacy support of Babel's
59// function.sent implementation.
60d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"===e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===x)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(// Dispatch the exception by looping back around to the
61// context.dispatchException(context.arg) call above.
62e="completed",d.method="throw",d.arg=k.arg)}}}// Call delegate.iterator[context.method](context.arg) and handle the
63// result, either by returning a { value, done } result from the
64// delegate iterator, or by modifying context.method and context.arg,
65// setting context.delegate to null, and returning the ContinueSentinel.
66function j(a,b){var d=a.iterator[b.method];if(void 0===d){if(b.delegate=null,"throw"===b.method){if(a.iterator.return&&(b.method="return",b.arg=void 0,j(a,b),"throw"===b.method))// If maybeInvokeDelegate(context) changed context.method from
67// "return" to "throw", let that override the TypeError below.
68return x;b.method="throw",b.arg=new TypeError("The iterator does not provide a 'throw' method")}return x}var e=c(d,a.iterator,b.arg);if("throw"===e.type)return b.method="throw",b.arg=e.arg,b.delegate=null,x;var f=e.arg;if(!f)return b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,x;if(f.done)b[a.resultName]=f.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0);else// Re-yield the result returned by the delegate method.
69return f;// The delegate iterator is finished, so forget it and continue with
70// the outer generator.
71return b.delegate=null,x}// Define Generator.prototype.{next,throw,return} in terms of the
72// unified ._invoke helper method.
73function k(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function l(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function m(a){// The root entry object (effectively a try statement without a catch
74// or a finally block) gives us a place to store values thrown from
75// locations where there is no enclosing try statement.
76this.tryEntries=[{tryLoc:"root"}],a.forEach(k,this),this.reset(!0)}function n(a){if(a){var b=a[s];if(b)return b.call(a);if("function"===typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(q.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}// Return an iterator with no values.
77return{next:o}}function o(){return{value:void 0,done:!0}}var p=Object.prototype,q=p.hasOwnProperty,r="function"===typeof Symbol?Symbol:{},s=r.iterator||"@@iterator",t=r.asyncIterator||"@@asyncIterator",u=r.toStringTag||"@@toStringTag",v="object"===typeof module,w=a.regeneratorRuntime;if(w)// Don't bother evaluating the rest of this file if the runtime was
78// already defined globally.
79return void(v&&(module.exports=w));// Define the runtime globally (as expected by generated code) as either
80// module.exports (if we're in a module) or a new, empty object.
81w=a.regeneratorRuntime=v?module.exports:{},w.wrap=b;var x={},y={};y[s]=function(){return this};var z=Object.getPrototypeOf,A=z&&z(z(n([])));A&&A!==p&&q.call(A,s)&&(y=A);var B=f.prototype=d.prototype=Object.create(y);// Within the body of any async function, `await x` is transformed to
82// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
83// `hasOwn.call(value, "__await")` to determine if the yielded value is
84// meant to be awaited.
85// Note that simple async functions are implemented on top of
86// AsyncIterator objects; they just return a Promise for the value of
87// the final result produced by the iterator.
88// A Generator should always return itself as the iterator object when the
89// @@iterator function is called on it. Some browsers' implementations of the
90// iterator prototype chain incorrectly implement this, causing the Generator
91// object to not be returned from this call. This ensures that doesn't happen.
92// See https://github.com/facebook/regenerator/issues/274 for more details.
93e.prototype=B.constructor=f,f.constructor=e,f[u]=e.displayName="GeneratorFunction",w.isGeneratorFunction=function(a){var b="function"===typeof a&&a.constructor;return!!b&&(b===e||// For the native GeneratorFunction constructor, the best we can
94// do is to check its .name property.
95"GeneratorFunction"===(b.displayName||b.name))},w.mark=function(a){return Object.setPrototypeOf?Object.setPrototypeOf(a,f):(a.__proto__=f,!(u in a)&&(a[u]="GeneratorFunction")),a.prototype=Object.create(B),a},w.awrap=function(a){return{__await:a}},g(h.prototype),h.prototype[t]=function(){return this},w.AsyncIterator=h,w.async=function(a,c,d,e){var f=new h(b(a,c,d,e));return w.isGeneratorFunction(c)?f// If outerFn is a generator, return the full iterator.
96:f.next().then(function(a){return a.done?a.value:f.next()})},g(B),B[u]="Generator",B[s]=function(){return this},B.toString=function(){return"[object Generator]"},w.keys=function(a){var b=[];for(var c in a)b.push(c);// Rather than returning an object with a next method, we keep
97// things simple and return the next function itself.
98return b.reverse(),function c(){for(;b.length;){var d=b.pop();if(d in a)return c.value=d,c.done=!1,c}// To avoid creating an additional object, we just hang the .value
99// and .done properties off the next function object itself. This
100// also ensures that the minifier will not anonymize the function.
101return c.done=!0,c}},w.values=n,m.prototype={constructor:m,reset:function(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!a)for(var b in this)// Not sure about the optimal order of these conditions:
102"t"===b.charAt(0)&&q.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function(){this.done=!0;var a=this.tryEntries[0],b=a.completion;if("throw"===b.type)throw b.arg;return this.rval},dispatchException:function(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)// Exception thrown outside of any try block that could handle
103// it, so set the completion value of the entire function to
104// throw the exception.
105return b("end");if(e.tryLoc<=this.prev){var g=q.call(e,"catchLoc"),h=q.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(g){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);}else if(!h)throw new Error("try statement without catch or finally");else if(this.prev<e.finallyLoc)return b(e.finallyLoc)}}},abrupt:function(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&q.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,x):this.complete(f)},complete:function(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),x},finish:function(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),l(b),x},catch:function(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;l(b)}return e}// The context.catch method must only be called with a location
106// argument that corresponds to a known catch block.
107throw new Error("illegal catch attempt")},delegateYield:function(a,b,c){return this.delegate={iterator:n(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),x}}}(// In sloppy mode, unbound `this` refers to the global object, fallback to
108// Function constructor if we're in global strict mode. That is sadly a form
109// of indirect eval which violates Content Security Policy.
110function(){return this}()||Function("return this")());
\No newline at end of file