6f6021885afde6075f5621066a77b9af01527d3d
[yaffs-website] / baseMatchesProperty.js
1 var baseIsEqual = require('./baseIsEqual'),
2     get = require('../get'),
3     hasIn = require('../hasIn');
4
5 /** Used to compose bitmasks for comparison styles. */
6 var UNORDERED_COMPARE_FLAG = 1,
7     PARTIAL_COMPARE_FLAG = 2;
8
9 /**
10  * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
11  *
12  * @private
13  * @param {string} path The path of the property to get.
14  * @param {*} srcValue The value to match.
15  * @returns {Function} Returns the new function.
16  */
17 function baseMatchesProperty(path, srcValue) {
18   return function(object) {
19     var objValue = get(object, path);
20     return (objValue === undefined && objValue === srcValue)
21       ? hasIn(object, path)
22       : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG);
23   };
24 }
25
26 module.exports = baseMatchesProperty;