Optional
This library provides java-like optionals to filter, map and process values depending on if they're present or not.
I created this lib because I like functional programming think that Optionals are a good way to clean up code.
Yes, I know that typescript has the optional operator (?
) but sometimes this isn't enough, like when I want to filter values or fail instantly if a value is empty.
How to use
Install it with yarn or npm using yarn add @mrdrogdrog/optional
or npm i @mrdrogdrog/optional
.
API
In addition to the traditional java-like optional functions I added some more useful functions like isEmpty, orThrow and guard. Check the docs folder for the whole API.
Build
You can build this lib by running yarn build
.
Run tests with yarn test
.
To check the code style use yarn lint
.
Contributions
I welcome contributions! Have a look at the contribution docs to find out how you can help.
License
Licensed under MIT. For our list of contributors, see AUTHORS.