import { pipe } from "https://deno.land/x/fun@v2.0.0/fn.ts";
The pipe takes a value as the first argument and composes it with subsequent function arguments, returning the result of the last function passed in. It handles and correctly types up to 10 unary functions. Beyond 10 it makes sense to break up pipe into multiple pipes.
Examples
Example 1
Example 1
import { pipe } from "./fn.ts";
const add = (n: number) => (m: number) => m + n;
const multiply = (n: number) => (m: number) => m * n;
const result = pipe(
1,
add(1), // 2
multiply(2), // 4
add(1), // 5
multiply(2), // 10
); // 10
Parameters
a: A