mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 01:17:50 +00:00
Bump to v3.7.0.
This commit is contained in:
@@ -1,25 +1,45 @@
|
||||
import baseGet from './baseGet';
|
||||
import baseIsEqual from './baseIsEqual';
|
||||
import baseSlice from './baseSlice';
|
||||
import isArray from '../lang/isArray';
|
||||
import isKey from './isKey';
|
||||
import isStrictComparable from './isStrictComparable';
|
||||
import last from '../array/last';
|
||||
import toObject from './toObject';
|
||||
import toPath from './toPath';
|
||||
|
||||
/**
|
||||
* The base implementation of `_.matchesProperty` which does not coerce `key`
|
||||
* to a string.
|
||||
* The base implementation of `_.matchesProperty` which does not which does
|
||||
* not clone `value`.
|
||||
*
|
||||
* @private
|
||||
* @param {string} key The key of the property to get.
|
||||
* @param {string} path The path of the property to get.
|
||||
* @param {*} value The value to compare.
|
||||
* @returns {Function} Returns the new function.
|
||||
*/
|
||||
function baseMatchesProperty(key, value) {
|
||||
if (isStrictComparable(value)) {
|
||||
return function(object) {
|
||||
return object != null && object[key] === value &&
|
||||
(typeof value != 'undefined' || (key in toObject(object)));
|
||||
};
|
||||
}
|
||||
function baseMatchesProperty(path, value) {
|
||||
var isArr = isArray(path),
|
||||
isCommon = isKey(path) && isStrictComparable(value),
|
||||
pathKey = (path + '');
|
||||
|
||||
path = toPath(path);
|
||||
return function(object) {
|
||||
return object != null && baseIsEqual(value, object[key], null, true);
|
||||
if (object == null) {
|
||||
return false;
|
||||
}
|
||||
var key = pathKey;
|
||||
object = toObject(object);
|
||||
if ((isArr || !isCommon) && !(key in object)) {
|
||||
object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
|
||||
if (object == null) {
|
||||
return false;
|
||||
}
|
||||
key = last(path);
|
||||
object = toObject(object);
|
||||
}
|
||||
return object[key] === value
|
||||
? (value !== undefined || (key in object))
|
||||
: baseIsEqual(value, object[key], null, true);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user