Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ParallelStream<TSubResult, TEndResult>

Generic parallel stream that can be coordinated using the provided next, resolve and reject callbacks.

Type parameters

  • TSubResult

    type of the sub results

  • TEndResult

    type of the end result

Hierarchy

  • ParallelStream

Implements

Index

Constructors

constructor

Properties

Private nextHandlers

nextHandlers: NextHandler<TSubResult>[] = []

Registered handlers that should be called for each sub result

type

{Array}

Private promise

promise: Promise<TEndResult>

Private reject

reject: function

Type declaration

    • (reason: any): void
    • Parameters

      • reason: any

      Returns void

Private resolve

resolve: function

Type declaration

    • (result: TEndResult): void
    • Parameters

      • result: TEndResult

      Returns void

Methods

Private _next

  • _next(subResult: TSubResult, taskIndex: number, valuesPerTask: number): void

catch

  • catch<TResult>(onrejected: function): Promise<TResult | TEndResult>
  • catch(onrejected: function): Promise<TEndResult>
  • Type parameters

    • TResult

    Parameters

    • onrejected: function
        • (reason: any): TResult | PromiseLike<TResult>
        • Parameters

          • reason: any

          Returns TResult | PromiseLike<TResult>

    Returns Promise<TResult | TEndResult>

  • Parameters

    • onrejected: function
        • (reason: any): TEndResult | PromiseLike<TEndResult>
        • Parameters

          • reason: any

          Returns TEndResult | PromiseLike<TEndResult>

    Returns Promise<TEndResult>

subscribe

  • subscribe(onNext: function, onError?: undefined | function, onComplete?: undefined | function): IParallelStream<TSubResult, TEndResult>
  • Parameters

    • onNext: function
        • (subResult: TSubResult, taskIndex: number, valuesPerWorker: number): void
        • Parameters

          • subResult: TSubResult
          • taskIndex: number
          • valuesPerWorker: number

          Returns void

    • Optional onError: undefined | function
    • Optional onComplete: undefined | function

    Returns IParallelStream<TSubResult, TEndResult>

then

  • then<TResult1, TResult2>(onfulfilled: function, onrejected: function): Promise<TResult2 | TResult1>
  • then<TResult>(onfulfilled: function, onrejected: function): Promise<TResult>
  • then<TResult>(onfulfilled: function): IPromise<TResult>
  • then<TResult>(onfulfilled?: undefined | function, onrejected?: undefined | function): Promise<TResult>
  • then<TResult>(onfulfilled?: undefined | function, onrejected?: undefined | function): Promise<TResult>
  • Type parameters

    • TResult1

    • TResult2

    Parameters

    • onfulfilled: function
        • (value: TEndResult): TResult1 | PromiseLike<TResult1>
        • Parameters

          • value: TEndResult

          Returns TResult1 | PromiseLike<TResult1>

    • onrejected: function
        • (reason: any): TResult2 | PromiseLike<TResult2>
        • Parameters

          • reason: any

          Returns TResult2 | PromiseLike<TResult2>

    Returns Promise<TResult2 | TResult1>

  • Type parameters

    • TResult

    Parameters

    • onfulfilled: function
        • (value: TEndResult): TResult | PromiseLike<TResult>
        • Parameters

          • value: TEndResult

          Returns TResult | PromiseLike<TResult>

    • onrejected: function
        • (reason: any): TResult | PromiseLike<TResult>
        • Parameters

          • reason: any

          Returns TResult | PromiseLike<TResult>

    Returns Promise<TResult>

  • Type parameters

    • TResult

    Parameters

    • onfulfilled: function
        • (value: TEndResult): TResult | PromiseLike<TResult>
        • Parameters

          • value: TEndResult

          Returns TResult | PromiseLike<TResult>

    Returns IPromise<TResult>

  • Type parameters

    • TResult

    Parameters

    • Optional onfulfilled: undefined | function
    • Optional onrejected: undefined | function

    Returns Promise<TResult>

  • Type parameters

    • TResult

    Parameters

    • Optional onfulfilled: undefined | function
    • Optional onrejected: undefined | function

    Returns Promise<TResult>

Static fromTasks

  • fromTasks<TTaskResult, TEndResult>(tasks: ITask<TTaskResult>[], defaultResult: TEndResult, joiner: function): IParallelStream<TTaskResult, TEndResult>
  • Creates a new parallel stream for the given set of tasks.

    Type parameters

    • TTaskResult

      type of the task results

    • TEndResult

      result of the created stream. Created by applying the end results of the stream to the joiner

    Parameters

    • tasks: ITask<TTaskResult>[]

      the set of tasks that compute the results of the stream

    • defaultResult: TEndResult

      the default result

    • joiner: function

      the joiner to use to join two computed task results

        • (memo: TTaskResult, current: TTaskResult): TEndResult
        • Parameters

          • memo: TTaskResult
          • current: TTaskResult

          Returns TEndResult

    Returns IParallelStream<TTaskResult, TEndResult>

    stream for the given set of tasks

Static transform

  • Creates a new parallel that is based on the given input stream but transforms the end result using the given transformer

    Type parameters

    • TIn

      type of the input elements for this stream

    • TIntermediate

      type of the end results from the input stream

    • TResult

      end result after applying the transformer.

    Parameters

    • inputStream: IParallelStream<TIn, TIntermediate>

      the input stream on which the returned stream is based on

    • transformer: function

      the transformer used to transform the end result

        • (result: TIntermediate): TResult
        • Parameters

          • result: TIntermediate

          Returns TResult

    Returns ParallelStream<TIn, TResult>

    parallel stream that is based on the given input stream but with the transformed end result

Generated using TypeDoc