This repository provides an optional type that allows for cleaner code when dealing with operations that would otherwise return undefined
Refer to the API documentation to see available classes and their functions.
npx
https://github.com/npm/npx. This allows invoking of the other global npm requirements in the repository (Typescript, Jest) without having to install them.You can install the package using
npm i -S @ruffy/ts-optional
You can then use the classes direct as:
Optional.of(undefined) === None.nil
Optional.of(2) === new Some(2)
or you can use the provided helper functions for cleaner code:
optional(undefined) === none
optional(2) === some(2)
Contributions, if they are in line with Monad logic are welcome. Requirements for pull requests are:
Generated using TypeDoc