logic-branch-helpers
v1.0.1
Published
Helpers for logical branches
Downloads
4
Readme
logic-branch-helpers
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();
}
}