Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type compatibility with node 10+ #392

Merged
merged 1 commit into from
Aug 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/types/master.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ export type TransferList = Transferable[]
/** Worker instance. Either a web worker or a node.js Worker provided by `worker_threads` or `tiny-worker`. */
export interface Worker extends EventTarget {
postMessage(value: any, transferList?: TransferList): void
terminate(callback?: (error?: Error, exitCode?: number) => void): void
/** In nodejs 10+ return type is Promise while with tiny-worker and in browser return type is void */
terminate(callback?: (error?: Error, exitCode?: number) => void): void | Promise<number>
}

export interface ThreadsWorkerOptions extends WorkerOptions {
/** Prefix for the path passed to the Worker constructor. Web worker only. */
_baseURL?: string
Expand All @@ -102,7 +102,7 @@ export interface ThreadsWorkerOptions extends WorkerOptions {
export declare class WorkerImplementation extends EventTarget implements Worker {
constructor(path: string, options?: ThreadsWorkerOptions)
public postMessage(value: any, transferList?: TransferList): void
public terminate(): void
public terminate(): void | Promise<number>
}

/** Class to spawn workers from a blob or source string. */
Expand Down