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

x/fun/fn.ts>compose

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

Compose two functions by taking the output of one and passing it to another. This is equivalent to the map function.

Examples

Example 1

import { compose, pipe } from "./fn.ts";

const length = (s: string) => s.length;
const dup = (n: number) => n + n;

const composed = pipe(
  length,
  compose(dup),
);

const result1 = composed("Hello"); // 10
const result2 = composed(""); // 0

Parameters

second: Fn<A, I>

Returns

<D>(first: Fn<D, A>) => Fn<D, I>