matches.js 505 B

1234567891011121314151617181920
  1. var forOwn = require('./forOwn');
  2. /**
  3. * checks if a object contains all given properties/values
  4. */
  5. function matches(target, props){
  6. // can't use "object/every" because of circular dependency
  7. var result = true;
  8. forOwn(props, function(val, key){
  9. if (target[key] !== val) {
  10. // break loop at first difference
  11. return (result = false);
  12. }
  13. });
  14. return result;
  15. }
  16. module.exports = matches;