Chapter11/11.1/node_modules/accessibility-developer-tools/lib/closure-library/closure/goog/promise/promise_test.js
/**
 * Creates a thenable which isn't formally a promise for testing non-Promise
 * thenables.
 */
Creates a thenable which isn't formally a promise for testing non-Promise
thenables.
Creates a thenable which isn ' t formally a promise for testing non - Promise thenables .
function createThenableResolver() {
  var resolver = goog.Promise.withResolver();
  var thenable = {};
  var then = function(onFulfilled, onRejected) {
    var next = createThenableResolver();
    next.resolve(resolver.promise.then(onFulfilled, onRejected));
    return next.thenable;
  };
  if (SUPPORTS_ACCESSORS) {
    thenable.thenAccesses = 0;
    window.Object.defineProperty(thenable, 'then', {
      get: function() {
        thenable.thenAccesses++;
        return then;
      }
    });
  } else {
    thenable.then = then;
  }
  return {
    resolve: resolver.resolve,
    reject: resolver.reject,
    thenable: thenable
  };
}
function createThenableResolver ( ) { var resolver = goog . Promise . withResolver ( ) ; var thenable = { } ; var then = function ( onFulfilled , onRejected ) { var next = createThenableResolver ( ) ; next . resolve ( resolver . promise . then ( onFulfilled , onRejected ) ) ; return next . thenable ; } ; if ( SUPPORTS_ACCESSORS ) { thenable . thenAccesses = 0 ; window . Object . defineProperty ( thenable , 'then' , { get : function ( ) { thenable . thenAccesses ++ ; return then ; } } ) ; } else { thenable . then = then ; } return { resolve : resolver . resolve , reject : resolver . reject , thenable : thenable } ; }
Creates a thenable which isn't formally a promise for testing non-Promise
 thenables.
Creates a thenable which isn ' t formally a promise for testing non - Promise thenables .
// Count accesses of the {@code then} property when possible. Otherwise, just // define the {@code then} method as a regular data property.