bind
If is Some
, then binds the value of the Option
to another Option
.
If is None
, then does nothing.
Type
type bind = <E,F>(e: UnaryFunction<E, F>) => (option:Option<E>) => Option<F>
Examples
import {bind, Some} from 'fnxt/option';
const plusOne = bind((x: number) => Some(x + 1));
plusOne(Some(42)) // -> Some(43)
import {bind, None} from 'fnxt/option';
const plusOne = bind((x: number) => x + 1);
plusOne(None) // -> None