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

Function all

lib/test/angular/1.6.7/angular.js:17385–17405  ·  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

17383 */
17384
17385 function all(promises) {
17386 var result = new Promise(),
17387 counter = 0,
17388 results = isArray(promises) ? [] : {};
17389
17390 forEach(promises, function(promise, key) {
17391 counter++;
17392 when(promise).then(function(value) {
17393 results[key] = value;
17394 if (!(--counter)) resolvePromise(result, results);
17395 }, function(reason) {
17396 rejectPromise(result, reason);
17397 });
17398 });
17399
17400 if (counter === 0) {
17401 resolvePromise(result, results);
17402 }
17403
17404 return result;
17405 }
17406
17407 /**
17408 * @ngdoc method

Callers

nothing calls this directly

Calls 5

forEachFunction · 0.70
whenFunction · 0.70
resolvePromiseFunction · 0.70
rejectPromiseFunction · 0.70
isArrayFunction · 0.50

Tested by

no test coverage detected