mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 07:47:49 +00:00
27 lines
795 B
JavaScript
27 lines
795 B
JavaScript
var baseIsEqual = require('./baseIsEqual'),
|
|
isStrictComparable = require('./isStrictComparable'),
|
|
toObject = require('./toObject');
|
|
|
|
/**
|
|
* The base implementation of `_.matchesProperty` which does not coerce `key`
|
|
* to a string.
|
|
*
|
|
* @private
|
|
* @param {string} key The key 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)));
|
|
};
|
|
}
|
|
return function(object) {
|
|
return object != null && baseIsEqual(value, object[key], null, true);
|
|
};
|
|
}
|
|
|
|
module.exports = baseMatchesProperty;
|