object-utils.ts 261 B

12345678910111213
  1. // remove property if value is null
  2. export const removeNullPropertyFromObject = <T extends object>(
  3. object: T,
  4. ): T => {
  5. for (const [key, value] of Object.entries(object)) {
  6. if (value == null) {
  7. delete object[key];
  8. }
  9. }
  10. return object;
  11. };