Pacote
    Preparing search index...

    Function pipe

    • Passes a value through a sequence of functions from left to right.

      Type Parameters

      • A

      Parameters

      • initial: A

        Value passed to the first function.

      Returns A

      The result returned by the last function, or initial when no functions are supplied.

      import { pipe } from '@pacote/pipe'

      const doubleSay = (value: string) => `${value}, ${value}`
      const capitalize = (value: string) =>
      value.charAt(0).toUpperCase() + value.slice(1)
      const exclaim = (value: string) => `${value}!`

      pipe('hello', doubleSay, capitalize, exclaim)
      // => 'Hello, hello!'
      // equivalent to exclaim(capitalize(doubleSay('hello')))
    • Passes initial through functions from left to right.

      Type Parameters

      • A
      • B

      Parameters

      • initial: A

        Value passed to the first function.

      • ...fns: Compose1<A, B>

        Functions applied in order; each receives the previous result.

      Returns B

      The result returned by the last function.

    • Passes initial through functions from left to right.

      Type Parameters

      • A
      • B
      • C

      Parameters

      • initial: A

        Value passed to the first function.

      • ...fns: Compose2<A, B, C>

        Functions applied in order; each receives the previous result.

      Returns C

      The result returned by the last function.

    • Passes initial through functions from left to right.

      Type Parameters

      • A
      • B
      • C
      • D

      Parameters

      • initial: A

        Value passed to the first function.

      • ...fns: Compose3<A, B, C, D>

        Functions applied in order; each receives the previous result.

      Returns D

      The result returned by the last function.

    • Passes initial through functions from left to right.

      Type Parameters

      • A
      • B
      • C
      • D
      • E

      Parameters

      • initial: A

        Value passed to the first function.

      • ...fns: Compose4<A, B, C, D, E>

        Functions applied in order; each receives the previous result.

      Returns E

      The result returned by the last function.

    • Passes initial through functions from left to right.

      Type Parameters

      • A
      • B
      • C
      • D
      • E
      • F

      Parameters

      • initial: A

        Value passed to the first function.

      • ...fns: Compose5<A, B, C, D, E, F>

        Functions applied in order; each receives the previous result.

      Returns F

      The result returned by the last function.

    • Passes initial through functions from left to right.

      Type Parameters

      • A
      • B
      • C
      • D
      • E
      • F
      • G

      Parameters

      • initial: A

        Value passed to the first function.

      • ...fns: Compose6<A, B, C, D, E, F, G>

        Functions applied in order; each receives the previous result.

      Returns G

      The result returned by the last function.

    • Passes initial through functions from left to right.

      Type Parameters

      • A
      • B
      • C
      • D
      • E
      • F
      • G
      • H

      Parameters

      • initial: A

        Value passed to the first function.

      • ...fns: Compose7<A, B, C, D, E, F, G, H>

        Functions applied in order; each receives the previous result.

      Returns H

      The result returned by the last function.

    • Passes initial through functions from left to right.

      Type Parameters

      • A
      • B
      • C
      • D
      • E
      • F
      • G
      • H
      • I

      Parameters

      • initial: A

        Value passed to the first function.

      • ...fns: Compose8<A, B, C, D, E, F, G, H, I>

        Functions applied in order; each receives the previous result.

      Returns I

      The result returned by the last function.