Options
All
  • Public
  • Public/Protected
  • All
Menu

logic-branch-helpers

logic-branch-helpers

npm CI codecov

TypeScript helpers for logical branches.

Documentation

Example

import { todo, unimplemented, unreachable } from 'logic-branch-helpers';

function isEven(n: number): boolean {
if (n < 1) {
return unimplemented('numbers less than 1');
}
switch (n) {
case 1:
return false;
case 2:
return true;
default:
return todo('support numbers greater than 2');
}
}

type Bit = 0 | 1;

function bitToString(b: Bit): string {
switch (b) {
case 0:
return 'off';
case 1:
return 'on';
default:
return unreachable();
}
}

Generated using TypeDoc