Skip to content

Instantly share code, notes, and snippets.

@gitexec
Last active October 11, 2017 15:55
Show Gist options
  • Save gitexec/9e5182113b1dcce5fdd8abd9214d1ed6 to your computer and use it in GitHub Desktop.
Save gitexec/9e5182113b1dcce5fdd8abd9214d1ed6 to your computer and use it in GitHub Desktop.
compare Any Number Of Objects
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