A lightweight functional library in typescript that helps dealing with failures the rail way
A lightweight functional library in typescript that helps dealing with failures the rail way
Highlights:
- A take on Railway Oriented Programming (ROP) in typescript
- Each function will always yield a failure or a success
- You can easily combine multiple functions into a single unit using operators
- Support for promises
A few examples of commands:
Bind two switch functions:
bindTwo(min3char, valueifyShort)('some text')
Bind three switch functions:
bindThree(min3char, max20char, valueifyShort)('some text')
Bind three similar switch functions:
bindSimilar([min3char, max20char, notDot])('some text')
Bypass a function if it fails:
bypass(addContextToError)(min3char('some text'))
Recovers a function if it fails:
recover(recoverToGood)(min3char('some text'))
Fallback to a different function if the first fail:
orFallback(min3char, fallbackToUppercase)('some text')
Convert a simple transformer to a switch function:
transformToSwitch((value: number) => value * 2)(17)
- Code Maintenance 🔧
- Code Of Conduct
- Api for fairlie-functional
- Contributing 👥 🚧
- Diagram for the code base 📐
- Vocabulary used in the code base 📖
- Architectural Decision Records 📝
- Contributors 👥
- Dependencies
- Glossary 📖
- Software engineering principles 💎
- Overview of Flarebyte.com ecosystem 🏭
- Npm dependencies
This package is ESM only.
yarn add fairlie-functional