1 | import isObjectLike from './is-object-like';
|
2 | import isArrayLike from './is-array-like';
|
3 | import isString from './is-string';
|
4 | var isEqual = function (value, other) {
|
5 | if (value === other) {
|
6 | return true;
|
7 | }
|
8 | if (!value || !other) {
|
9 | return false;
|
10 | }
|
11 | if (isString(value) || isString(other)) {
|
12 | return false;
|
13 | }
|
14 | if (isArrayLike(value) || isArrayLike(other)) {
|
15 | if (value.length !== other.length) {
|
16 | return false;
|
17 | }
|
18 | var rst = true;
|
19 | for (var i = 0; i < value.length; i++) {
|
20 | rst = isEqual(value[i], other[i]);
|
21 | if (!rst) {
|
22 | break;
|
23 | }
|
24 | }
|
25 | return rst;
|
26 | }
|
27 | if (isObjectLike(value) || isObjectLike(other)) {
|
28 | var valueKeys = Object.keys(value);
|
29 | var otherKeys = Object.keys(other);
|
30 | if (valueKeys.length !== otherKeys.length) {
|
31 | return false;
|
32 | }
|
33 | var rst = true;
|
34 | for (var i = 0; i < valueKeys.length; i++) {
|
35 | rst = isEqual(value[valueKeys[i]], other[valueKeys[i]]);
|
36 | if (!rst) {
|
37 | break;
|
38 | }
|
39 | }
|
40 | return rst;
|
41 | }
|
42 | return false;
|
43 | };
|
44 | export default isEqual;
|
45 |
|
\ | No newline at end of file |