MCPcopy
hub / github.com/angular-ui/ui-router / all

Function all

test/angular/1.7/angular.js:18188–18208  ·  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

18186 */
18187
18188 function all(promises) {
18189 var result = new Promise(),
18190 counter = 0,
18191 results = isArray(promises) ? [] : {};
18192
18193 forEach(promises, function(promise, key) {
18194 counter++;
18195 when(promise).then(function(value) {
18196 results[key] = value;
18197 if (!(--counter)) resolvePromise(result, results);
18198 }, function(reason) {
18199 rejectPromise(result, reason);
18200 });
18201 });
18202
18203 if (counter === 0) {
18204 resolvePromise(result, results);
18205 }
18206
18207 return result;
18208 }
18209
18210 /**
18211 * @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