Skip to content

Commit ac3494a

Browse files
authored
Merge pull request #31 from spadgett/arrays
Handle arrays in LabelSelector.select()
2 parents eb0ac6e + 3d9856c commit ac3494a

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

labelSelector.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,13 @@ LabelSelector.prototype.each = function(fn) {
8585
};
8686

8787
LabelSelector.prototype.select = function(resources) {
88-
var selectedResources = {};
89-
var self = this;
90-
angular.forEach(resources, function(resource, resId) {
91-
if (self.matches(resource)) {
92-
selectedResources[resId] = resource;
93-
}
94-
});
95-
return selectedResources;
88+
// If passed an array, return an array.
89+
if (_.isArray(resources)) {
90+
return _.filter(resources, this.matches, this);
91+
}
92+
93+
// Otherwise handle it as a map.
94+
return _.pick(resources, this.matches, this);
9695
};
9796

9897
LabelSelector.prototype.matches = function(resource) {

0 commit comments

Comments
 (0)