2021-09-16 21:07:22 +00:00
|
|
|
import type { FullIconCustomisations } from './index';
|
|
|
|
import { defaults } from './index';
|
2020-04-28 09:47:35 +00:00
|
|
|
|
|
|
|
// Get all keys
|
|
|
|
const allKeys: (keyof FullIconCustomisations)[] = Object.keys(
|
|
|
|
defaults
|
|
|
|
) as (keyof FullIconCustomisations)[];
|
|
|
|
|
|
|
|
// All keys without width/height
|
2020-12-25 19:03:15 +00:00
|
|
|
const filteredKeys = allKeys.filter(
|
|
|
|
(key) => key !== 'width' && key !== 'height'
|
|
|
|
);
|
2020-04-28 09:47:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Compare sets of cusotmisations, return false if they are different, true if the same
|
|
|
|
*
|
|
|
|
* If dimensions are derived from props1 or props2, do not compare them.
|
|
|
|
*/
|
|
|
|
export function compare(
|
|
|
|
item1: FullIconCustomisations,
|
|
|
|
item2: FullIconCustomisations,
|
|
|
|
compareDimensions = true
|
|
|
|
): boolean {
|
|
|
|
const keys = compareDimensions ? allKeys : filteredKeys;
|
|
|
|
for (let i = 0; i < keys.length; i++) {
|
|
|
|
const key = keys[i];
|
|
|
|
if (item1[key] !== item2[key]) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|