isEqualWithDates.tsx 510 B

12345678910111213141516171819
  1. import isDate from 'lodash/isDate';
  2. import isEqualWith from 'lodash/isEqualWith';
  3. // `lodash.isEqual` does not compare date objects
  4. function dateComparator(value: any, other: any): boolean | undefined {
  5. if (isDate(value) && isDate(other)) {
  6. return +value === +other;
  7. }
  8. // Loose checking
  9. if (!value && !other) {
  10. return true;
  11. }
  12. // returning undefined will use default comparator
  13. return undefined;
  14. }
  15. export const isEqualWithDates = (a: any, b: any) => isEqualWith(a, b, dateComparator);