79305989

Date: 2024-12-24 15:57:59
Score: 0.5
Natty:
Report link

A simpler approach with fp could be:

const removeEmptyProperties = fp.omitBy(fp.isEmpty);
const compactObject = (obj: unknown) => {
  return fp.mapValues((value: unknown) => {
    if (fp.isObject(value)) {
      return removeEmptyProperties(compactObject(value));
    }

    return value;
  })(obj);
};
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Sebastian Serrano