https://github.com/itsabdelrahman/functional-conditional
🐏 Conditional Logic: The Functional Way
https://github.com/itsabdelrahman/functional-conditional
case else if switch then when
Last synced: 22 days ago
JSON representation
🐏 Conditional Logic: The Functional Way
- Host: GitHub
- URL: https://github.com/itsabdelrahman/functional-conditional
- Owner: itsabdelrahman
- Created: 2019-02-23T13:09:42.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-03T02:38:14.000Z (about 6 years ago)
- Last Synced: 2025-04-12T06:54:30.848Z (22 days ago)
- Topics: case, else, if, switch, then, when
- Language: TypeScript
- Homepage:
- Size: 63.5 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
functional-conditional
Conditional Logic: The Functional Way
## Usage
Turn this:
```ts
let result = null;switch (someValue) {
case 0:
result = 'zero';
break;
case 1:
result = 'one';
break;
case 2:
result = 'two';
break;
}
```Into this:
```ts
import conditional from 'functional-conditional';const result = conditional([
{ if: 0, then: 'zero' },
{ if: 1, then: 'one' },
{ if: 2, then: 'two' },
])(someValue);
```## License
MIT