Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / internal / baseIsMatch.js
1 var baseIsEqual = require('./baseIsEqual'),
2     toObject = require('./toObject');
3
4 /**
5  * The base implementation of `_.isMatch` without support for callback
6  * shorthands and `this` binding.
7  *
8  * @private
9  * @param {Object} object The object to inspect.
10  * @param {Array} matchData The propery names, values, and compare flags to match.
11  * @param {Function} [customizer] The function to customize comparing objects.
12  * @returns {boolean} Returns `true` if `object` is a match, else `false`.
13  */
14 function baseIsMatch(object, matchData, customizer) {
15   var index = matchData.length,
16       length = index,
17       noCustomizer = !customizer;
18
19   if (object == null) {
20     return !length;
21   }
22   object = toObject(object);
23   while (index--) {
24     var data = matchData[index];
25     if ((noCustomizer && data[2])
26           ? data[1] !== object[data[0]]
27           : !(data[0] in object)
28         ) {
29       return false;
30     }
31   }
32   while (++index < length) {
33     data = matchData[index];
34     var key = data[0],
35         objValue = object[key],
36         srcValue = data[1];
37
38     if (noCustomizer && data[2]) {
39       if (objValue === undefined && !(key in object)) {
40         return false;
41       }
42     } else {
43       var result = customizer ? customizer(objValue, srcValue, key) : undefined;
44       if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, true) : result)) {
45         return false;
46       }
47     }
48   }
49   return true;
50 }
51
52 module.exports = baseIsMatch;