Skip to content
Browse files

Safer include

  • Loading branch information...
1 parent c4ae9ce commit 573aace4ed9c54ca8bcddcb55ed61d241571f5e2 @1602 committed May 8, 2013
Showing with 5 additions and 5 deletions.
  1. +5 −5 lib/include.js
View
10 lib/include.js
@@ -92,12 +92,12 @@ AbstractClass.include = function (objects, include, cb) {
if (!keyVals[relation.keyFrom]) {
objsByKeys[relation.keyFrom] = {};
- for (var j = 0; j < objs.length; j++) {
- if (!objsByKeys[relation.keyFrom][objs[j][relation.keyFrom]]) {
- objsByKeys[relation.keyFrom][objs[j][relation.keyFrom]] = [];
+ objs.filter(Boolean).forEach(function(obj) {
+ if (!objsByKeys[relation.keyFrom][obj[relation.keyFrom]]) {
+ objsByKeys[relation.keyFrom][obj[relation.keyFrom]] = [];
}
- objsByKeys[relation.keyFrom][objs[j][relation.keyFrom]].push(objs[j]);
- }
+ objsByKeys[relation.keyFrom][obj[relation.keyFrom]].push(obj);
+ });
keyVals[relation.keyFrom] = Object.keys(objsByKeys[relation.keyFrom]);
}

0 comments on commit 573aace

Please sign in to comment.
Something went wrong with that request. Please try again.