All files / app / home Statement.tsx

91.66% Statements 11/12
50% Branches 1/2
100% Functions 7/7
91.66% Lines 11/12

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 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54            40x 40x       20x             40x 40x 40x 40x               20x   20x                                 820x 820x        
import Link from 'next/link';
import { Fragment } from 'react';
import type { JSX } from 'react';
import { interleave, pipe } from '@/fns';
 
function getYearsOfExperience(): number {
  const CAREER_YEAR_START = 2012;
  return new Date().getFullYear() - CAREER_YEAR_START;
}
 
function statement(): string {
  return [
    `I’m a seasoned software engineer with ${getYearsOfExperience()} years of professional experience located in West Michigan.`,
    `I specialize in AI augmented software.`,
  ].join(' ');
}
 
function replace(value: string, replacement: JSX.Element) {
  return (words: (string | JSX.Element)[]): (string | JSX.Element)[] => {
    Eif (words.includes(value)) {
      const index = words.indexOf(value);
      return [...words.slice(0, index), replacement, ...words.slice(index + 1)];
    }
 
    return words;
  };
}
 
function Statement(): JSX.Element[] {
  const years = String(getYearsOfExperience());
 
  return interleave(
    pipe(
      replace(
        years,
        <Link className="font-bold" href="/">
          {years}
        </Link>,
      ),
      replace(
        'AI',
        <Link className="font-bold" href="/">
          {'AI'}
        </Link>,
      ),
    )(statement().split(' ')),
    ' ',
  )
    .map((component, key) => [component, key] as const)
    .map(([component, key]) => <Fragment key={key}>{component}</Fragment>);
}
 
export { Statement, statement };