You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.2 KiB
45 lines
1.2 KiB
import isObjectLike from './is-object-like';
|
|
import isArrayLike from './is-array-like';
|
|
import isString from './is-string';
|
|
var isEqual = function (value, other) {
|
|
if (value === other) {
|
|
return true;
|
|
}
|
|
if (!value || !other) {
|
|
return false;
|
|
}
|
|
if (isString(value) || isString(other)) {
|
|
return false;
|
|
}
|
|
if (isArrayLike(value) || isArrayLike(other)) {
|
|
if (value.length !== other.length) {
|
|
return false;
|
|
}
|
|
var rst = true;
|
|
for (var i = 0; i < value.length; i++) {
|
|
rst = isEqual(value[i], other[i]);
|
|
if (!rst) {
|
|
break;
|
|
}
|
|
}
|
|
return rst;
|
|
}
|
|
if (isObjectLike(value) || isObjectLike(other)) {
|
|
var valueKeys = Object.keys(value);
|
|
var otherKeys = Object.keys(other);
|
|
if (valueKeys.length !== otherKeys.length) {
|
|
return false;
|
|
}
|
|
var rst = true;
|
|
for (var i = 0; i < valueKeys.length; i++) {
|
|
rst = isEqual(value[valueKeys[i]], other[valueKeys[i]]);
|
|
if (!rst) {
|
|
break;
|
|
}
|
|
}
|
|
return rst;
|
|
}
|
|
return false;
|
|
};
|
|
export default isEqual;
|
|
//# sourceMappingURL=is-equal.js.map
|