Turn this:
let result = null;
switch (someValue) {
case 0:
result = 'zero';
break;
case 1:
result = 'one';
break;
case 2:
result = 'two';
break;
}
Into this:
import conditional from 'functional-conditional';
const result = conditional<number, string>([
{ if: 0, then: 'zero' },
{ if: 1, then: 'one' },
{ if: 2, then: 'two' },
])(someValue);
MIT