2017-06-08_509bba0/509bba0_unpacked_with_node_modules/discord_common/js/lib/shallowEqual.js
2022-07-26 10:06:20 -07:00

29 lines
No EOL
599 B
JavaScript
Executable file

/**
* Shallow compare to objects with the option to ignore certain keys.
*/
export default function shallowEqual(a: Object, b: Object, ignore: Array<string>): boolean {
if (a === b) {
return true;
}
const keysA = Object.keys(a);
const keysB = Object.keys(b);
if (keysA.length !== keysB.length) {
return false;
}
for (let i = 0; i < keysA.length; i++) {
const key = keysA[i];
if (a[key] !== b[key] && (ignore == null || ignore.indexOf(key) === -1)) {
return false;
}
}
return true;
}
// WEBPACK FOOTER //
// ./discord_common/js/lib/shallowEqual.js