import { default } from "https://deno.land/x/froebel@v0.21.0/pipe.ts";
Given a list of functions returns a function that will execute the given functions one after another, always passing the result of the previous function as an argument to the next function.
If one of the given functions returns a promise, the promise will be resolved before being passed to the next function.
Examples
Example 1
Example 1
const join = (...chars: string[]) => chars.join('')
pipe(join, parseInt)('1', '2', '3') // -> 123
const square = (n: number) => n ** 2
// this is equivalent to: square(square(square(2)))
pipe(square, square, square)(2) // -> 256
// also works with promises:
fetchNumber :: async () => Promise<number>
pipe(fetchNumber, n => n.toString()) // async () => Promise<string>