Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

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

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

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