Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PromiseExecutor<Input, Output>

Class which executes a task over a data set.

Type parameters

  • Input

  • Output

Hierarchy

  • PromiseExecutor

Properties

Static Readonly PARALLEL

PARALLEL: number = ...

Static Readonly SEQUENTIAL

SEQUENTIAL: 0 = 0

Methods

execute

  • execute(): Promise<Output[]>
  • Execute processor over data set.

    Returns Promise<Output[]>

    Processing results.

Static command

  • command<I, O>(processor: AsyncFunction<I, O>, data: readonly I[], concurrency: number): PromiseExecutor<I, O>
  • Creates a new PromiseExecutor which encapsulates task that needs to be run over data set.
    Follows Command Design Pattern.

    Type parameters

    • I

    • O

    Parameters

    • processor: AsyncFunction<I, O>

      Processing function.

    • data: readonly I[]

      Data Set.

    • concurrency: number

      Processing concurrency. Can take the following values:
      - 0 - data will be processed in sequential order
      - [1, Infinity) - data will be processed in batches of concurrency size
      - Infinity - all data will be processed in parallel

    Returns PromiseExecutor<I, O>

Static formatConcurrency

  • formatConcurrency(concurrency: number): string
  • Formats concurrency to human readable format.

    Parameters

    • concurrency: number

      Processing concurrency.

    Returns string

Static run

  • run<I, O>(processor: AsyncFunction<I, O>, data: readonly I[], concurrency: number): Promise<O[]>
  • Runs processor over data with specified concurrency.

    Type parameters

    • I

    • O

    Parameters

    • processor: AsyncFunction<I, O>

      Processing function.

    • data: readonly I[]

      Data Set.

    • concurrency: number

      Processing concurrency. Can take the following values:
      - 0 - data will be processed in sequential order
      - [1, Infinity) - data will be processed in batches of concurrency size
      - Infinity - all data will be processed in parallel

    Returns Promise<O[]>

    Processing results.