MCPcopy Index your code
hub / github.com/angular-ui/ui-router / all

Function all

test/angular/1.2/angular.js:11976–11998  ·  view source on GitHub ↗

* @ngdoc method * @name $q#all * @kind function * * @description * Combines multiple promises into a single promise that is resolved when all of the input * promises are resolved. * * @param {Array. |Object. } promises An array or hash of promises. * @retur

(promises)

Source from the content-addressed store, hash-verified

11974 * with the same rejection value.
11975 */
11976 function all(promises) {
11977 var deferred = defer(),
11978 counter = 0,
11979 results = isArray(promises) ? [] : {};
11980
11981 forEach(promises, function(promise, key) {
11982 counter++;
11983 ref(promise).then(function(value) {
11984 if (results.hasOwnProperty(key)) return;
11985 results[key] = value;
11986 if (!(--counter)) deferred.resolve(results);
11987 }, function(reason) {
11988 if (results.hasOwnProperty(key)) return;
11989 deferred.reject(reason);
11990 });
11991 });
11992
11993 if (counter === 0) {
11994 deferred.resolve(results);
11995 }
11996
11997 return deferred.promise;
11998 }
11999
12000 return {
12001 defer: defer,

Callers

nothing calls this directly

Calls 4

isArrayFunction · 0.85
refFunction · 0.85
deferFunction · 0.70
forEachFunction · 0.70

Tested by

no test coverage detected