Tweakr
    Preparing search index...

    Function pipeAsync

    • Composes multiple functions into a single async pipeline.

      Each function is invoked in sequence, passing the result of the previous function to the next. Supports both synchronous and asynchronous functions, but the pipeline always returns a Promise.

      Type Parameters

      • T

        The type of the initial input value.

      Parameters

      • ...fns: ((arg: any) => any)[]

        An array of functions to compose. Each function receives the result of the previous function.

      Returns (input: T) => Promise<any>

      A function that takes an initial input and returns a Promise resolving to the final result after all functions have been applied.

      1.1.0

      const add = async (x: number) => x + 1;
      const double = (x: number) => x * 2;

      const pipeline = pipeAsync<number>(add, double);
      const result = await pipeline(3); // ((3 + 1) * 2) = 8