Skip to main content
Module

x/fun/option.ts>map

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Latest
function map
import { map } from "https://deno.land/x/fun@v2.0.0/option.ts";

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>