0.1.0 • Published 5 years ago

functional-conditional v0.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

Conditional Logic: The Functional Way

Usage

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

License

MIT