optional-js-flow
v1.0.2
Published
JavaScript Optional type for functional programming with Flow
Downloads
2
Readme
optional-js-flow
JavaScript Optional type for functional programming with Flow
Installation
npm install --save optional-js-flow
Import library
import OptionalFactory from 'optional-js-flow';
import type { Optional } from 'optional-js-flow';
Create Optional type
OptionalFactory.makeOptionalOf<T>(value: T | null | void): Optional<T>
OptionalFactory.makeEmptyOptional<T>(): Optional<T>
Use Optional type
map<U>(map: (value: T) => U): Optional<U>;
orElse(elseValue: T): T;
ifPresent(consume: (value: T) => void): void;
orElseSupplyValue(supplyElseValue: () => T): T;
ifPresentOrElse(consume: (value: T) => void, performAction: () => void): void;
filter(isTrue: (value: T) => boolean): Optional<T>;
flatMap<U>(map: (value: T) => Optional<U>): Optional<U>;
License
MIT License