From: Jérôme Benoit Date: Sat, 15 Apr 2023 17:09:38 +0000 (+0200) Subject: docs: add documentation to worker function type aliases X-Git-Tag: v2.4.10~12 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=09564a833b20cff37a199cabe15ee5470b63e071;p=poolifier.git docs: add documentation to worker function type aliases Signed-off-by: Jérôme Benoit --- diff --git a/src/utility-types.ts b/src/utility-types.ts index 81a57698..ea90afd6 100644 --- a/src/utility-types.ts +++ b/src/utility-types.ts @@ -40,14 +40,31 @@ export interface MessageValue< } /** - * Worker function that can be executed types. + * Worker synchronous function that can be executed. + * + * @typeParam Data - Type of data sent to the worker. This can only be serializable data. + * @typeParam Response - Type of execution response. This can only be serializable data. */ export type WorkerSyncFunction = ( data?: Data ) => Response +/** + * Worker asynchronous function that can be executed. + * This function must return a promise. + * + * @typeParam Data - Type of data sent to the worker. This can only be serializable data. + * @typeParam Response - Type of execution response. This can only be serializable data. + */ export type WorkerAsyncFunction = ( data?: Data ) => Promise +/** + * Worker function that can be executed. + * This function can be synchronous or asynchronous. + * + * @typeParam Data - Type of data sent to the worker. This can only be serializable data. + * @typeParam Response - Type of execution response. This can only be serializable data. + */ export type WorkerFunction = | WorkerSyncFunction | WorkerAsyncFunction