'use strict';

function noNulls(value) {
  if (value === null || value === undefined) return '';
  if (value instanceof Date) return value;
  if (Array.isArray(value)) return value.map(noNulls);
  if (typeof value !== 'object') return value;

  return Object.fromEntries(
    Object.entries(value).map(([key, entry]) => [key, noNulls(entry)])
  );
}

module.exports = { noNulls };
