diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-04-20 03:09:25 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-04-24 16:14:29 +0200 |
commit | 82f2b76e25a4a67e01ec67e5ebe39d14ad771ea8 (patch) | |
tree | 965f6eb89b84d65a62b49008fd972c004832ccd1 /node_modules/regenerator-runtime | |
parent | e6e0cbc387c2a77b48e4065c229daa65bf1aa0fa (diff) | |
download | wallet-core-82f2b76e25a4a67e01ec67e5ebe39d14ad771ea8.tar.xz |
Reorganize module loading.
We now use webpack instead of SystemJS, effectively bundling modules
into one file (plus commons chunks) for every entry point. This results
in a much smaller extension size (almost half). Furthermore we use
yarn/npm even for extension run-time dependencies. This relieves us
from manually vendoring and building dependencies. It's also easier to
understand for new developers familiar with node.
Diffstat (limited to 'node_modules/regenerator-runtime')
-rw-r--r-- | node_modules/regenerator-runtime/package.json | 2 | ||||
-rw-r--r-- | node_modules/regenerator-runtime/runtime.js | 266 |
2 files changed, 161 insertions, 107 deletions
diff --git a/node_modules/regenerator-runtime/package.json b/node_modules/regenerator-runtime/package.json index 7fd3c8940..55f13af56 100644 --- a/node_modules/regenerator-runtime/package.json +++ b/node_modules/regenerator-runtime/package.json @@ -2,7 +2,7 @@ "name": "regenerator-runtime", "author": "Ben Newman <bn@cs.stanford.edu>", "description": "Runtime for Regenerator-compiled generator and async functions.", - "version": "0.9.6", + "version": "0.10.3", "main": "runtime-module.js", "keywords": [ "regenerator", diff --git a/node_modules/regenerator-runtime/runtime.js b/node_modules/regenerator-runtime/runtime.js index 4ec72f1aa..212da1bc1 100644 --- a/node_modules/regenerator-runtime/runtime.js +++ b/node_modules/regenerator-runtime/runtime.js @@ -11,7 +11,8 @@ !(function(global) { "use strict"; - var hasOwn = Object.prototype.hasOwnProperty; + var Op = Object.prototype; + var hasOwn = Op.hasOwnProperty; var undefined; // More compressible than void 0. var $Symbol = typeof Symbol === "function" ? Symbol : {}; var iteratorSymbol = $Symbol.iterator || "@@iterator"; @@ -83,10 +84,29 @@ function GeneratorFunction() {} function GeneratorFunctionPrototype() {} - var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype; + // This is a polyfill for %IteratorPrototype% for environments that + // don't natively support it. + var IteratorPrototype = {}; + IteratorPrototype[iteratorSymbol] = function () { + return this; + }; + + var getProto = Object.getPrototypeOf; + var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); + if (NativeIteratorPrototype && + NativeIteratorPrototype !== Op && + hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { + // This environment has a native %IteratorPrototype%; use it instead + // of the polyfill. + IteratorPrototype = NativeIteratorPrototype; + } + + var Gp = GeneratorFunctionPrototype.prototype = + Generator.prototype = Object.create(IteratorPrototype); GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; GeneratorFunctionPrototype.constructor = GeneratorFunction; - GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction"; + GeneratorFunctionPrototype[toStringTagSymbol] = + GeneratorFunction.displayName = "GeneratorFunction"; // Helper for defining the .next, .throw, and .return methods of the // Iterator interface in terms of a single ._invoke method. @@ -123,17 +143,12 @@ // Within the body of any async function, `await x` is transformed to // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test - // `value instanceof AwaitArgument` to determine if the yielded value is - // meant to be awaited. Some may consider the name of this method too - // cutesy, but they are curmudgeons. + // `hasOwn.call(value, "__await")` to determine if the yielded value is + // meant to be awaited. runtime.awrap = function(arg) { - return new AwaitArgument(arg); + return { __await: arg }; }; - function AwaitArgument(arg) { - this.arg = arg; - } - function AsyncIterator(generator) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); @@ -142,8 +157,10 @@ } else { var result = record.arg; var value = result.value; - if (value instanceof AwaitArgument) { - return Promise.resolve(value.arg).then(function(value) { + if (value && + typeof value === "object" && + hasOwn.call(value, "__await")) { + return Promise.resolve(value.__await).then(function(value) { invoke("next", value, resolve, reject); }, function(err) { invoke("throw", err, resolve, reject); @@ -212,6 +229,7 @@ } defineIteratorMethods(AsyncIterator.prototype); + runtime.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of // AsyncIterator objects; they just return a Promise for the value of @@ -246,90 +264,34 @@ return doneResult(); } + context.method = method; + context.arg = arg; + while (true) { var delegate = context.delegate; if (delegate) { - if (method === "return" || - (method === "throw" && delegate.iterator[method] === undefined)) { - // A return or throw (when the delegate iterator has no throw - // method) always terminates the yield* loop. - context.delegate = null; - - // If the delegate iterator has a return method, give it a - // chance to clean up. - var returnMethod = delegate.iterator["return"]; - if (returnMethod) { - var record = tryCatch(returnMethod, delegate.iterator, arg); - if (record.type === "throw") { - // If the return method threw an exception, let that - // exception prevail over the original return or throw. - method = "throw"; - arg = record.arg; - continue; - } - } - - if (method === "return") { - // Continue with the outer return, now that the delegate - // iterator has been terminated. - continue; - } - } - - var record = tryCatch( - delegate.iterator[method], - delegate.iterator, - arg - ); - - if (record.type === "throw") { - context.delegate = null; - - // Like returning generator.throw(uncaught), but without the - // overhead of an extra function call. - method = "throw"; - arg = record.arg; - continue; + var delegateResult = maybeInvokeDelegate(delegate, context); + if (delegateResult) { + if (delegateResult === ContinueSentinel) continue; + return delegateResult; } - - // Delegate generator ran and handled its own exceptions so - // regardless of what the method was, we continue as if it is - // "next" with an undefined arg. - method = "next"; - arg = undefined; - - var info = record.arg; - if (info.done) { - context[delegate.resultName] = info.value; - context.next = delegate.nextLoc; - } else { - state = GenStateSuspendedYield; - return info; - } - - context.delegate = null; } - if (method === "next") { + if (context.method === "next") { // Setting context._sent for legacy support of Babel's // function.sent implementation. - context.sent = context._sent = arg; + context.sent = context._sent = context.arg; - } else if (method === "throw") { + } else if (context.method === "throw") { if (state === GenStateSuspendedStart) { state = GenStateCompleted; - throw arg; + throw context.arg; } - if (context.dispatchException(arg)) { - // If the dispatched exception was caught by a catch block, - // then let that catch block handle the exception normally. - method = "next"; - arg = undefined; - } + context.dispatchException(context.arg); - } else if (method === "return") { - context.abrupt("return", arg); + } else if (context.method === "return") { + context.abrupt("return", context.arg); } state = GenStateExecuting; @@ -342,40 +304,112 @@ ? GenStateCompleted : GenStateSuspendedYield; - var info = { + if (record.arg === ContinueSentinel) { + continue; + } + + return { value: record.arg, done: context.done }; - if (record.arg === ContinueSentinel) { - if (context.delegate && method === "next") { - // Deliberately forget the last sent value so that we don't - // accidentally pass it on to the delegate. - arg = undefined; - } - } else { - return info; - } - } else if (record.type === "throw") { state = GenStateCompleted; // Dispatch the exception by looping back around to the - // context.dispatchException(arg) call above. - method = "throw"; - arg = record.arg; + // context.dispatchException(context.arg) call above. + context.method = "throw"; + context.arg = record.arg; } } }; } + // Call delegate.iterator[context.method](context.arg) and handle the + // result, either by returning a { value, done } result from the + // delegate iterator, or by modifying context.method and context.arg, + // setting context.delegate to null, and returning the ContinueSentinel. + function maybeInvokeDelegate(delegate, context) { + var method = delegate.iterator[context.method]; + if (method === undefined) { + // A .throw or .return when the delegate iterator has no .throw + // method always terminates the yield* loop. + context.delegate = null; + + if (context.method === "throw") { + if (delegate.iterator.return) { + // If the delegate iterator has a return method, give it a + // chance to clean up. + context.method = "return"; + context.arg = undefined; + maybeInvokeDelegate(delegate, context); + + if (context.method === "throw") { + // If maybeInvokeDelegate(context) changed context.method from + // "return" to "throw", let that override the TypeError below. + return ContinueSentinel; + } + } + + context.method = "throw"; + context.arg = new TypeError( + "The iterator does not provide a 'throw' method"); + } + + return ContinueSentinel; + } + + var record = tryCatch(method, delegate.iterator, context.arg); + + if (record.type === "throw") { + context.method = "throw"; + context.arg = record.arg; + context.delegate = null; + return ContinueSentinel; + } + + var info = record.arg; + + if (! info) { + context.method = "throw"; + context.arg = new TypeError("iterator result is not an object"); + context.delegate = null; + return ContinueSentinel; + } + + if (info.done) { + // Assign the result of the finished delegate to the temporary + // variable specified by delegate.resultName (see delegateYield). + context[delegate.resultName] = info.value; + + // Resume execution at the desired location (see delegateYield). + context.next = delegate.nextLoc; + + // If context.method was "throw" but the delegate handled the + // exception, let the outer generator proceed normally. If + // context.method was "next", forget context.arg since it has been + // "consumed" by the delegate iterator. If context.method was + // "return", allow the original .return call to continue in the + // outer generator. + if (context.method !== "return") { + context.method = "next"; + context.arg = undefined; + } + + } else { + // Re-yield the result returned by the delegate method. + return info; + } + + // The delegate iterator is finished, so forget it and continue with + // the outer generator. + context.delegate = null; + return ContinueSentinel; + } + // Define Generator.prototype.{next,throw,return} in terms of the // unified ._invoke helper method. defineIteratorMethods(Gp); - Gp[iteratorSymbol] = function() { - return this; - }; - Gp[toStringTagSymbol] = "Generator"; Gp.toString = function() { @@ -492,6 +526,9 @@ this.done = false; this.delegate = null; + this.method = "next"; + this.arg = undefined; + this.tryEntries.forEach(resetTryEntry); if (!skipTempReset) { @@ -528,7 +565,15 @@ record.type = "throw"; record.arg = exception; context.next = loc; - return !!caught; + + if (caught) { + // If the dispatched exception was caught by a catch block, + // then let that catch block handle the exception normally. + context.method = "next"; + context.arg = undefined; + } + + return !! caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { @@ -596,12 +641,12 @@ record.arg = arg; if (finallyEntry) { + this.method = "next"; this.next = finallyEntry.finallyLoc; - } else { - this.complete(record); + return ContinueSentinel; } - return ContinueSentinel; + return this.complete(record); }, complete: function(record, afterLoc) { @@ -613,11 +658,14 @@ record.type === "continue") { this.next = record.arg; } else if (record.type === "return") { - this.rval = record.arg; + this.rval = this.arg = record.arg; + this.method = "return"; this.next = "end"; } else if (record.type === "normal" && afterLoc) { this.next = afterLoc; } + + return ContinueSentinel; }, finish: function(finallyLoc) { @@ -656,6 +704,12 @@ nextLoc: nextLoc }; + if (this.method === "next") { + // Deliberately forget the last sent value so that we don't + // accidentally pass it on to the delegate. + this.arg = undefined; + } + return ContinueSentinel; } }; |