Skip to content

JavaScript Optional type for functional programming with Flow

License

Notifications You must be signed in to change notification settings

pksilen/optional-js-flow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

JavaScript Optional type for functional programming with Flow

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published