functional-conditional
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

functional-conditional

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

Package Sidebar

Install

npm i functional-conditional

Weekly Downloads

0

Version

0.1.0

License

MIT

Unpacked Size

3.44 kB

Total Files

8

Last publish

Collaborators

  • ar-maged