import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'pluralSingular'
})
export class PluralSingularPipe implements PipeTransform {

  transform(num: number, singularText: string, pluralText: string = null, counts = true): string {
    const pluralWord = pluralText ? pluralText : `${singularText}s`;
    if (counts) {
      return num > 1 ? `${num} ${pluralWord}` : `${num} ${singularText}` ;
    } else {
      return num > 1 ? `${pluralWord}` : `${singularText}` ;
    }
  }

}
