29 lines
No EOL
599 B
JavaScript
Executable file
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
|