Functional Toolbox written in TypeScript.
Inspired by vavr
// Possible usage of the Option class to avoid potential null access.
const someValue: string = 'sample text';
const valueOption = Option.of(someValue);
valueOption.constructor.name // Some
valueOption.isDefined(); // true
valueOption.getOrElse('other'); // 'sample text'
valueOption.get(); // 'sample text'
const nullValue: number = null;
const nullValueOption = Option.of(nullValue);
nullValueOption.constructor.name // None
nullValueOption.isEmpty(); // true
nullValueOption.getOrElse(42); // 42
nullValueOption.get(); // throws new Error('No value present')
Work in progress