typescript-angular-utilities
Advanced tools
Comparing version 2.1.3 to 2.1.4
{ | ||
"name": "typescript-angular-utilities", | ||
"version": "2.1.3", | ||
"version": "2.1.4", | ||
"description": "Typescript utility classes published as angular services", | ||
@@ -5,0 +5,0 @@ "author": "Renovo Development Team", |
@@ -7,2 +7,3 @@ import * as angular from 'angular'; | ||
isPromise(promise: angular.IPromise<any>): boolean; | ||
resolvePromises(resolves: any): angular.IPromise<any>; | ||
} |
@@ -7,3 +7,5 @@ 'use strict'; | ||
var PromiseUtility = (function () { | ||
function PromiseUtility() { | ||
function PromiseUtility($q, $injector) { | ||
this.$q = $q; | ||
this.$injector = $injector; | ||
} | ||
@@ -13,2 +15,19 @@ PromiseUtility.prototype.isPromise = function (promise) { | ||
}; | ||
PromiseUtility.prototype.resolvePromises = function (resolves) { | ||
var _this = this; | ||
var promises = {}; | ||
_.each(resolves, function (value, key) { | ||
if (_.isFunction(value) || _.isArray(value)) { | ||
promises[key] = (_this.$q.when(_this.$injector.invoke(value))); | ||
} | ||
else if (_.isString(value)) { | ||
promises[key] = (_this.$q.when(_this.$injector.get(value))); | ||
} | ||
else { | ||
promises[key] = (_this.$q.when(value)); | ||
} | ||
}); | ||
return this.$q.all(promises); | ||
}; | ||
PromiseUtility.$inject = ['$q', '$injector']; | ||
return PromiseUtility; | ||
@@ -15,0 +34,0 @@ })(); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
240492
4783