1 | var Stack = require('./_Stack'),
|
2 | baseIsEqual = require('./_baseIsEqual');
|
3 |
|
4 |
|
5 | var COMPARE_PARTIAL_FLAG = 1,
|
6 | COMPARE_UNORDERED_FLAG = 2;
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
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;
|