`Promise.all` method https://tc39.github.io/ecma262/#sec-promise.all
480692
function all(iterable) {
    var C = this;
    var capability = newPromiseCapability(C);
    var resolve = capability.resolve;
    var reject = capability.reject;
    var result = perform(function () {
      var $promiseResolve = aFunction(C.resolve);
      var values = [];
      var counter = 0;
      var remaining = 1;
      iterate(iterable, function (promise) {
        var index = counter++;
        var alreadyCalled = false;
        values.push(undefined);
        remaining++;
        $promiseResolve.call(C, promise).then(function (value) {
          if (alreadyCalled) return;
          alreadyCalled = true;
          values[index] = value;
          --remaining || resolve(values);
        }, reject);
      });
      --remaining || resolve(values);
    });
    if (result.error) reject(result.value);
    return capability.promise;
  }
529517
def listPromise(*args):
    
    ret = Promise()

    def handleSuccess(v, ret):
        for arg in args:
            if not arg.isFulfilled():
                return

        value = map(lambda p: p.value, args)
        ret.fulfill(value)

    for arg in args:
        arg.addCallback(lambda v: handleSuccess(v, ret))
        arg.addErrback(lambda r: ret.reject(r))

    # Check to see if all the promises are already fulfilled
    handleSuccess(None, ret)

    return ret
693889
function execPromise (fn) {
  return new Promise(function (resolve) {
    resolve(fn(process.argv.slice(2)))
  }).then(onSuccess, onError)
}
570889
@NotNull
	public static <T> Promise<T> any(@NotNull Iterator<? extends Promise<? extends T>> promises, @NotNull Consumer<T> cleanup) {
		if (!promises.hasNext()) return any();
		@NotNull PromiseAny<T> resultPromise = new PromiseAny<>();
		while (promises.hasNext()) {
			Promise<? extends T> promise = promises.next();
			if (promise.isResult()) return Promise.of(promise.materialize().getResult());
			if (promise.isException()) continue;
			resultPromise.errors++;
			promise.whenComplete((result, e) -> {
				if (e == null) {
					if (resultPromise.isComplete()) {
						cleanup.accept(result);
					} else {
						resultPromise.complete(result);
					}
				} else {
					if (--resultPromise.errors == 0) {
						resultPromise.completeExceptionally(e);
					}
				}
			});
		}
		return resultPromise.errors != 0 ? resultPromise : any();
	}
125384
function () {
            return [
                __.all ([                 123,                   456 ]).assert ([123, 456]),
                __.all ([     _.constant (123),      _.constant (456)]).assert ([123, 456]),
                __.all ([Promise.resolve (123), Promise.resolve (456)]).assert ([123, 456]) ] }
896325
function routine (fn, sets, context) {
  const master = []

  if (typeof context === 'undefined') {
    context = fn
  }

  for (const args of sets) {
    master.push(fn.apply(context, Array.isArray(args) ? args : [args]))
  }

  return Promise.all(master)
}
1110170
function (nodes, i, container, _parent, counter) {
	var node = nodes[i].clone();

	nodes[i].clear();

	return function (others) {
		var local_promises = [];
		if (node.children.length) {
			transclude(others, node.children);
		}

		node.children    = others;
		node.is_resolved = true;

		collect_components([node], container, local_promises, _parent, counter);

		return $q.all(local_promises).then(function () {
			nodes[i] = node;
		});
	};
}
1149517
function promiseify(method, ctx) {

  // check first
  if (typeof method !== 'function') {
    throw new TypeError(String(method) + ' is not a function');
  }

  return function() {

    // runtime args
    var args = [].slice.call(arguments);

    // runtime this
    ctx = ctx || this;

    return new Promise(function(resolve, reject) {

      args.push(function(err) {
        if (err) {
          return reject(err);
        }
        var arg = [].slice.call(arguments);
        if (arg.length === 2) {
          resolve.call(this, arg[1]);
        } else {
          resolve.call(this, arg.slice(1));
        }
      });

      try {
        method.apply(ctx, args);
      } catch (err) {
        reject(err);
      }
    });
  };
}
1353162
function resolveAll(fileContent) {
			var matches      = [].concat(fileContent.match(regexFile)).filter(Boolean).map(extractFile);
			var pathsMatches = [].concat(fileContent.match(regexPath)).filter(Boolean).map(extractFile);

			if (matches.length === 0 && pathsMatches.length === 0) {
				return new RSVP.Promise(function(resolve) {
					resolve(fileContent)
				});
			}

			var promises      = [].concat(matches.map(resolveFile)).filter(Boolean);
			var promisesPaths = [].concat(pathsMatches.map(resolvePath)).filter(Boolean);

			return RSVP.all(promises.concat(promisesPaths)).then(function() {
				for (var i = 0, len = matches.length; i < len; i++) {
					fileContent = fileContent.replace(matches[i], replacements[i]);
				}
				return fileContent;
			});

		}
312741
function syncPromise(promise) {
  let isDone = false;
  let res, err;

  promise.then(
    value => {
      res = value;
      isDone = true;
    },
    error => {
      err = error;
      isDone = true;
    }
  );

  deasync.loopWhile(() => !isDone);

  if (err) {
    throw err;
  }

  return res;
}
991498
function resolve(promise, x) {
  /*  sanity check arguments  */

  /*  [Promises/A+ 2.3.1]  */
  if (promise === x || promise.proxy === x) {
    promise.reject(new TypeError('cannot resolve promise with itself'));
    return;
  }
  /*  surgically check for a "then" method
    (mainly to just call the "getter" of "then" only once)  */


  var then;

  if (_typeof(x) === 'object' && x !== null || typeof x === 'function') {
    try {
      then = x.then;
    }
    /*  [Promises/A+ 2.3.3.1, 3.5]  */
    catch (e) {
      promise.reject(e);
      /*  [Promises/A+ 2.3.3.2]  */

      return;
    }
  }
  /*  handle own Thenables    [Promises/A+ 2.3.2]
    and similar "thenables" [Promises/A+ 2.3.3]  */


  if (typeof then === 'function') {
    var resolved = false;

    try {
      /*  call retrieved "then" method */

      /*  [Promises/A+ 2.3.3.3]  */
      then.call(x,
      /*  resolvePromise  */

      /*  [Promises/A+ 2.3.3.3.1]  */
      function (y) {
        if (resolved) return;
        resolved = true;
        /*  [Promises/A+ 2.3.3.3.3]  */

        if (y === x)
          /*  [Promises/A+ 3.6]  */
          promise.reject(new TypeError('circular thenable chain'));else resolve(promise, y);
      },
      /*  rejectPromise  */

      /*  [Promises/A+ 2.3.3.3.2]  */
      function (r) {
        if (resolved) return;
        resolved = true;
        /*  [Promises/A+ 2.3.3.3.3]  */

        promise.reject(r);
      });
    } catch (e) {
      if (!resolved)
        /*  [Promises/A+ 2.3.3.3.3]  */
        promise.reject(e);
      /*  [Promises/A+ 2.3.3.3.4]  */
    }

    return;
  }
  /*  handle other values  */


  promise.fulfill(x);
  /*  [Promises/A+ 2.3.4, 2.3.3.4]  */
}
323901
function handlePromise(query, q, model, resultsPerPage) {
  return Promise.all([
    query.exec(),
    model.count(q).exec()
  ]).spread(function(results, count) {
    return [
      results,
      Math.ceil(count / resultsPerPage) || 1,
      count
    ]
  });
}
246751
function _each( object, callback, thisObj ) {

		if ( !object ) {
			return Promise.resolve();
		}

		var results;
		var fns = [];

		if ( Object.prototype.toString.call( object ) === '[object Array]' ) {

			results = [];

			var length = object.length;
			for ( var idx = 0; idx < length; idx ++ ) {
				var value = callback.call( thisObj || this, object[ idx ], idx );
				if ( value ) {
					fns.push( value );
					if ( value instanceof Promise ) {
						value.then( function( key, value ) {
							results[ idx ] = value;
						}.bind( this, key ));
					} else {
						results[ idx ] = value;
					}
				}
			}

		} else {

			results = {};

			for ( var key in object ) {
				if ( object.hasOwnProperty( key ) ) {
					var value = callback.call( thisObj || this, object[ key ], key );
					if ( value ) {
						fns.push( value );
						if ( value instanceof Promise ) {
							value.then( function( key, value ) {
								results[ key ] = value;
							}.bind( this, key ));
						} else {
							results[ key ] = value;
						}
					}
				}
			}

		}

		return Promise.all( fns ).then( function() {
			return results;
		});

	}
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);
	    });
        }
    }
446146
function parse(method, req, res, options) {
    return new Promise(function(resolve, reject) {
        BodyParser[method](options)(req, res, function(err) {
            if (err) {
                return reject(err);
            }

            return resolve();
        });
    });
}
694612
function _resolvePromises (opts, val) {
  opts = opts || {}
  var duplicate = opts.duplicate
  if (is(Array, val)) {
    return Promise.all(duplicate ? concat([], val) : val)
  } else if (duplicate && is(Object, val) && !is(Function, val.then)) {
    return Object.assign({}, val)
  }
  return val
}
1007192
function(C) {
        if (!ES.IsCallable(C)) {
          throw new TypeError('bad promise constructor');
        }
        var capability = this;
        var resolver = function(resolve, reject) {
          capability.resolve = resolve;
          capability.reject = reject;
        };
        capability.promise = ES.Construct(C, [resolver]);
        // see https://bugs.ecmascript.org/show_bug.cgi?id=2478
        if (!capability.promise._es6construct) {
          throw new TypeError('bad promise constructor');
        }
        if (!(ES.IsCallable(capability.resolve) &&
              ES.IsCallable(capability.reject))) {
          throw new TypeError('bad promise constructor');
        }
      }