Function pipe

  • Pipe a stream (or anything else) through a series of single-argument functions/operators

    e.g. the following creates a stream that outputs 4 and then 6:

    pipe(fromIterable([1,2,3,4]), skip(1), take(2), map(x => x*2))
    

    The first argument to pipe() can be any value, but all other arguments must be functions. The value is passed to the first function, and then the result is passed to the next function in turn, until all provided functions have been called with the result of the previous function. The return value is the last result, or the original value if no functions were given.

    The underlying implementation of pipe() works with any number of arguments, but due to TypeScript limitations we only have typing defined for a max of 9 functions (10 arguments total). If you need more than 9 functions, you can stack some of them with compose(), e.g.:

    pipe(
    aStream,
    compose(op1, op2, ...),
    compose(op10, op11, ...),
    compose(op19, ...),
    ...
    )

    Type Parameters

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

    Parameters

    • input: A
    • Rest ...fns: [((v: A) => B), ((v: B) => C), ((v: C) => D), ((v: D) => E), ((v: E) => F), ((v: F) => G), ((v: G) => H), ((v: H) => I), ((v: I) => J)]

    Returns J

  • Type Parameters

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

    Parameters

    • input: A
    • Rest ...fns: [((v: A) => B), ((v: B) => C), ((v: C) => D), ((v: D) => E), ((v: E) => F), ((v: F) => G), ((v: G) => H), ((v: H) => I)]

    Returns I

  • Type Parameters

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

    Parameters

    • input: A
    • Rest ...fns: [((v: A) => B), ((v: B) => C), ((v: C) => D), ((v: D) => E), ((v: E) => F), ((v: F) => G), ((v: G) => H)]

    Returns H

  • Type Parameters

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

    Parameters

    • input: A
    • Rest ...fns: [((v: A) => B), ((v: B) => C), ((v: C) => D), ((v: D) => E), ((v: E) => F), ((v: F) => G)]

    Returns G

  • Type Parameters

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

    Parameters

    • input: A
    • Rest ...fns: [((v: A) => B), ((v: B) => C), ((v: C) => D), ((v: D) => E), ((v: E) => F)]

    Returns F

  • Type Parameters

    • A
    • B
    • C
    • D
    • E

    Parameters

    • input: A
    • Rest ...fns: [((v: A) => B), ((v: B) => C), ((v: C) => D), ((v: D) => E)]

    Returns E

  • Type Parameters

    • A
    • B
    • C
    • D

    Parameters

    • input: A
    • Rest ...fns: [((v: A) => B), ((v: B) => C), ((v: C) => D)]

    Returns D

  • Type Parameters

    • A
    • B
    • C

    Parameters

    • input: A
    • Rest ...fns: [((v: A) => B), ((v: B) => C)]

    Returns C

  • Type Parameters

    • A
    • B

    Parameters

    • input: A
    • Rest ...fns: Chain1<A, B>

    Returns B

  • Type Parameters

    • A

    Parameters

    • input: A

    Returns A

  • Parameters

    • input: any
    • Rest ...fns: ((v: any) => any)[]

    Returns any