mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 02:17:48 +00:00
67 lines
2.1 KiB
JavaScript
67 lines
2.1 KiB
JavaScript
/**
|
|
* lodash 3.1.0 (Custom Build) <https://lodash.com/>
|
|
* Build: `lodash modern modularize exports="npm" -o ./`
|
|
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
|
|
* Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE>
|
|
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
* Available under MIT license <https://lodash.com/license>
|
|
*/
|
|
var baseIsEqual = require('lodash._baseisequal');
|
|
|
|
/** Used for native method references. */
|
|
var objectProto = Object.prototype;
|
|
|
|
/** Used to check objects for own properties. */
|
|
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
|
|
/**
|
|
* The base implementation of `_.isMatch` without support for callback
|
|
* shorthands or `this` binding.
|
|
*
|
|
* @private
|
|
* @param {Object} object The object to inspect.
|
|
* @param {Array} props The source property names to match.
|
|
* @param {Array} values The source values to match.
|
|
* @param {Array} strictCompareFlags Strict comparison flags for source values.
|
|
* @param {Function} [customizer] The function to customize comparing objects.
|
|
* @returns {boolean} Returns `true` if `object` is a match, else `false`.
|
|
*/
|
|
function baseIsMatch(object, props, values, strictCompareFlags, customizer) {
|
|
var length = props.length;
|
|
if (object == null) {
|
|
return !length;
|
|
}
|
|
var index = -1,
|
|
noCustomizer = !customizer;
|
|
|
|
while (++index < length) {
|
|
if ((noCustomizer && strictCompareFlags[index])
|
|
? values[index] !== object[props[index]]
|
|
: !hasOwnProperty.call(object, props[index])
|
|
) {
|
|
return false;
|
|
}
|
|
}
|
|
index = -1;
|
|
while (++index < length) {
|
|
var key = props[index];
|
|
if (noCustomizer && strictCompareFlags[index]) {
|
|
var result = hasOwnProperty.call(object, key);
|
|
} else {
|
|
var objValue = object[key],
|
|
srcValue = values[index];
|
|
|
|
result = customizer ? customizer(objValue, srcValue, key) : undefined;
|
|
if (typeof result == 'undefined') {
|
|
result = baseIsEqual(srcValue, objValue, customizer, true);
|
|
}
|
|
}
|
|
if (!result) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
module.exports = baseIsMatch;
|