Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace worker

A namespace that represents the exports from the worker sub-package.

remarks

You can import this namespace via import {worker} from "@convergejs/converge", or import its exports directly via import {...} from "@convergejs/converge/worker".

Index

Type Aliases

AbstractWorkerConstructor: Constructor<typeof AbstractWorker, [...unknown[]]>

A constructable AbstractWorker.

ExitMessage: { exitCode?: number; type: "exit" }

An exit message.

Type declaration

  • Optional exitCode?: number
  • type: "exit"
PlatformWorkerMessageEvent<T>: { data: T }

A general message with data.

Type Parameters

  • T = unknown

    The type of the data expected in the data property.

Type declaration

  • Readonly data: T
StartMessage: { args: unknown[]; type: "start" }

A start message.

Type declaration

  • args: unknown[]
  • type: "start"
WorkerFeatureConstructor: Constructor<typeof WorkerFeature, [worker: WorkerLike, messagePort?: MessagePort]>

A paramaterized constructable WorkerFeature.

WorkerMessage<T>: { data: T }

Type Parameters

  • T = unknown

Type declaration

  • Readonly data: T
WorkerOptions: { node?: { filename: string | URL }; web?: { filename: string | URL } }

Options for the worker decorator.

Type declaration

  • Optional node?: { filename: string | URL }

    Options that will be applied when executing on the Node.js platform.

    • filename: string | URL
  • Optional web?: { filename: string | URL }

    Options that will be applied when executing within a web browser.

    • filename: string | URL

Variables

WorkerFeatureSymbol: { workerFeatureInstances: typeof WorkerFeatureInstancesSymbol; workerFeatures: typeof WorkerFeaturesSymbol }

Provides symbols for properties and methods related to worker features.

Type declaration

  • workerFeatureInstances: typeof WorkerFeatureInstancesSymbol

    A property that returns a map of WorkerFeatureConstructor and their initialized instances.

  • workerFeatures: typeof WorkerFeaturesSymbol

    A property that returns an array of types described by WorkerFeatureConstructor that represents the required features of a Worker.

Functions

  • A type guard that determines if an event is an ExitMessage.

    Parameters

    • obj: unknown

      The event to test.

    Returns obj is ExitMessage

    true if obj represents an ExitMessage; otherwise false.

  • A type guard that determines if an event is a message event.

    Parameters

    • obj: unknown

      The event to test.

    Returns obj is PlatformWorkerMessageEvent<unknown>

    true if obj represents a PlatformWorkerMessageEvent; otherwise false.

  • A type guard that determines if an event is a StartMessage.

    Parameters

    • obj: unknown

      The event to test.

    Returns obj is StartMessage

    true if obj represents a StartMessage; otherwise false.

  • useSharedMemory(): (<T>(target: T) => T)
  • Returns a class decorator that attached the shared memory feature to a worker.

    Returns (<T>(target: T) => T)

    A class decorator that attaches the SharedMemoryFeature to a given target AbstractWorker.

  • Returns a class decorator that attaches a worker feature to a worker.

    Parameters

    Returns (<T>(target: T) => T)

    A class decorator that attaches feature to a given target AbstractWorker

      • <T>(target: T): T
      • Returns a class decorator that attaches a worker feature to a worker.

        Type Parameters

        Parameters

        • target: T

        Returns T

        A class decorator that attaches feature to a given target AbstractWorker

  • Returns a class decorator that ensures that an AbstractWorker implementation executes in its own dedicated worker thread.

    Parameters

    • Optional options: WorkerOptions

      The options to apply when configuring the underlying worker.

    Returns (<T>(target: T) => T)

    A class decorator that decorates a given AbstractWorker target so that it is executed in its own worker thread.

      • <T>(target: T): T
      • Returns a class decorator that ensures that an AbstractWorker implementation executes in its own dedicated worker thread.

        Type Parameters

        Parameters

        • target: T

        Returns T

        A class decorator that decorates a given AbstractWorker target so that it is executed in its own worker thread.

Generated using TypeDoc