Last active
October 11, 2017 15:55
-
-
Save gitexec/9e5182113b1dcce5fdd8abd9214d1ed6 to your computer and use it in GitHub Desktop.
compare Any Number Of Objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {fromJS} from 'immutable'; | |
public compareObjects(...compareArguments): boolean { | |
//For now just two arguments | |
if (!compareArguments) | |
return false; | |
if (compareArguments.length < 2) | |
return false; | |
compareArguments.forEach((curr, index) => { | |
if ((fromJS(curr).equals(fromJS(compareArguments[index + 1]))) == false){ | |
return false; | |
} | |
}); | |
return true; | |
} | |
/* //Other ways with pure ES6 | |
let obj = Objects.values(ob1); | |
let obj2 = Objects.values(ob2); | |
if(obj.length !== obj2.length) | |
return false; | |
for(let [key, curr] of obj){ | |
if(curr !== obj2[key+1]) | |
return false | |
} | |
return true; | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment