From 09564a833b20cff37a199cabe15ee5470b63e071 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 15 Apr 2023 19:09:38 +0200 Subject: [PATCH] docs: add documentation to worker function type aliases MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/utility-types.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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 -- 2.34.1