diff --git a/src/git/models/branch.ts b/src/git/models/branch.ts index 55844d5..c3cf610 100644 --- a/src/git/models/branch.ts +++ b/src/git/models/branch.ts @@ -155,13 +155,9 @@ export class GitBranch implements GitBranchReference { return this.detached ? this.sha! : this.name; } - @memoize(format => (format == null ? 'MMMM Do, YYYY h:mma' : format)) + @memoize(format => format ?? 'MMMM Do, YYYY h:mma') formatDate(format?: string | null): string { - if (format == null) { - format = 'MMMM Do, YYYY h:mma'; - } - - return this.date != null ? formatDate(this.date, format) : ''; + return this.date != null ? formatDate(this.date, format ?? 'MMMM Do, YYYY h:mma') : ''; } formatDateFromNow(): string { diff --git a/src/git/models/commit.ts b/src/git/models/commit.ts index 7bf9dfc..93fa437 100644 --- a/src/git/models/commit.ts +++ b/src/git/models/commit.ts @@ -483,16 +483,12 @@ export class GitCommitIdentity { private readonly avatarUrl?: string | undefined, ) {} - @memoize(format => (format == null ? 'MMMM Do, YYYY h:mma' : format)) - formatDate(format?: string | null) { - if (format == null) { - format = 'MMMM Do, YYYY h:mma'; - } - - return formatDate(this.date, format); + @memoize(format => format ?? 'MMMM Do, YYYY h:mma') + formatDate(format?: string | null): string { + return formatDate(this.date, format ?? 'MMMM Do, YYYY h:mma'); } - fromNow(short?: boolean) { + fromNow(short?: boolean): string { return fromNow(this.date, short); } diff --git a/src/git/models/pullRequest.ts b/src/git/models/pullRequest.ts index aa4a70b..6ac0336 100644 --- a/src/git/models/pullRequest.ts +++ b/src/git/models/pullRequest.ts @@ -80,7 +80,7 @@ export class PullRequest { : this.formatDateFromNow(); } - @memoize(format => (format == null ? 'MMMM Do, YYYY h:mma' : format)) + @memoize(format => format ?? 'MMMM Do, YYYY h:mma') formatDate(format?: string | null) { return formatDate(this.mergedDate ?? this.closedDate ?? this.date, format ?? 'MMMM Do, YYYY h:mma'); } @@ -89,7 +89,7 @@ export class PullRequest { return fromNow(this.mergedDate ?? this.closedDate ?? this.date); } - @memoize(format => (format == null ? 'MMMM Do, YYYY h:mma' : format)) + @memoize(format => format ?? 'MMMM Do, YYYY h:mma') formatClosedDate(format?: string | null) { if (this.closedDate == null) return ''; return formatDate(this.closedDate, format ?? 'MMMM Do, YYYY h:mma'); @@ -100,7 +100,7 @@ export class PullRequest { return fromNow(this.closedDate); } - @memoize(format => (format == null ? 'MMMM Do, YYYY h:mma' : format)) + @memoize(format => format ?? 'MMMM Do, YYYY h:mma') formatMergedDate(format?: string | null) { if (this.mergedDate == null) return ''; return formatDate(this.mergedDate, format ?? 'MMMM Do, YYYY h:mma') ?? ''; @@ -111,7 +111,7 @@ export class PullRequest { return fromNow(this.mergedDate); } - @memoize(format => (format == null ? 'MMMM Do, YYYY h:mma' : format)) + @memoize(format => format ?? 'MMMM Do, YYYY h:mma') formatUpdatedDate(format?: string | null) { return formatDate(this.date, format ?? 'MMMM Do, YYYY h:mma') ?? ''; } diff --git a/src/git/models/reflog.ts b/src/git/models/reflog.ts index 8dad1f5..eebe46e 100644 --- a/src/git/models/reflog.ts +++ b/src/git/models/reflog.ts @@ -28,7 +28,7 @@ export class GitReflogRecord { public readonly details: string | undefined, ) {} - @memoize(format => (format == null ? 'MMMM Do, YYYY h:mma' : format)) + @memoize(format => format ?? 'MMMM Do, YYYY h:mma') formatDate(format?: string | null) { return formatDate(this.date, format ?? 'MMMM Do, YYYY h:mma'); } diff --git a/src/git/models/tag.ts b/src/git/models/tag.ts index 54e33be..8745820 100644 --- a/src/git/models/tag.ts +++ b/src/git/models/tag.ts @@ -65,7 +65,7 @@ export class GitTag implements GitTagReference { return this.name; } - @memoize(format => (format == null ? 'MMMM Do, YYYY h:mma' : format)) + @memoize(format => format ?? 'MMMM Do, YYYY h:mma') formatCommitDate(format?: string | null) { return this.commitDate != null ? formatDate(this.commitDate, format ?? 'MMMM Do, YYYY h:mma') : ''; } @@ -74,7 +74,7 @@ export class GitTag implements GitTagReference { return this.commitDate != null ? fromNow(this.commitDate) : ''; } - @memoize(format => (format == null ? 'MMMM Do, YYYY h:mma' : format)) + @memoize(format => format ?? 'MMMM Do, YYYY h:mma') formatDate(format?: string | null) { return formatDate(this.date, format ?? 'MMMM Do, YYYY h:mma'); }