Skip to content

asyncPipe<T>

Utility function that allows for piping a series of async functions together that operate on a common type T

Usage

ts
import { asyncPipe } from "@alchemy/aa-core";

const addOne = async (num: number) => num + 1;
const addTwo = async (num: number) => num + 2;

const result = await asyncPipe(addOne, addTwo)(0);

Returns

T

The result of the last function in the pipe chain

Parameters

fns: Array<(x: T) => Promise<T>>

The array of functions to pipe together