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