Options
All
  • Public
  • Public/Protected
  • All
Menu

@cosmjs/stream Documentation

Index

Type Aliases

ReducerFunc<T, U>: ((acc: U, evt: T) => U)

Type Parameters

  • T

  • U

Type declaration

    • (acc: U, evt: T): U
    • Parameters

      • acc: U
      • evt: T

      Returns U

SameTypeStreamOperator<T>: ((ins: Stream<T>) => Stream<T>)

Type Parameters

  • T

Type declaration

    • (ins: Stream<T>): Stream<T>
    • The type that fits into Stream.compose() with input stream and output stream of the same type.

      Parameters

      • ins: Stream<T>

      Returns Stream<T>

Functions

  • asArray<T>(stream: Stream<T>): Reducer<T, readonly T[]>
  • concat<T>(...streams: Stream<T>[]): Stream<T>
  • An implementation of concat that buffers all source stream events

    Marble diagram:

    --1--2---3---4-|
    -a--b-c--d-|
    --------X---------Y---------Z-
              concat
    --1--2---3---4-abcdXY-------Z-
    

    This is inspired by RxJS's concat as documented at http://rxmarbles.com/#concat and behaves differently than xstream's concat as discussed in https://github.com/staltz/xstream/issues/170.

    Type Parameters

    • T

    Parameters

    • Rest ...streams: Stream<T>[]

    Returns Stream<T>

  • countStream<T>(stream: Stream<T>): Reducer<T, number>
  • Drops duplicate values in a stream.

    Marble diagram:

    -1-1-1-2-4-3-3-4--
      dropDuplicates
    -1-----2-4-3------
    

    Each value must be uniquely identified by a string given by valueToKey(value).

    Internally this maintains a set of keys that have been processed already, i.e. memory consumption and Set lookup times should be considered when using this function.

    Type Parameters

    • T

    Parameters

    • valueToKey: ((x: T) => string)
        • (x: T): string
        • Parameters

          • x: T

          Returns string

    Returns SameTypeStreamOperator<T>

  • firstEvent<T>(stream: Stream<T>): Promise<T>
  • Listens to stream, collects one event and revolves.

    Rejects if stream completes before one event was fired.

    Type Parameters

    • T

    Parameters

    • stream: Stream<T>

    Returns Promise<T>

  • fromListPromise<T>(promise: Promise<Iterable<T>>): Stream<T>
  • Emits one event for each list element as soon as the promise resolves

    Type Parameters

    • T

    Parameters

    • promise: Promise<Iterable<T>>

    Returns Stream<T>

  • lastValue<T>(stream: Stream<T>): Reducer<T, T | undefined>
  • Type Parameters

    • T

    Parameters

    • stream: Stream<T>

    Returns Reducer<T, T | undefined>

  • toListPromise<T>(stream: Stream<T>, count: number): Promise<readonly T[]>
  • Listens to stream and collects events. When count events are collected, the promise resolves with an array of events.

    Rejects if stream completes before count events are collected.

    Type Parameters

    • T

    Parameters

    • stream: Stream<T>
    • count: number

    Returns Promise<readonly T[]>

Generated using TypeDoc