Class InlineThread<Args, Output>

Creates a new thread using an inline function.

Example

import { InlineThread } from 'nanothreads';

const handle = new InlineThread<[number, number], number>((a, b) => a + b);
await handle.send(4, 1); // output: 5

Type Parameters

  • Args

  • Output

Hierarchy

Constructors

Properties

channel: MessagePort
config?: {
    id?: number;
    once?: boolean;
}

Type declaration

  • Optional id?: number
  • Optional once?: boolean
handle: BrowserImpl<unknown>
options: IWorkerOptions & {
    eval?: boolean;
} = {}
src: string | WorkerThreadFn<Args, Output>
type: "inline" | "inline-blob" | "file"

Methods

  • Parameters

    • Rest ...data: Args extends any[] ? Args : [Args]

    Returns Promise<Output>

Generated using TypeDoc