mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 01:17:50 +00:00
Move internal modules to “internal” folder.
This commit is contained in:
33
.internal/baseMatchesProperty.js
Normal file
33
.internal/baseMatchesProperty.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import baseIsEqual from './.internal/baseIsEqual.js';
|
||||
import get from './get.js';
|
||||
import hasIn from './hasIn.js';
|
||||
import isKey from './.internal/isKey.js';
|
||||
import isStrictComparable from './.internal/isStrictComparable.js';
|
||||
import matchesStrictComparable from './.internal/matchesStrictComparable.js';
|
||||
import toKey from './.internal/toKey.js';
|
||||
|
||||
/** Used to compose bitmasks for value comparisons. */
|
||||
const COMPARE_PARTIAL_FLAG = 1;
|
||||
const COMPARE_UNORDERED_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 object => {
|
||||
const objValue = get(object, path);
|
||||
return (objValue === undefined && objValue === srcValue)
|
||||
? hasIn(object, path)
|
||||
: baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
|
||||
};
|
||||
}
|
||||
|
||||
export default baseMatchesProperty;
|
||||
Reference in New Issue
Block a user