Promise internals Below this, everything is @private 
Get an appropriate handler for x, without checking for cycles
@param {*} x
@returns {object} handler
10574
function getHandler(x) {
			if(isPromise(x)) {
				return x._handler.join();
			}
			return maybeThenable(x) ? getHandlerUntrusted(x) : new Fulfilled(x);
		}
1215089
function(callback) {
            var d = Q.defer();
            if (_.isFunction(callback)) d.promise.done(callback);

            this.on("ready", function() {
                d.resolve(this);
            }, this);
            if (this.is_ready) d.resolve(this);

            return d.promise;
        }
591391
function triggerPromise() {
        var me = this;
        var args = arguments;

        var canHandlePromise =
            this.children.indexOf("completed") >= 0 &&
            this.children.indexOf("failed") >= 0;

        var createdPromise = new PromiseFactory(function(resolve, reject) {
            // If `listenAndPromise` is listening
            // patch `promise` w/ context-loaded resolve/reject
            if (me.willCallPromise) {
                _.nextTick(function() {
                    var previousPromise = me.promise;
                    me.promise = function (inputPromise) {
                        inputPromise.then(resolve, reject);
                        // Back to your regularly schedule programming.
                        me.promise = previousPromise;
                        return me.promise.apply(me, arguments);
                    };
                    me.trigger.apply(me, args);
                });
                return;
            }

            if (canHandlePromise) {
                var removeSuccess = me.completed.listen(function () {
                    var args = Array.prototype.slice.call(arguments);
                    removeSuccess();
                    removeFailed();
                    resolve(args.length > 1 ? args : args[0]);
                });

                var removeFailed = me.failed.listen(function () {
                    var args = Array.prototype.slice.call(arguments);
                    removeSuccess();
                    removeFailed();
                    reject(args.length > 1 ? args : args[0]);
                });
            }

            _.nextTick(function () {
                me.trigger.apply(me, args);
            });

            if (!canHandlePromise) {
                resolve();
            }
        });

        // Ensure that the promise does trigger "Uncaught (in promise)" errors in console if no error handler is added
        // See: https://github.com/reflux/reflux-promise/issues/4
        createdPromise.catch(function() {});

        return createdPromise;
    }
276559
function Promise(o){
	var self = this;
	
        // object mixin
        if(o && typeof o === 'object'){
            for(var k in Promise.prototype)
		o[k] = Promise.prototype[k];
	    o._promise = {_chain:[]};

	    return o;
        }
	
	// create new instance
        if(!(this instanceof Promise))
            return new Promise(o);

	this._promise = {_chain: []};

        // use resolver callback
        if(typeof o === 'function') {
	    task(function(){
		var res = self.resolve.bind(self),
		    rej = self.reject.bind(self);
		o(res,rej);
	    });
        }
    }
195838
function withPromise(callback, {raf = false} = {}) {
  return new Promise((resolve, reject) => {
    if (raf) {
      requestAnimationFrame(() => {
        callback(resolve, reject);
      });
    } else {
      callback(resolve, reject);
    }
  });
}
1128877
function promiseWrap(x) {
  if(x.then && typeof x.then === "function") {
    return x;    
  }
  var deferred = q.defer();
  deferred.resolve(x);
  return deferred.promise;
}
337785
function(executor) {
            /*  optionally support non-constructor/plain-function call  */
            if (!(this instanceof Promise)) return new Promise(executor);
            /*  initialize object  */
            this.id = "Thenable/1.0.7";
            this.state = STATE_PENDING;
            /*  initial state  */
            this.fulfillValue = undefined;
            /*  initial value  */
            /*  [Promises/A+ 1.3, 2.1.2.2]  */
            this.rejectReason = undefined;
            /*  initial reason */
            /*  [Promises/A+ 1.5, 2.1.3.2]  */
            this.onFulfilled = [];
            /*  initial handlers  */
            this.onRejected = [];
            /*  initial handlers  */
            /*  support optional executor function  */
            if (typeof executor === "function") executor.call(this, this.fulfill.bind(this), this.reject.bind(this));
        }
198392
function wrapHandler(fnHandler) {
						var fnWrappedHandler = function(oEvent) {
							// The ready state at the time the event is occurring needs to
							// be preserved, to restore it when the handler is called delayed
							var iCurrentState = oXHR.readyState;
							function callHandler() {
								iReadyState = iCurrentState;
								// Only if the event has not been removed in the meantime
								// the handler needs to be called after the timeout
								if (fnWrappedHandler.active) {
									return fnHandler.call(oProxy, oEvent);
								}
							}
							// If this is an asynchronous request and a sync request is ongoing,
							// the execution of all following handler calls needs to be delayed
							if (!bSync && bSyncRequestOngoing) {
								bDelay = true;
							}
							if (bDelay) {
								_timeout(callHandler, 0);
								return true;
							}
							return callHandler();
						};
						fnHandler.wrappedHandler = fnWrappedHandler;
						fnWrappedHandler.active = true;
						return fnWrappedHandler;
					}
1294739
function tryCatchReject(f, x, thisArg, next) {
			try {
				next.become(getHandler(f.call(thisArg, x)));
			} catch(e) {
				next.become(new Rejected(e));
			}
		}
1092558
function xs(dyn, urlArr, selector, limit) {
  dyn = dyn || false
  var x = scrape.bind(null, dyn)
    // limit the urlArr size for crawling
  if (limit > 0) urlArr = _.take(urlArr, limit)
  console.log("urlArr is", urlArr)
  var promises = []
  _.each(urlArr, function(url) {
    var defer = new Promise(function(resolve, reject) {
      x(url, selector)
        .then(grab.bind(null, url))
        .then(resolve)
        .catch(reject)
    })
    promises.push(defer)
  })
  return Promise.all(promises)
}
576483
function requestHandler (method) {
  return function (req, res, next) {
    method.call(this, req, responseHandler(res, next));
  }.bind(this);
}
79088
function createLoader(handlers) {
  let _handlersType = t.nullable(t.object());

  t.param("handlers", _handlersType).assert(handlers);

  const handlerMap = new Map(Object.keys(handlers).map(key => [key, handlers[key]]));
  handlers = _handlersType.assert(undefined);

  return (state, data) => {
    const keys = Object.keys(data);
    return Promise.all(keys.map(key => {
      const handler = handlerMap.get(key);
      if (!handler) throw new Error(`Missing handler for "${key}".`);
      return handler(state, data[key]);
    })).then(results => {
      const data = Object.create(null);
      results.forEach((result, index) => {
        data[keys[index]] = result;
      });
      return data;
    });
  };
}
81482
function scheduleHandler (p1, p2) {
        return setTimeout(function () {
            var x, handler = p1._s ? p2._onFulfilled : p2._onRejected;

            // 2.2.7.3
            // 2.2.7.4
            if (handler === void 0) {
                settlePromise(p2, p1._s, p1._v);
                return;
            }

            try {
                // 2.2.5
                x = handler(p1._v);
            } catch (err) {
                // 2.2.7.2
                settlePromise(p2, $rejected, err);
                return;
            }

            // 2.2.7.1
            settleWithX(p2, x);
        });
    }
704241
function next( idx ) {
		/**
		* FUNCTION: next( error, data )
		*	Callback invoked upon completing a request.
		*
		* @private
		* @param {Error|Null} error - error object
		* @param {String} data - response data
		* @returns {Void}
		*/
		return function next( error, data ) {
			if ( eFLG ) {
				return;
			}
			if ( error ) {
				if ( error.status !== 404 ) {
					eFLG = true;
					return done( error );
				}
				data = error;
			}
			data = normalize( chunks[ idx ], data );
			data = transform( chunks[ idx ], data );

			out[ idx ] = data;

			done();
		}; // end FUNCTION next()
	}
1312305
function Promise () {
	this.deferred = false;
	this.handlers = [];
	this.state    = promise.state.PENDING;
	this.value    = null;
}
164171
function(xhr, promise, headers, method) {
            // XDR cannot set requestheaders, only XHR:
            if (!xhr._isXDR) {
                console.log(NAME, '_setHeaders');
                var name;
                if ((method!=='POST') && (method!=='PUT')) {
                    // force GET-request to make a request instead of using cache (like IE does):
                    headers['If-Modified-Since'] = 'Wed, 15 Nov 1995 01:00:00 GMT';
                    // header 'Content-Type' should only be set with POST or PUT requests:
                    delete headers[CONTENT_TYPE];
                }
                // set all headers
                for (name in headers) {
                    xhr.setRequestHeader(name, headers[name]);
                }

                // in case of POST or PUT method: always make sure 'Content-Type' is specified
                ((method!=='POST') && (method!=='PUT')) || (headers && (CONTENT_TYPE in headers)) || xhr.setRequestHeader(CONTENT_TYPE, DEF_CONTENT_TYPE_POST);
            }
        }
174902
function resolve(x) {
                        // instanceof instead of internal slot check because we should fix it without replacement native Promise core
                        if (x instanceof $Promise && sameConstructor(x.constructor, this)) return x;
                        var capability = newPromiseCapability(this)
                            , $$resolve = capability.resolve;
                        $$resolve(x);
                        return capability.promise;
                    }