Permalink
Browse files

Added intersect as a util

  • Loading branch information...
1 parent b05897a commit a45a669d391ef1f5b42047207c14d3469aad6e79 @masylum masylum committed Dec 12, 2010
Showing with 14 additions and 1 deletion.
  1. +13 −0 lib/utils.js
  2. +1 −1 lib/validator.js
View
@@ -130,6 +130,19 @@ module.exports = (function () {
}
return vals;
+ },
+
+ /**
+ * Returns the intersection of two arrays
+ *
+ * @param {array} remove
+ * @return {array}
+ * @api public
+ */
+ intersect: function (a, b) {
+ return a.filter(function (val) {
+ return b.indexOf(val) !== -1;
+ });
}
};
}());
View
@@ -4,7 +4,7 @@ module.exports = function (model, data) {
// private methods
getKeys = function (object) {
- return Object.keys(object).intersect(Object.keys(validator.data));
+ return utils.intersect(Object.keys(object), Object.keys(validator.data));
};
validator.model = model || {};

0 comments on commit a45a669

Please sign in to comment.