Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "forkjoin"

Index

Type aliases

Sliceable

Sliceable<T>: ArrayLike<T> & { slice: any }

Type parameters

  • T

Functions

Const forkBuffer

  • forkBuffer(minChunkSize?: number): (Anonymous function)
  • Higher-order fork function for scenarios involving the split-parallel processing of a large buffer.

    remarks

    The returned function is meant to be used as fork function in a ForkJoinOpts config and extracts a workload slice of the original buffer for a single worker. The HOF itself takes a minimum chunk size as optional parameter (default: 1).

    Note: Depending on the configured minChunkSize and the size of the input buffer to be partitioned, the returned fork function might produce empty sub-arrays for some workers, iff the configured number of workers exceeds the resulting number of chunks / input values. E.g. If the number of workers = 8, buffer size = 10 and min chunk size = 2, then the last 3 (i.e. 8 - 10 / 2) workers will only receive empty workloads.

    More generally, if the input buffer size is not equally distributable over the given number of workers, the last worker(s) might receive a larger, smaller or empty chunk.

    Also see forkJoin and joinBuffer.

    example
    forkJoin<number[], number[], number[], number[]>({
        src,
        // job definition / split buffer into chunks (min size 256 values)
        fork: forkBuffer(256),
        // re-join partial results
        join: joinBuffer(),
        worker: "./worker.js",
    })

    Parameters

    • Default value minChunkSize: number = 1

      -

    Returns (Anonymous function)

Const forkJoin

  • Returns a StreamSync instance which creates & attaches multiple subscriptions to given src input stream, processes each received value in parallel via web workers, then recombines partial results and passes the resulting transformed value downstream.

    remarks

    See ForkJoinOpts for further details & behavior options and the forkBuffer and joinBuffer helpers for array-based value processing (most likely use case).

    Type parameters

    • IN

    • MSG

    • RES

    • OUT

    Parameters

    Returns Subscription<any, OUT>

Const joinBuffer

  • joinBuffer<A, B>(fn?: Fn<A, ArrayLikeIterable<B>>): (Anonymous function)
  • Higher-order join function for scenarios involving the split-parallel processing of a large buffer.

    remarks

    The returned function is meant to be used as join function in a ForkJoinOpts config, receives the processed result chunks from all workers (ordered by worker ID) and concatenates them back into a single result array.

    The optional fn arg can be used to pick the actual result chunk from each worker result. This is useful if the worker result type is not an array and includes other data points (e.g. execution metrics etc.). If fn is not given, it defaults to the identity function (i.e. each worker's result is assumed to be an array).

    Also see forkJoin and forkBuffer.

    Type parameters

    • A

    • B

    Parameters

    • Optional fn: Fn<A, ArrayLikeIterable<B>>

      -

    Returns (Anonymous function)

Generated using TypeDoc