| Index: third_party/google_input_tools/third_party/closure_library/third_party/closure/goog/mochikit/async/deferred.js
|
| diff --git a/third_party/google_input_tools/third_party/closure_library/third_party/closure/goog/mochikit/async/deferred.js b/third_party/google_input_tools/third_party/closure_library/third_party/closure/goog/mochikit/async/deferred.js
|
| index de32629d535ed5efca688a4e0d3b379ea2f668d3..f3d71d17b3f9ecc291edd144673ab17531022357 100644
|
| --- a/third_party/google_input_tools/third_party/closure_library/third_party/closure/goog/mochikit/async/deferred.js
|
| +++ b/third_party/google_input_tools/third_party/closure_library/third_party/closure/goog/mochikit/async/deferred.js
|
| @@ -17,6 +17,8 @@
|
| *
|
| * Based on the Dojo code which in turn is based on the MochiKit code.
|
| *
|
| + * @author arv@google.com (Erik Arvidsson)
|
| + * @author brenneman@google.com (Shawn Brenneman)
|
| */
|
|
|
| goog.provide('goog.async.Deferred');
|
| @@ -54,7 +56,7 @@ goog.require('goog.debug.Error');
|
| * Deferreds may be templated to a specific type they produce using generics
|
| * with syntax such as:
|
| * <code>
|
| - * /** @type {goog.async.Deferred.<string>} */
|
| + * /** @type {goog.async.Deferred<string>} */
|
| * var d = new goog.async.Deferred();
|
| * // Compiler can infer that foo is a string.
|
| * d.addCallback(function(foo) {...});
|
| @@ -70,14 +72,14 @@ goog.require('goog.debug.Error');
|
| * @param {Object=} opt_defaultScope The default object context to call
|
| * callbacks and errbacks in.
|
| * @constructor
|
| - * @implements {goog.Thenable.<VALUE>}
|
| + * @implements {goog.Thenable<VALUE>}
|
| * @template VALUE
|
| */
|
| goog.async.Deferred = function(opt_onCancelFunction, opt_defaultScope) {
|
| /**
|
| * Entries in the sequence are arrays containing a callback, an errback, and
|
| * an optional scope. The callback or errback in an entry may be null.
|
| - * @type {!Array.<!Array>}
|
| + * @type {!Array<!Array>}
|
| * @private
|
| */
|
| this.sequence_ = [];
|
| @@ -412,7 +414,7 @@ goog.async.Deferred.prototype.addCallback = function(cb, opt_scope) {
|
| * @param {!function(this:T,?):?} eb The function to be called on an
|
| * unsuccessful result.
|
| * @param {T=} opt_scope An optional scope to call the errback in.
|
| - * @return {!goog.async.Deferred.<VALUE>} This Deferred.
|
| + * @return {!goog.async.Deferred<VALUE>} This Deferred.
|
| * @template T
|
| */
|
| goog.async.Deferred.prototype.addErrback = function(eb, opt_scope) {
|
| @@ -434,6 +436,26 @@ goog.async.Deferred.prototype.addBoth = function(f, opt_scope) {
|
|
|
|
|
| /**
|
| + * Like addBoth, but propagates uncaught exceptions in the errback.
|
| + *
|
| + * @param {function(this:T,?):?} f The function to be called on any result.
|
| + * @param {T=} opt_scope An optional scope to call the function in.
|
| + * @return {!goog.async.Deferred<VALUE>} This Deferred.
|
| + * @template T
|
| + */
|
| +goog.async.Deferred.prototype.addFinally = function(f, opt_scope) {
|
| + var self = this;
|
| + return this.addCallbacks(f, function(err) {
|
| + var result = f.call(self, err);
|
| + if (!goog.isDef(result)) {
|
| + throw err;
|
| + }
|
| + return result;
|
| + }, opt_scope);
|
| +};
|
| +
|
| +
|
| +/**
|
| * Registers a callback function and an errback function at the same position
|
| * in the execution sequence. Only one of these functions will execute,
|
| * depending on the error state during the execution sequence.
|
| @@ -441,9 +463,9 @@ goog.async.Deferred.prototype.addBoth = function(f, opt_scope) {
|
| * NOTE: This is not equivalent to {@code def.addCallback().addErrback()}! If
|
| * the callback is invoked, the errback will be skipped, and vice versa.
|
| *
|
| - * @param {(function(this:T,VALUE):?)|null} cb The function to be called on a
|
| + * @param {?(function(this:T,VALUE):?)} cb The function to be called on a
|
| * successful result.
|
| - * @param {(function(this:T,?):?)|null} eb The function to be called on an
|
| + * @param {?(function(this:T,?):?)} eb The function to be called on an
|
| * unsuccessful result.
|
| * @param {T=} opt_scope An optional scope to call the functions in.
|
| * @return {!goog.async.Deferred} This Deferred.
|
| @@ -541,7 +563,7 @@ goog.async.Deferred.prototype.awaitDeferred = function(otherDeferred) {
|
| * @param {boolean=} opt_propagateCancel If cancel() is called on every child
|
| * branch created with opt_propagateCancel, the parent will be canceled as
|
| * well.
|
| - * @return {!goog.async.Deferred.<VALUE>} A Deferred that will be started with
|
| + * @return {!goog.async.Deferred<VALUE>} A Deferred that will be started with
|
| * the computed result from this stage in the execution sequence.
|
| */
|
| goog.async.Deferred.prototype.branch = function(opt_propagateCancel) {
|
| @@ -633,7 +655,9 @@ goog.async.Deferred.prototype.fire_ = function() {
|
| this.result_ = res = ret;
|
| }
|
|
|
| - if (goog.Thenable.isImplementedBy(res)) {
|
| + if (goog.Thenable.isImplementedBy(res) ||
|
| + (typeof goog.global['Promise'] === 'function' &&
|
| + res instanceof goog.global['Promise'])) {
|
| isNewlyBlocked = true;
|
| this.blocked_ = true;
|
| }
|
| @@ -697,8 +721,8 @@ goog.async.Deferred.succeed = function(opt_result) {
|
| * Creates a Deferred that fires when the given promise resolves.
|
| * Use only during migration to Promises.
|
| *
|
| - * @param {!goog.Promise.<T>} promise
|
| - * @return {!goog.async.Deferred.<T>} The new Deferred.
|
| + * @param {!goog.Promise<T>} promise
|
| + * @return {!goog.async.Deferred<T>} The new Deferred.
|
| * @template T
|
| */
|
| goog.async.Deferred.fromPromise = function(promise) {
|
| @@ -876,7 +900,7 @@ goog.async.Deferred.Error_.prototype.resetTimer = function() {
|
|
|
| /**
|
| * Map of unhandled errors scheduled to be rethrown in a future timestep.
|
| - * @private {!Object.<number|string, goog.async.Deferred.Error_>}
|
| + * @private {!Object<number|string, goog.async.Deferred.Error_>}
|
| */
|
| goog.async.Deferred.errorMap_ = {};
|
|
|
|
|