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