Function flow

  • Similar to pipe, except that it returns a function which takes as its parameter the initial value for the pipe in order to support point-free style. Though point-free style can make for concise code, be aware that type-inference for flow may be less robust than for pipe due to its data-last form.

    Remarks

    The implementation contains types to support up to twelve transformations. All overload signatures follow the same pattern as the representative form shown here.

    Example

    import { flow } from "flurp";
    import * as N from "flurp/number";

    const applyPipe = flow(
    N.multiply(2), // 6 so far
    N.ad(4.2), // 10.2 so far
    Math.round
    );

    applyPipe(3) // 10

    Type Parameters

    • A extends unknown[]

    • B

    • C

    • D

    Parameters

    • f1: ((...xs: A) => B)
        • (...xs: A): B
        • Parameters

          • Rest ...xs: A

          Returns B

    • f2: ((x: B) => C)
        • (x: B): C
        • Parameters

          • x: B

          Returns C

    • f3: ((x: C) => D)
        • (x: C): D
        • Parameters

          • x: C

          Returns D

    Returns ((...xs: A) => D)

      • (...xs: A): D
      • Parameters

        • Rest ...xs: A

        Returns D