A lightweight functional library in typescript that helps dealing with failures the rail way
npm install fairlie-functional!npm !Build status !npm bundle size
!npm type definitions !node-current !NPM
> 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
!Hero image for fairlie-functional
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:
``typescript
bindTwo(min3char, valueifyShort)('some text')
``
Bind three switch functions:typescript
bindThree(min3char, max20char, valueifyShort)('some text')
``
Bind three similar switch functions:typescript
bindSimilar([min3char, max20char, notDot])('some text')
``
Bypass a function if it fails:typescript
bypass(addContextToError)(min3char('some text'))
``
Recovers a function if it fails:typescript
recover(recoverToGood)(min3char('some text'))
``
Fallback to a different function if the first fail:typescript
orFallback(min3char, fallbackToUppercase)('some text')
``
Convert a simple transformer to a switch function:typescript
transformToSwitch((value: number) => value * 2)(17)
`
* Code Maintenance :wrench:
* Code Of Conduct
* Api for fairlie-functional
* Contributing :busts_in_silhouette: :construction:
* Diagram for the code base :triangular_ruler:
* Vocabulary used in the code base :book:
* Architectural Decision Records :memo:
* Contributors :busts_in_silhouette:
* Dependencies
* Glossary :book:
* Software engineering principles :gem:
* Overview of Flarebyte.com ecosystem :factory:
* Npm dependencies
This package is ESM only.
`bash``
yarn add fairlie-functional