[d565449] | 1 | import baseIsEqual from './_baseIsEqual.js';
|
---|
| 2 | import get from './get.js';
|
---|
| 3 | import hasIn from './hasIn.js';
|
---|
| 4 | import isKey from './_isKey.js';
|
---|
| 5 | import isStrictComparable from './_isStrictComparable.js';
|
---|
| 6 | import matchesStrictComparable from './_matchesStrictComparable.js';
|
---|
| 7 | import toKey from './_toKey.js';
|
---|
| 8 |
|
---|
| 9 | /** Used to compose bitmasks for value comparisons. */
|
---|
| 10 | var COMPARE_PARTIAL_FLAG = 1,
|
---|
| 11 | COMPARE_UNORDERED_FLAG = 2;
|
---|
| 12 |
|
---|
| 13 | /**
|
---|
| 14 | * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
|
---|
| 15 | *
|
---|
| 16 | * @private
|
---|
| 17 | * @param {string} path The path of the property to get.
|
---|
| 18 | * @param {*} srcValue The value to match.
|
---|
| 19 | * @returns {Function} Returns the new spec function.
|
---|
| 20 | */
|
---|
| 21 | function baseMatchesProperty(path, srcValue) {
|
---|
| 22 | if (isKey(path) && isStrictComparable(srcValue)) {
|
---|
| 23 | return matchesStrictComparable(toKey(path), srcValue);
|
---|
| 24 | }
|
---|
| 25 | return function(object) {
|
---|
| 26 | var objValue = get(object, path);
|
---|
| 27 | return (objValue === undefined && objValue === srcValue)
|
---|
| 28 | ? hasIn(object, path)
|
---|
| 29 | : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
|
---|
| 30 | };
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | export default baseMatchesProperty;
|
---|