isMatch.js 409 B

1234567891011121314
  1. import keys from './keys.js';
  2. // Returns whether an object has a given set of `key:value` pairs.
  3. export default function isMatch(object, attrs) {
  4. var _keys = keys(attrs), length = _keys.length;
  5. if (object == null) return !length;
  6. var obj = Object(object);
  7. for (var i = 0; i < length; i++) {
  8. var key = _keys[i];
  9. if (attrs[key] !== obj[key] || !(key in obj)) return false;
  10. }
  11. return true;
  12. }