Repository: discordjs/discord.js
File: packages/discord.js/src/util/Transformers.js (JavaScript)

Code before:
    start: new Date(recurrenceRule.startAt).toISOString(),
    frequency: recurrenceRule.frequency,
    interval: recurrenceRule.interval,
    by_weekday: recurrenceRule.byWeekday,
    by_n_weekday: recurrenceRule.byNWeekday,
    by_month: recurrenceRule.byMonth,
    by_month_day: recurrenceRule.byMonthDay,
  };
}

/**
 * Transforms API incidents data to a camel-cased variant.
 * @param {APIIncidentsData} data The incidents data to transform
 * @returns {IncidentActions}
 * @ignore
 */
function _transformAPIIncidentsData(data) {
  return {
    invitesDisabledUntil: data.invites_disabled_until
      ? new Date(data.invites_disabled_until)
      : data.invites_disabled_until,
    dmsDisabledUntil: data.dms_disabled_until ? new Date(data.dms_disabled_until) : data.dms_disabled_until,
    dmSpamDetectedAt: data.dm_spam_detected_at
      ? new Date(data.dm_spam_detected_at)
      : (data.dm_spam_detected_at ?? null),
    raidDetectedAt: data.raid_detected_at ? new Date(data.raid_detected_at) : (data.raid_detected_at ?? null),
  };
}

exports.toSnakeCase = toSnakeCase;
exports._transformAPIAutoModerationAction = _transformAPIAutoModerationAction;
exports._transformAPIMessageInteractionMetadata = _transformAPIMessageInteractionMetadata;
exports._transformGuildScheduledEventRecurrenceRule = _transformGuildScheduledEventRecurrenceRule;
exports._transformAPIIncidentsData = _transformAPIIncidentsData;


Review comment (performance):
I don't see a benefit in keeping the extra complexity

```suggestion
    invitesDisabledUntil: data.invites_disabled_until ? new Date(data.invites_disabled_until) : null,
    dmsDisabledUntil: data.dms_disabled_until ? new Date(data.dms_disabled_until) : null,
    dmSpamDetectedAt: data.dm_spam_detected_at ? new Date(data.dm_spam_detected_at) : null,
    raidDetectedAt: data.raid_detected_at ? new Date(data.raid_detected_at) : null,
```

Code after:
    start: new Date(recurrenceRule.startAt).toISOString(),
    frequency: recurrenceRule.frequency,
    interval: recurrenceRule.interval,
    by_weekday: recurrenceRule.byWeekday,
    by_n_weekday: recurrenceRule.byNWeekday,
    by_month: recurrenceRule.byMonth,
    by_month_day: recurrenceRule.byMonthDay,
  };
}

/**
 * Transforms API incidents data to a camel-cased variant.
 * @param {APIIncidentsData} data The incidents data to transform
 * @returns {IncidentActions}
 * @ignore
 */
function _transformAPIIncidentsData(data) {
  return {
    invitesDisabledUntil: data.invites_disabled_until ? new Date(data.invites_disabled_until) : null,
    dmsDisabledUntil: data.dms_disabled_until ? new Date(data.dms_disabled_until) : null,
    dmSpamDetectedAt: data.dm_spam_detected_at ? new Date(data.dm_spam_detected_at) : null,
    raidDetectedAt: data.raid_detected_at ? new Date(data.raid_detected_at) : null,
  };
}

exports.toSnakeCase = toSnakeCase;
exports._transformAPIAutoModerationAction = _transformAPIAutoModerationAction;
exports._transformAPIMessageInteractionMetadata = _transformAPIMessageInteractionMetadata;
exports._transformGuildScheduledEventRecurrenceRule = _transformGuildScheduledEventRecurrenceRule;
exports._transformAPIIncidentsData = _transformAPIIncidentsData;