import { fn } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { flow } = fn;
The flow function is like the pipe function without the initial value. It composes up to 9 functions from left to right (top to bottom). The first function can take multiple arguments but every subsequent function must be unary (only take one argument).
Examples
Example 1
Example 1
import { flow } from "./fn.ts";
const add = (m: number) => (n: number) => m + n;
const multiply = (m: number) => (n: number) => m * n;
const flowed = flow(
add(1),
multiply(2),
add(1),
multiply(2),
);
const result1 = flowed(1); // 10
const result2 = flowed(2); // 14
const result3 = flowed(3); // 18