logic-branch-helpers
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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();
  }
}

Readme

Keywords

Package Sidebar

Install

npm i logic-branch-helpers

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

9.24 kB

Total Files

15

Last publish

Collaborators

  • spenserblack