All files / src/elements heading.ts

100% Statements 10/10
100% Branches 5/5
100% Functions 2/2
100% Lines 10/10

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 111x 1x 1x 1x 1x 116x 114x 114x 2x 2x  
export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
 
const isInHeadingLevelRange = (level: HeadingLevel) => level >= 1 && level <= 6;
 
export const heading = (level: HeadingLevel, text: string) => {
  if (isInHeadingLevelRange(level)) {
    return `${'#'.repeat(level)} ${text}`;
  }
  throw new Error('level must be between 1 and 6');
};