import isEqual from 'lodash/isEqual';

export const getDiff = (
  a: Record<string, unknown>,
  b: Record<string, unknown>
) => {
  const diff = Object.keys(a).reduce((result, key) => {
    if (!b.hasOwnProperty(key)) {
      result.push(key);
    } else if (isEqual(a[key], b[key])) {
      const resultKeyIndex = result.indexOf(key);
      result.splice(resultKeyIndex, 1);
    }
    return result;
  }, Object.keys(b));

  return diff;
};
