mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
import baseIsEqual from './_baseIsEqual.js';
|
|
import get from './get.js';
|
|
import hasIn from './hasIn.js';
|
|
import isKey from './_isKey.js';
|
|
import isStrictComparable from './_isStrictComparable.js';
|
|
import matchesStrictComparable from './_matchesStrictComparable.js';
|
|
import toKey from './_toKey.js';
|
|
|
|
/** Used to compose bitmasks for comparison styles. */
|
|
var UNORDERED_COMPARE_FLAG = 1,
|
|
PARTIAL_COMPARE_FLAG = 2;
|
|
|
|
/**
|
|
* The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
|
|
*
|
|
* @private
|
|
* @param {string} path The path of the property to get.
|
|
* @param {*} srcValue The value to match.
|
|
* @returns {Function} Returns the new spec function.
|
|
*/
|
|
function baseMatchesProperty(path, srcValue) {
|
|
if (isKey(path) && isStrictComparable(srcValue)) {
|
|
return matchesStrictComparable(toKey(path), srcValue);
|
|
}
|
|
return function(object) {
|
|
var objValue = get(object, path);
|
|
return (objValue === undefined && objValue === srcValue)
|
|
? hasIn(object, path)
|
|
: baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG);
|
|
};
|
|
}
|
|
|
|
export default baseMatchesProperty;
|