@vgerbot/async
    Preparing search index...

    Function seq

    • Composes async functions from left to right (sequential composition). The leftmost function is called first, and its result is passed to the next function. This is the reverse of compose and matches the execution order visually.

      Type Parameters

      • T1
      • T2

      Parameters

      • fn1: AsyncFunction<T1, T2>

      Returns (input: T1, options?: CancellableOptions<unknown>) => CancellableHandle<T2>

      A composed function that executes all functions in sequence.

      const addOne = async (n: number) => n + 1;
      const double = async (n: number) => n * 2;
      const square = async (n: number) => n * n;

      const sequenced = seq(addOne, double, square);
      const handle = sequenced(5); // ((5 + 1) * 2) ^ 2 = 144
      const result = await handle; // 144
    • Composes async functions from left to right (sequential composition). The leftmost function is called first, and its result is passed to the next function. This is the reverse of compose and matches the execution order visually.

      Type Parameters

      • T1
      • T2
      • T3

      Parameters

      • fn1: AsyncFunction<T1, T2>
      • fn2: AsyncFunction<T2, T3>

      Returns (input: T1, options?: CancellableOptions<unknown>) => CancellableHandle<T3>

      A composed function that executes all functions in sequence.

      const addOne = async (n: number) => n + 1;
      const double = async (n: number) => n * 2;
      const square = async (n: number) => n * n;

      const sequenced = seq(addOne, double, square);
      const handle = sequenced(5); // ((5 + 1) * 2) ^ 2 = 144
      const result = await handle; // 144
    • Composes async functions from left to right (sequential composition). The leftmost function is called first, and its result is passed to the next function. This is the reverse of compose and matches the execution order visually.

      Type Parameters

      • T1
      • T2
      • T3
      • T4

      Parameters

      • fn1: AsyncFunction<T1, T2>
      • fn2: AsyncFunction<T2, T3>
      • fn3: AsyncFunction<T3, T4>

      Returns (input: T1, options?: CancellableOptions<unknown>) => CancellableHandle<T4>

      A composed function that executes all functions in sequence.

      const addOne = async (n: number) => n + 1;
      const double = async (n: number) => n * 2;
      const square = async (n: number) => n * n;

      const sequenced = seq(addOne, double, square);
      const handle = sequenced(5); // ((5 + 1) * 2) ^ 2 = 144
      const result = await handle; // 144
    • Composes async functions from left to right (sequential composition). The leftmost function is called first, and its result is passed to the next function. This is the reverse of compose and matches the execution order visually.

      Type Parameters

      • T1
      • T2
      • T3
      • T4
      • T5

      Parameters

      • fn1: AsyncFunction<T1, T2>
      • fn2: AsyncFunction<T2, T3>
      • fn3: AsyncFunction<T3, T4>
      • fn4: AsyncFunction<T4, T5>

      Returns (input: T1, options?: CancellableOptions<unknown>) => CancellableHandle<T5>

      A composed function that executes all functions in sequence.

      const addOne = async (n: number) => n + 1;
      const double = async (n: number) => n * 2;
      const square = async (n: number) => n * n;

      const sequenced = seq(addOne, double, square);
      const handle = sequenced(5); // ((5 + 1) * 2) ^ 2 = 144
      const result = await handle; // 144