Add ensureListingDetails to prevent redundancy

This commit is contained in:
Sam Carlton 2022-06-09 14:08:55 -05:00
parent 98099df011
commit 1055f80429

View file

@ -93,6 +93,8 @@ export class ListingDetails {
type = '' type = ''
isListingDetails = true
get mainHeading () { get mainHeading () {
if ( this.type === 'formula' ) { if ( this.type === 'formula' ) {
return `Does <code>${ this.api.name }</code> work on Apple Silicon when installed via Homebrew?` return `Does <code>${ this.api.name }</code> work on Apple Silicon when installed via Homebrew?`
@ -176,3 +178,12 @@ export class ListingDetails {
} }
} }
} }
export function ensureListingDetails ( listing ) {
if ( listing.isListingDetails ) {
return listing
}
return new ListingDetails( listing )
}