map<T, R> function

Option<R> Function(Option<T> option) map<T, R>(
  1. R f(
    1. T value
    )
)

Transform the wrapped value if the Option is a Some, using the provided function.

expect(
  O.some(1).chain(O.map((i) => i * 2)),
  equals(O.some(2)),
);

Implementation

Option<R> Function(Option<T> option) map<T, R>(
  R Function(T value) f,
) =>
    flatMap((a) => some(f(a)));