Skip to main content
Module

x/domain_functions/src/index.ts>cf.map

Decouple your business logic from your framework. With first-class type inference from end to end.
Go to Latest
function cf.map
import { cf } from "https://deno.land/x/domain_functions@v2.6.0/src/index.ts";
const { map } = cf;

It takes a Composable and a predicate to apply a transformation over the resulting data. It only runs if the function was successfull. When the given function fails, its error is returned wihout changes.

Examples

import { cf as C } from 'domain-functions'

const increment = C.composable(({ id }: { id: number }) => id + 1) const incrementToString = C.map(increment, String) // ^? Composable

Parameters

fn: T
mapper: (res: UnpackResult<ReturnType<T>>) => R