8 var runtime = (function (exports) { |
8 var runtime = (function (exports) { |
9 "use strict"; |
9 "use strict"; |
10 |
10 |
11 var Op = Object.prototype; |
11 var Op = Object.prototype; |
12 var hasOwn = Op.hasOwnProperty; |
12 var hasOwn = Op.hasOwnProperty; |
|
13 var defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }; |
13 var undefined; // More compressible than void 0. |
14 var undefined; // More compressible than void 0. |
14 var $Symbol = typeof Symbol === "function" ? Symbol : {}; |
15 var $Symbol = typeof Symbol === "function" ? Symbol : {}; |
15 var iteratorSymbol = $Symbol.iterator || "@@iterator"; |
16 var iteratorSymbol = $Symbol.iterator || "@@iterator"; |
16 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; |
17 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; |
17 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; |
18 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; |
40 var generator = Object.create(protoGenerator.prototype); |
41 var generator = Object.create(protoGenerator.prototype); |
41 var context = new Context(tryLocsList || []); |
42 var context = new Context(tryLocsList || []); |
42 |
43 |
43 // The ._invoke method unifies the implementations of the .next, |
44 // The ._invoke method unifies the implementations of the .next, |
44 // .throw, and .return methods. |
45 // .throw, and .return methods. |
45 generator._invoke = makeInvokeMethod(innerFn, self, context); |
46 defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }); |
46 |
47 |
47 return generator; |
48 return generator; |
48 } |
49 } |
49 exports.wrap = wrap; |
50 exports.wrap = wrap; |
50 |
51 |
101 } |
102 } |
102 |
103 |
103 var Gp = GeneratorFunctionPrototype.prototype = |
104 var Gp = GeneratorFunctionPrototype.prototype = |
104 Generator.prototype = Object.create(IteratorPrototype); |
105 Generator.prototype = Object.create(IteratorPrototype); |
105 GeneratorFunction.prototype = GeneratorFunctionPrototype; |
106 GeneratorFunction.prototype = GeneratorFunctionPrototype; |
106 define(Gp, "constructor", GeneratorFunctionPrototype); |
107 defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: true }); |
107 define(GeneratorFunctionPrototype, "constructor", GeneratorFunction); |
108 defineProperty( |
|
109 GeneratorFunctionPrototype, |
|
110 "constructor", |
|
111 { value: GeneratorFunction, configurable: true } |
|
112 ); |
108 GeneratorFunction.displayName = define( |
113 GeneratorFunction.displayName = define( |
109 GeneratorFunctionPrototype, |
114 GeneratorFunctionPrototype, |
110 toStringTagSymbol, |
115 toStringTagSymbol, |
111 "GeneratorFunction" |
116 "GeneratorFunction" |
112 ); |
117 ); |
212 ) : callInvokeWithMethodAndArg(); |
217 ) : callInvokeWithMethodAndArg(); |
213 } |
218 } |
214 |
219 |
215 // Define the unified helper method that is used to implement .next, |
220 // Define the unified helper method that is used to implement .next, |
216 // .throw, and .return (see defineIteratorMethods). |
221 // .throw, and .return (see defineIteratorMethods). |
217 this._invoke = enqueue; |
222 defineProperty(this, "_invoke", { value: enqueue }); |
218 } |
223 } |
219 |
224 |
220 defineIteratorMethods(AsyncIterator.prototype); |
225 defineIteratorMethods(AsyncIterator.prototype); |
221 define(AsyncIterator.prototype, asyncIteratorSymbol, function () { |
226 define(AsyncIterator.prototype, asyncIteratorSymbol, function () { |
222 return this; |
227 return this; |
322 // Call delegate.iterator[context.method](context.arg) and handle the |
327 // Call delegate.iterator[context.method](context.arg) and handle the |
323 // result, either by returning a { value, done } result from the |
328 // result, either by returning a { value, done } result from the |
324 // delegate iterator, or by modifying context.method and context.arg, |
329 // delegate iterator, or by modifying context.method and context.arg, |
325 // setting context.delegate to null, and returning the ContinueSentinel. |
330 // setting context.delegate to null, and returning the ContinueSentinel. |
326 function maybeInvokeDelegate(delegate, context) { |
331 function maybeInvokeDelegate(delegate, context) { |
327 var method = delegate.iterator[context.method]; |
332 var methodName = context.method; |
|
333 var method = delegate.iterator[methodName]; |
328 if (method === undefined) { |
334 if (method === undefined) { |
329 // A .throw or .return when the delegate iterator has no .throw |
335 // A .throw or .return when the delegate iterator has no .throw |
330 // method always terminates the yield* loop. |
336 // method, or a missing .next mehtod, always terminate the |
|
337 // yield* loop. |
331 context.delegate = null; |
338 context.delegate = null; |
332 |
339 |
333 if (context.method === "throw") { |
340 // Note: ["return"] must be used for ES3 parsing compatibility. |
334 // Note: ["return"] must be used for ES3 parsing compatibility. |
341 if (methodName === "throw" && delegate.iterator["return"]) { |
335 if (delegate.iterator["return"]) { |
342 // If the delegate iterator has a return method, give it a |
336 // If the delegate iterator has a return method, give it a |
343 // chance to clean up. |
337 // chance to clean up. |
344 context.method = "return"; |
338 context.method = "return"; |
345 context.arg = undefined; |
339 context.arg = undefined; |
346 maybeInvokeDelegate(delegate, context); |
340 maybeInvokeDelegate(delegate, context); |
347 |
341 |
348 if (context.method === "throw") { |
342 if (context.method === "throw") { |
349 // If maybeInvokeDelegate(context) changed context.method from |
343 // If maybeInvokeDelegate(context) changed context.method from |
350 // "return" to "throw", let that override the TypeError below. |
344 // "return" to "throw", let that override the TypeError below. |
351 return ContinueSentinel; |
345 return ContinueSentinel; |
352 } |
346 } |
353 } |
347 } |
354 if (methodName !== "return") { |
348 |
|
349 context.method = "throw"; |
355 context.method = "throw"; |
350 context.arg = new TypeError( |
356 context.arg = new TypeError( |
351 "The iterator does not provide a 'throw' method"); |
357 "The iterator does not provide a '" + methodName + "' method"); |
352 } |
358 } |
353 |
359 |
354 return ContinueSentinel; |
360 return ContinueSentinel; |
355 } |
361 } |
356 |
362 |