Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fun/mod.ts>option.map

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Go to Latest
function option.map
import { option } from "https://deno.land/x/fun@v.2.0.0-alpha.11/mod.ts";
const { map } = option;

Apply the mapping function fai to the inner value of an Option if it exists. If the option is None then this function does nothing.

Examples

Example 1

import * as O from "./option.ts";
import { pipe } from "./fn.ts";

const result1 = pipe(O.some(1), O.map(n => n + 1)); // Some(2)
const result2 = pipe(O.none, O.map((n: number) => n + 1)); // None

Parameters

fai: (a: A) => I

Returns

(ua: Option<A>) => Option<I>