Interface Stream<P, T, F>

Type Parameters

  • P

  • T

  • F extends boolean = false

Hierarchy

  • Stream

Properties

makeProducer: ((onData: ((data: P) => Promise<boolean>), onEnd: ((eof: boolean) => void)) => Promise<void>)

Type declaration

    • (onData: ((data: P) => Promise<boolean>), onEnd: ((eof: boolean) => void)): Promise<void>
    • Parameters

      • onData: ((data: P) => Promise<boolean>)
          • (data: P): Promise<boolean>
          • Parameters

            • data: P

            Returns Promise<boolean>

      • onEnd: ((eof: boolean) => void)
          • (eof: boolean): void
          • Parameters

            • eof: boolean

            Returns void

      Returns Promise<void>

stopProducer: (() => void)

Type declaration

    • (): void
    • Returns void

isFinite: F
fold: F extends true ? (<B>(init: B, f: ((init: B, item: T) => B | Promise<B>)) => Promise<B>) : never

Folds every element into an accumulator by applying an operation, returning the final result

finished: F extends true ? (() => Promise<void>) : never

Waits until the end of the stream

Methods

  • Waits for the first element or the end of the stream

    Returns Promise<F extends true ? undefined | T : T>

  • Executes handler on each item

    Parameters

    • handler: ((item: T) => void | Promise<void>)
        • (item: T): void | Promise<void>
        • Parameters

          • item: T

          Returns void | Promise<void>

    Returns void

  • Creates a stream which gives the current iteration count as well as the value

    Returns Stream<P, {
        index: number;
        item: T;
    }, F>

  • Alias for the .map((item) => { f(item); return item; })

    Parameters

    • handler: ((item: T) => void | Promise<void>)
        • (item: T): void | Promise<void>
        • Parameters

          • item: T

          Returns void | Promise<void>

    Returns Stream<P, T, F>

  • Skip elements where f(item) == false

    Parameters

    • f: ((item: T) => boolean | Promise<boolean>)
        • (item: T): boolean | Promise<boolean>
        • Parameters

          • item: T

          Returns boolean | Promise<boolean>

    Returns Stream<P, T, F>

  • Modifies items and skip all undefined

    Type Parameters

    • U

    Parameters

    • f: ((item: T) => undefined | U | Promise<undefined | U>)
        • (item: T): undefined | U | Promise<undefined | U>
        • Parameters

          • item: T

          Returns undefined | U | Promise<undefined | U>

    Returns Stream<P, U, F>

  • Modifies items

    Type Parameters

    • U

    Parameters

    • f: ((item: T) => U | Promise<U>)
        • (item: T): U | Promise<U>
        • Parameters

          • item: T

          Returns U | Promise<U>

    Returns Stream<P, U, F>

  • Creates an iterator that flattens nested structure

    Type Parameters

    • U

    Parameters

    • f: ((item: T) => U[] | Promise<U[]>)
        • (item: T): U[] | Promise<U[]>
        • Parameters

          • item: T

          Returns U[] | Promise<U[]>

    Returns Stream<P, U, F>

  • Creates an iterator that skips the first n elements

    Parameters

    • n: number

    Returns Stream<P, T, F>

  • Creates an iterator that skips elements based on a predicate

    Parameters

    • f: ((item: T) => boolean | Promise<boolean>)
        • (item: T): boolean | Promise<boolean>
        • Parameters

          • item: T

          Returns boolean | Promise<boolean>

    Returns Stream<P, T, F>

  • Creates an iterator that yields the first n elements, or fewer if the underlying iterator ends sooner

    Parameters

    • n: number

    Returns Stream<P, T, true>

  • Creates an iterator that yields elements based on a predicate

    Parameters

    • f: ((item: T) => boolean | Promise<boolean>)
        • (item: T): boolean | Promise<boolean>
        • Parameters

          • item: T

          Returns boolean | Promise<boolean>

    Returns Stream<P, T, true>

  • Creates an iterator that yields mapped elements based on a predicate until first undefined is found

    Type Parameters

    • U

    Parameters

    • f: ((item: T) => undefined | U | Promise<undefined | U>)
        • (item: T): undefined | U | Promise<undefined | U>
        • Parameters

          • item: T

          Returns undefined | U | Promise<undefined | U>

    Returns Stream<P, U, true>