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