libs/lodash.js
function matches(source) {
      var props = keys(source),
          propsLength = props.length,
          key = props[0],
          value = propsLength && source[key];

      // fast path the common case of providing an object with a single
      // property containing a primitive value
      if (propsLength == 1 && value === value && !isObject(value)) {
        return function(object) {
          if (!(object && hasOwnProperty.call(object, key))) {
            return false;
          }
          // treat `-0` vs. `+0` as not equal
          var other = object[key];
          return value === other && (value !== 0 || (1 / value == 1 / other));
        };
      }
      return function(object) {
        var length = propsLength;
        if (length && !object) {
          return false;
        }
        var result = true;
        while (length--) {
          var key = props[length];
          if (!(result = hasOwnProperty.call(object, key) &&
              baseIsEqual(object[key], source[key], null, true))) {
            break;
          }
        }
        return result;
      };
    }
function matches(source) {
      var props = keys(source),
          propsLength = props.length,
          key = props[0],
          value = propsLength && source[key];

      // fast path the common case of providing an object with a single
      // property containing a primitive value
      if (propsLength == 1 && value === value && !isObject(value)) {
        return function(object) {
          if (!(object && hasOwnProperty.call(object, key))) {
            return false;
          }
          // treat `-0` vs. `+0` as not equal
          var other = object[key];
          return value === other && (value !== 0 || (1 / value == 1 / other));
        };
      }
      return function(object) {
        var length = propsLength;
        if (length && !object) {
          return false;
        }
        var result = true;
        while (length--) {
          var key = props[length];
          if (!(result = hasOwnProperty.call(object, key) &&
              baseIsEqual(object[key], source[key], null, true))) {
            break;
          }
        }
        return result;
      };
    }
function matches ( source ) { var props = keys ( source ) , propsLength = props . length , key = props [ 0 ] , value = propsLength && source [ key ] ; // fast path the common case of providing an object with a single // property containing a primitive value if ( propsLength == 1 && value === value && ! isObject ( value ) ) { return function ( object ) { if ( ! ( object && hasOwnProperty . call ( object , key ) ) ) { return false ; } // treat `-0` vs. `+0` as not equal var other = object [ key ] ; return value === other && ( value !== 0 || ( 1 / value == 1 / other ) ) ; } ; } return function ( object ) { var length = propsLength ; if ( length && ! object ) { return false ; } var result = true ; while ( length -- ) { var key = props [ length ] ; if ( ! ( result = hasOwnProperty . call ( object , key ) && baseIsEqual ( object [ key ] , source [ key ] , null , true ) ) ) { break ; } } return result ; } ; }
Creates a "_.where" style predicate function which performs a deep comparison
between a given object and the `source` object, returning `true` if the given
object has equivalent property values, else `false`.

@static
@memberOf _
@category Utilities
@param {Object} source The object of property values to match.
@returns {Function} Returns the new function.
@example

var characters = [
{ 'name': 'fred',   'age': 40 },
{ 'name': 'barney', 'age': 36 }
];

var matchesAge = _.matches({ 'age': 36 });

_.filter(characters, matchesAge);
// => [{ 'name': 'barney', 'age': 36 }]

_.find(characters, matchesAge);
// => { 'name': 'barney', 'age': 36 }
Creates a _ . where style predicate function which performs a deep comparison between a given object and the source object returning true if the given object has equivalent property values else false .