[6a3a178] | 1 | var Stack = require('./_Stack'),
|
---|
| 2 | baseIsEqual = require('./_baseIsEqual');
|
---|
| 3 |
|
---|
| 4 | /** Used to compose bitmasks for value comparisons. */
|
---|
| 5 | var COMPARE_PARTIAL_FLAG = 1,
|
---|
| 6 | COMPARE_UNORDERED_FLAG = 2;
|
---|
| 7 |
|
---|
| 8 | /**
|
---|
| 9 | * The base implementation of `_.isMatch` without support for iteratee shorthands.
|
---|
| 10 | *
|
---|
| 11 | * @private
|
---|
| 12 | * @param {Object} object The object to inspect.
|
---|
| 13 | * @param {Object} source The object of property values to match.
|
---|
| 14 | * @param {Array} matchData The property names, values, and compare flags to match.
|
---|
| 15 | * @param {Function} [customizer] The function to customize comparisons.
|
---|
| 16 | * @returns {boolean} Returns `true` if `object` is a match, else `false`.
|
---|
| 17 | */
|
---|
| 18 | function baseIsMatch(object, source, matchData, customizer) {
|
---|
| 19 | var index = matchData.length,
|
---|
| 20 | length = index,
|
---|
| 21 | noCustomizer = !customizer;
|
---|
| 22 |
|
---|
| 23 | if (object == null) {
|
---|
| 24 | return !length;
|
---|
| 25 | }
|
---|
| 26 | object = Object(object);
|
---|
| 27 | while (index--) {
|
---|
| 28 | var data = matchData[index];
|
---|
| 29 | if ((noCustomizer && data[2])
|
---|
| 30 | ? data[1] !== object[data[0]]
|
---|
| 31 | : !(data[0] in object)
|
---|
| 32 | ) {
|
---|
| 33 | return false;
|
---|
| 34 | }
|
---|
| 35 | }
|
---|
| 36 | while (++index < length) {
|
---|
| 37 | data = matchData[index];
|
---|
| 38 | var key = data[0],
|
---|
| 39 | objValue = object[key],
|
---|
| 40 | srcValue = data[1];
|
---|
| 41 |
|
---|
| 42 | if (noCustomizer && data[2]) {
|
---|
| 43 | if (objValue === undefined && !(key in object)) {
|
---|
| 44 | return false;
|
---|
| 45 | }
|
---|
| 46 | } else {
|
---|
| 47 | var stack = new Stack;
|
---|
| 48 | if (customizer) {
|
---|
| 49 | var result = customizer(objValue, srcValue, key, object, source, stack);
|
---|
| 50 | }
|
---|
| 51 | if (!(result === undefined
|
---|
| 52 | ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
|
---|
| 53 | : result
|
---|
| 54 | )) {
|
---|
| 55 | return false;
|
---|
| 56 | }
|
---|
| 57 | }
|
---|
| 58 | }
|
---|
| 59 | return true;
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | module.exports = baseIsMatch;
|
---|