X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Futility-types.ts;h=7ea86042ff796660b57410561bd1b57a2b9c8025;hb=90bd5e4759bd31cc25b6f42e88d07ed05b969cec;hp=aa4d058cce142ffa5214c8d2ce2965e428309d14;hpb=729c563db85562dd7d0f7733b1a3e2d98467134b;p=poolifier.git diff --git a/src/utility-types.ts b/src/utility-types.ts index aa4d058c..7ea86042 100644 --- a/src/utility-types.ts +++ b/src/utility-types.ts @@ -1,5 +1,9 @@ +import type { Worker } from 'cluster' +import type { MessagePort } from 'worker_threads' +import type { KillBehavior } from './worker/worker-options' + /** - * Make all properties in T non-readonly + * Make all properties in T non-readonly. */ export type Draft = { -readonly [P in keyof T]?: T[P] } @@ -24,7 +28,10 @@ export type JSONArray = Array /** * Message object that is passed between worker and main worker. */ -export interface MessageValue { +export interface MessageValue< + Data = unknown, + MainWorker extends Worker | MessagePort | unknown = unknown +> { /** * Input data that will be passed to the worker. */ @@ -36,7 +43,7 @@ export interface MessageValue { /** * Kill code. */ - readonly kill?: number + readonly kill?: KillBehavior | 1 /** * Error. */ @@ -46,5 +53,5 @@ export interface MessageValue { * * _Only for internal use_ */ - readonly parent?: MessagePort + readonly parent?: MainWorker }