time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

isMatch.js (1078B)


      1 var baseIsMatch = require('./_baseIsMatch'),
      2     getMatchData = require('./_getMatchData');
      3 
      4 /**
      5  * Performs a partial deep comparison between `object` and `source` to
      6  * determine if `object` contains equivalent property values.
      7  *
      8  * **Note:** This method is equivalent to `_.matches` when `source` is
      9  * partially applied.
     10  *
     11  * Partial comparisons will match empty array and empty object `source`
     12  * values against any array or object value, respectively. See `_.isEqual`
     13  * for a list of supported value comparisons.
     14  *
     15  * @static
     16  * @memberOf _
     17  * @since 3.0.0
     18  * @category Lang
     19  * @param {Object} object The object to inspect.
     20  * @param {Object} source The object of property values to match.
     21  * @returns {boolean} Returns `true` if `object` is a match, else `false`.
     22  * @example
     23  *
     24  * var object = { 'a': 1, 'b': 2 };
     25  *
     26  * _.isMatch(object, { 'b': 2 });
     27  * // => true
     28  *
     29  * _.isMatch(object, { 'b': 1 });
     30  * // => false
     31  */
     32 function isMatch(object, source) {
     33   return object === source || baseIsMatch(object, source, getMatchData(source));
     34 }
     35 
     36 module.exports = isMatch;