All files / src/utils grammar.ts

100% Statements 10/10
100% Branches 8/8
100% Functions 2/2
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14    3x 2x 1x       4x 3x 1x      
export class Grammar {
  static or(...values: any[]): string {
    if (values.length === 1) return values[0];
    else if (values.length === 2) return `${values[0]} or ${values[1]}`;
    return `${values.slice(0, values.length - 1).join(', ')}, or ${values.slice(values.length - 1)}`;
  }
 
  static and(...values: any[]): string {
    if (values.length === 1) return values[0];
    else if (values.length === 2) return `${values[0]} and ${values[1]}`;
    return `${values.slice(0, values.length - 1).join(', ')}, and ${values.slice(values.length - 1)}`;
  }
}