No Description

isMatch.js 424B

123456789101112131415
  1. var keys = require('./keys.js');
  2. // Returns whether an object has a given set of `key:value` pairs.
  3. 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. }
  13. module.exports = isMatch;