optional-js-flow

1.0.2 • Public • Published

optional-js-flow

JavaScript Optional type for functional programming with Flow

version build coverage MIT License

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

Package Sidebar

Install

npm i optional-js-flow

Weekly Downloads

3

Version

1.0.2

License

MIT

Unpacked Size

15.4 kB

Total Files

15

Last publish

Collaborators

  • pksilen