Skip to content

itsabdelrahman/functional-conditional

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

10 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

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

About

๐Ÿ Conditional Logic: The Functional Way

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published