|
|
@@ -181,7 +181,7 @@ var Common = {
|
|
|
}
|
|
|
,
|
|
|
|
|
|
- ifSame : function(object1, object2, simpleEqualClass=[]){ //对于复杂的类对象,若能简单判断就直接写进simpleEqualClass
|
|
|
+ ifSame : function(object1, object2, simpleEqualClass=[], orderRequest=true){ //对于复杂的类对象,若能简单判断就直接写进simpleEqualClass
|
|
|
if(object1 == object2 )return true // 0 != undefined , 0 == ''
|
|
|
else if(!object1 || !object2) return false
|
|
|
else if(object1.constructor != object2.constructor){
|
|
|
@@ -192,16 +192,19 @@ var Common = {
|
|
|
}else if(object1 instanceof Array ) {
|
|
|
if(object1.length != object2.length)return false;
|
|
|
var _object2 = object2.slice(0);
|
|
|
-
|
|
|
- for(let i=0;i<object1.length;i++){
|
|
|
- var u = _object2.find(e=>Common.ifSame(object1[i], e, simpleEqualClass));
|
|
|
- if(u == void 0 && !_object2.includes(u) && !object1.includes(u))return false;
|
|
|
- else{
|
|
|
- let index = _object2.indexOf(u);
|
|
|
- _object2.splice(index,1);
|
|
|
+ if(orderRequest){
|
|
|
+ for(let i=0;i<object1.length;i++){
|
|
|
+ if(!Common.ifSame(object1[i], _object2[i], simpleEqualClass, orderRequest))return false
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ for(let i=0;i<object1.length;i++){
|
|
|
+ var u = _object2.findIndex(e=>Common.ifSame(object1[i], e, simpleEqualClass, orderRequest));
|
|
|
+ if(u == -1 )return false;
|
|
|
+ else{
|
|
|
+ _object2.splice(u,1);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
return true
|
|
|
}else if(object1.equals instanceof Function ){//复杂数据仅支持这种,其他的可能卡住?
|
|
|
|
|
|
@@ -214,10 +217,10 @@ var Common = {
|
|
|
}else if(typeof object1 == "object"){
|
|
|
var keys1 = Object.keys(object1)
|
|
|
var keys2 = Object.keys(object2)
|
|
|
- if(!Common.ifSame(keys1,keys2,simpleEqualClass))return false;
|
|
|
+ if(!Common.ifSame(keys1,keys2,simpleEqualClass, orderRequest))return false;
|
|
|
|
|
|
for(let i in object1){
|
|
|
- var same = Common.ifSame(object1[i], object2[i],simpleEqualClass);
|
|
|
+ var same = Common.ifSame(object1[i], object2[i], simpleEqualClass, orderRequest);
|
|
|
if(!same)return false
|
|
|
}
|
|
|
return true
|