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

Function all

test/angular/1.6/angular.js:17570–17590  ·  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

17568 */
17569
17570 function all(promises) {
17571 var result = new Promise(),
17572 counter = 0,
17573 results = isArray(promises) ? [] : {};
17574
17575 forEach(promises, function(promise, key) {
17576 counter++;
17577 when(promise).then(function(value) {
17578 results[key] = value;
17579 if (!(--counter)) resolvePromise(result, results);
17580 }, function(reason) {
17581 rejectPromise(result, reason);
17582 });
17583 });
17584
17585 if (counter === 0) {
17586 resolvePromise(result, results);
17587 }
17588
17589 return result;
17590 }
17591
17592 /**
17593 * @ngdoc method

Callers

nothing calls this directly

Calls 5

isArrayFunction · 0.85
forEachFunction · 0.70
whenFunction · 0.70
resolvePromiseFunction · 0.70
rejectPromiseFunction · 0.70

Tested by

no test coverage detected