Function pipe

  • Composes multiple functions into a single function that can be called with multiple arguments.

    Type Parameters

    • A extends unknown[]
    • R

    Parameters

    • fn1: ((...x: A) => R)
        • (...x): R
        • Parameters

          • Rest...x: A

          Returns R

    Returns typeof fn1

    const add = (a: number, b: number) => a + b;
    const byTwo = (x: number) => x * 2;
    const composedFn = pipe(add, byTwo);
    composedFn(1, 2) // 6
  • Type Parameters

    • A extends unknown[]
    • B
    • R

    Parameters

    • fn1: ((...x: A) => B)
        • (...x): B
        • Parameters

          • Rest...x: A

          Returns B

    • fn2: ((x: B) => R)
        • (x): R
        • Parameters

          Returns R

    Returns ((...a: A) => R)

      • (...a): R
      • Parameters

        • Rest...a: A

        Returns R

  • Type Parameters

    • A extends unknown[]
    • B
    • C
    • R

    Parameters

    • fn1: ((...x: A) => B)
        • (...x): B
        • Parameters

          • Rest...x: A

          Returns B

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

          Returns C

    • fn3: ((x: C) => R)
        • (x): R
        • Parameters

          Returns R

    Returns ((...a: A) => R)

      • (...a): R
      • Parameters

        • Rest...a: A

        Returns R

  • Type Parameters

    • A extends unknown[]
    • B
    • C
    • D
    • R

    Parameters

    • fn1: ((...x: A) => B)
        • (...x): B
        • Parameters

          • Rest...x: A

          Returns B

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

          Returns C

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

          Returns D

    • fn4: ((x: D) => R)
        • (x): R
        • Parameters

          Returns R

    Returns ((...a: A) => R)

      • (...a): R
      • Parameters

        • Rest...a: A

        Returns R

  • Type Parameters

    • A extends unknown[]
    • B
    • C
    • D
    • E
    • R

    Parameters

    • fn1: ((...x: A) => B)
        • (...x): B
        • Parameters

          • Rest...x: A

          Returns B

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

          Returns C

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

          Returns D

    • fn4: ((x: D) => E)
        • (x): E
        • Parameters

          Returns E

    • fn5: ((x: E) => R)
        • (x): R
        • Parameters

          Returns R

    Returns ((...a: A) => R)

      • (...a): R
      • Parameters

        • Rest...a: A

        Returns R

  • Type Parameters

    • A extends unknown[]
    • B
    • C
    • D
    • E
    • F
    • R

    Parameters

    • fn1: ((...x: A) => B)
        • (...x): B
        • Parameters

          • Rest...x: A

          Returns B

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

          Returns C

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

          Returns D

    • fn4: ((x: D) => E)
        • (x): E
        • Parameters

          Returns E

    • fn5: ((x: E) => F)
        • (x): F
        • Parameters

          Returns F

    • fn6: ((x: F) => R)
        • (x): R
        • Parameters

          Returns R

    Returns ((...a: A) => R)

      • (...a): R
      • Parameters

        • Rest...a: A

        Returns R

  • Type Parameters

    • A extends unknown[]
    • B
    • C
    • D
    • E
    • F
    • G
    • R

    Parameters

    • fn1: ((...x: A) => B)
        • (...x): B
        • Parameters

          • Rest...x: A

          Returns B

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

          Returns C

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

          Returns D

    • fn4: ((x: D) => E)
        • (x): E
        • Parameters

          Returns E

    • fn5: ((x: E) => F)
        • (x): F
        • Parameters

          Returns F

    • fn6: ((x: F) => G)
        • (x): G
        • Parameters

          Returns G

    • fn7: ((x: G) => R)
        • (x): R
        • Parameters

          Returns R

    Returns ((...a: A) => R)

      • (...a): R
      • Parameters

        • Rest...a: A

        Returns R

  • Type Parameters

    • A extends unknown[]
    • B
    • C
    • D
    • E
    • F
    • G
    • H
    • R

    Parameters

    • fn1: ((...x: A) => B)
        • (...x): B
        • Parameters

          • Rest...x: A

          Returns B

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

          Returns C

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

          Returns D

    • fn4: ((x: D) => E)
        • (x): E
        • Parameters

          Returns E

    • fn5: ((x: E) => F)
        • (x): F
        • Parameters

          Returns F

    • fn6: ((x: F) => G)
        • (x): G
        • Parameters

          Returns G

    • fn7: ((x: G) => H)
        • (x): H
        • Parameters

          Returns H

    • fn8: ((x: H) => R)
        • (x): R
        • Parameters

          Returns R

    Returns ((...a: A) => R)

      • (...a): R
      • Parameters

        • Rest...a: A

        Returns R

  • Type Parameters

    • A extends unknown[]
    • B
    • C
    • D
    • E
    • F
    • G
    • H
    • I
    • R

    Parameters

    • fn1: ((...x: A) => B)
        • (...x): B
        • Parameters

          • Rest...x: A

          Returns B

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

          Returns C

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

          Returns D

    • fn4: ((x: D) => E)
        • (x): E
        • Parameters

          Returns E

    • fn5: ((x: E) => F)
        • (x): F
        • Parameters

          Returns F

    • fn6: ((x: F) => G)
        • (x): G
        • Parameters

          Returns G

    • fn7: ((x: G) => H)
        • (x): H
        • Parameters

          Returns H

    • fn8: ((x: H) => I)
        • (x): I
        • Parameters

          Returns I

    • fn9: ((x: I) => R)
        • (x): R
        • Parameters

          Returns R

    Returns ((...a: A) => R)

      • (...a): R
      • Parameters

        • Rest...a: A

        Returns R