Returns a promise
329563
function getPlatVersionsFromFileSystem(projectRoot){
    var platforms_on_fs = cordova_util.listPlatforms(projectRoot);
    var platformVersions = platforms_on_fs.map(function(platform){
        var script = path.join(projectRoot, 'platforms', platform, 'cordova', 'version');
        return Q.ninvoke(child_process, 'exec', script, {}).then(function(result){
            var version = result[0];

            // clean the version we get back from the script
            // This is necessary because the version script uses console.log to pass back
            // the version. Using console.log ends up adding additional line breaks/newlines to the value returned.
            // ToDO: version scripts should be refactored to not use console.log()
            var versionCleaned = version.replace(/\r?\n|\r/g, '');
            return {platform: platform, version: versionCleaned};
        });
    });

    return Q.all(platformVersions);
}
351903
async function() {
    const oThis = this
    ;
    const addressObj = new generateAddress({chain: 'utility', passphrase: oThis.reservePassphrase})
      , addressResponse = await addressObj.perform();
    if (addressResponse.isFailure()) {
      logger.error("* Reserve address generation failed with error:", addressResponse);
      process.exit(1);
    }
    return Promise.resolve(addressResponse);
  }
555786
function createMongoosePromise(resolver) {
    var promise

    // mongoose 5 and up
    if (parseInt(mongoose.version) >= 5) {
      promise = new mongoose.Promise(resolver)
    }
    // mongoose 4.1 and up
    else if (mongoose.Promise.ES6) {
      promise = new mongoose.Promise.ES6(resolver)
    }
    // backward compatibility
    else {
      promise = new mongoose.Promise
      resolver(promise.resolve.bind(promise, null), promise.reject.bind(promise))
    }

    return promise
  }
449237
function resolvePromise(promise, state, value) {
        var onceWrapper = once();
        if (promise === value) {
            throw new TypeError('Promise resolved with itself');
        }
        if (promise[symbolState] === UNRESOLVED) {
            // should only get value.then once based on promise spec.
            var then = null;
            try {
                if (typeof value === 'object' || typeof value === 'function') {
                    then = value && value.then;
                }
            }
            catch (err) {
                onceWrapper(function () {
                    resolvePromise(promise, false, err);
                })();
                return promise;
            }
            // if (value instanceof ZoneAwarePromise) {
            if (state !== REJECTED && value instanceof ZoneAwarePromise &&
                value.hasOwnProperty(symbolState) && value.hasOwnProperty(symbolValue) &&
                value[symbolState] !== UNRESOLVED) {
                clearRejectedNoCatch(value);
                resolvePromise(promise, value[symbolState], value[symbolValue]);
            }
            else if (state !== REJECTED && typeof then === 'function') {
                try {
                    then.apply(value, [
                        onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false))
                    ]);
                }
                catch (err) {
                    onceWrapper(function () {
                        resolvePromise(promise, false, err);
                    })();
                }
            }
            else {
                promise[symbolState] = state;
                var queue = promise[symbolValue];
                promise[symbolValue] = value;
                // record task information in value when error occurs, so we can
                // do some additional work such as render longStackTrace
                if (state === REJECTED && value instanceof Error) {
                    value[__symbol__('currentTask')] = Zone.currentTask;
                }
                for (var i = 0; i < queue.length;) {
                    scheduleResolveOrReject(promise, queue[i++], queue[i++], queue[i++], queue[i++]);
                }
                if (queue.length == 0 && state == REJECTED) {
                    promise[symbolState] = REJECTED_NO_CATCH;
                    try {
                        throw new Error('Uncaught (in promise): ' + value +
                            (value && value.stack ? '\n' + value.stack : ''));
                    }
                    catch (err) {
                        var error_1 = err;
                        error_1.rejection = value;
                        error_1.promise = promise;
                        error_1.zone = Zone.current;
                        error_1.task = Zone.currentTask;
                        _uncaughtPromiseErrors.push(error_1);
                        api.scheduleMicroTask(); // to make sure that it is running
                    }
                }
            }
        }
        // Resolving an already resolved promise is a noop.
        return promise;
    }
106902
function() {
				var prom = new promise.Promise();
				//console.log("deep2.Deffered.promise : ", prom, " r,r,c : ", this.rejected, this.resolved, this.canceled)
				if (this.resolved)
					return prom.resolve(this._success);
				if (this.rejected)
					return prom.reject(this._error);
				this._promises.push(prom);
				return prom;
			}
855426
function asPromise (val) {
	if (val && typeof val.then === 'function') {
		return val;
	}
	var deferred = new PromiseFactory();
	deferred.resolve(val);
	return deferred.promise();
}
580858
function _singlePromise () {
  let  done, cancel;
  const x = new Promise ( (resolve, reject ) => { 
                                                  done   = resolve
                                                  cancel = reject
                                 })

   return { 
               promise    : x
             , done       : done 
             , cancel     : cancel
             , onComplete : _after(x)
           }
   }
1112904
function promiseResult (options, data) {
		log(`promiseResult: data ${data}`);
		return new Promise((resolve, reject) => {
			/* Check cache to avoid I/O. */
			const cacheHit = checkCache(config, pattern);
			if (cacheHit !== RESPONSE_UNKNOWN) {
				log(`Cache hit: ${cacheHit}`);
				return resolve(cacheHit);
			}

			const req = https.request(options, (res) => {
				res.setEncoding('utf8');

				let response = '';
				res.on('data', (chunk) => {
					log(`Got data`);
					response += chunk;
				});

				res.on('end', () => {
					log(`end: I got ${JSON.stringify(response)}`);

					const result = serverResponseToRESPONSE(response);
					log(`end: result ${result}`);
					updateCache(config, postObject.pattern, result);

					if (result === RESPONSE_INVALID) {
						return reject(result);
					} else {
						return resolve(result);
					}
				});
			});

			req.on('error', (e) => {
				log(`Error: ${e}`);
				return reject(RESPONSE_INVALID);
			});

			// Write data to request body.
			log(`Writing to req:\n${data}`);
			req.write(data);
			req.end();
		});
	}
41793
function getCache() {
      return new Promise(function(resolve, reject) {
        // create and fetch the cache key
        get(getKey(), function(err, data) {
          if (err) {
            return reject(err);
          }
          resolve(data);
        });
      });
    }
527945
public function promise(): Promise
    {
        return new class($this) implements Promise {

            private $defer;

            public function __construct(Deferred $defer)
            {
                $this->defer = $defer;
            }

            /**
             * {@inheritdoc}
             */
            public function when(callable $callback): void
            {
                if ($this->defer->state & AbstractPromise::SUCCEEDED) {
                    try {
                        $callback(null, $this->defer->result);
                    } catch (\Throwable $e) {
                        $this->defer->context->handleError($e);
                    }
                } elseif ($this->defer->state & AbstractPromise::FAILED) {
                    try {
                        $callback($this->defer->result);
                    } catch (\Throwable $e) {
                        $this->defer->context->handleError($e);
                    }
                } elseif ($this->defer->result) {
                    if (\is_array($this->defer->result) && isset($this->defer->result[0])) {
                        $this->defer->result[] = $callback;
                    } else {
                        $this->defer->result = [
                            $this->defer->result,
                            $callback
                        ];
                    }
                } else {
                    $this->defer->result = $callback;
                }
            }
        };
    }
720383
function(){
        var deferred = Q.defer();

        fs.readFile( this.path, "utf-8", function( err, data ){
            if( err ){
                deferred.reject( err );
                return;
            }
            this.srcHTMLCode = data;
            deferred.resolve( this );
        }.bind( this ) );

        return deferred.promise;
    }
80254
function (iter, fn) {
      return new Promise(function (resolve) {
        var i = 0;
        function next() {
          return iter.next().then(function (result) {
            if (result.done) {
              return result.value;
            }
            fn(result.value, i++);
            return next();
          });
        }
        resolve(next());
      });
    }
965821
function()
    {
        if (this._executePromise)
            return this._executePromise;

        var q = this.clone();

        var table  = q._T.__name__;
        var page   = q._page;
        var fields = q._fields;

        // Create the query from our stuff
        var query = {};
        _(q._where.concat(q._like)).each(function (q) {
            query[q.key] = q.value;
        });

        var doneLoading      = Q.defer();
        this._executePromise = doneLoading.promise;

        var left = q._take;

        // A single iteration of fetching via the API. Called repeatedly in
        // the case of large / unbounded TAKES
        var loop = function() {

            // always take 1000 unless we're almost done
            var take = left < 1000 ? left : 1000;

            // Hit the API and incremement the page
            q._fetch(table, take, page++, query, fields).then(function(res) {

                // publish progress
                doneLoading.notify(q._results.length);

                if (left !== undefined) left -= res.length;

                // Either resolve the the promise with the results if we're
                // done or call the loop again

                if (q._doneLoading || left <= 0)
                    doneLoading.resolve(q._getResults());
                else
                    process.nextTick(loop);

            }).catch(function(err) {
                doneLoading.reject(err);
            });
        };

        // do tha damn thing
        loop();
        return doneLoading.promise;
    }
1307857
function when(promises) {
	promises = arrayify(promises);
	var whenPromise = new PromiseFactory();

	var pending = promises.length;
	var results = [];

	var resolve = function (i) {
		return function (val) {
			results[i] = val;
			pending--;

			if (pending === 0) {
				whenPromise.resolve(results);
			}
		};
	};

	promises.forEach(function (p, i) {
		if (!p || !p.then) return;

		p.then(resolve(i), whenPromise.reject);
	});

	return whenPromise.promise();
}
111371
function executePromise(fn, ...args) {
  try {
    // Execute the function. We do not bind a `this` variable. This is
    // expected to be done by the caller.
    const result = fn(...args);
    // If the result is thenable (most likely a promise) then we want to return
    // the result directly. Otherwise we will turn the value into a promise with
    // `Promise.resolve`.
    return result && typeof result.then === 'function'
      ? result
      : Promise.resolve(result);
  } catch (error) {
    // If the functioned errored synchronously we want to return a promise that
    // immeadiately rejects.
    return Promise.reject(error);
  }
}
408952
function wait() {
  var ms = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;

  return new Promise(function (res) {
    return setTimeout(res, ms);
  });
}
79017
function go() {
    return new Promise(handler)
      // Check for invalid `authCode`, this seems to happen at random intervals
      // within the neulion API, so we will only know when a request fails
      .catch(Errors.AuthenticationError, function(err) {

        // Authenticate and then try one more time
        return self
          .auth()
          .then(function() {
            return new Promise(handler)
          })
      })
  }