From 4e38fd2175c62f93f766733a1feff14a4a9e9958 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 19 Sep 2023 14:15:23 +0200 Subject: [PATCH] refactor: type namespace cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/index.ts | 2 +- src/worker/abstract-worker.ts | 12 ++++++------ src/worker/task-functions.ts | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/index.ts b/src/index.ts index 8faba255..fab0d8ed 100644 --- a/src/index.ts +++ b/src/index.ts @@ -60,7 +60,7 @@ export type { export type { TaskAsyncFunction, TaskFunction, - TaskFunctionOperationReturnType, + TaskFunctionOperationResult, TaskFunctions, TaskSyncFunction } from './worker/task-functions' diff --git a/src/worker/abstract-worker.ts b/src/worker/abstract-worker.ts index 6c6de861..dc1f6adc 100644 --- a/src/worker/abstract-worker.ts +++ b/src/worker/abstract-worker.ts @@ -18,7 +18,7 @@ import { KillBehaviors, type WorkerOptions } from './worker-options' import type { TaskAsyncFunction, TaskFunction, - TaskFunctionOperationReturnType, + TaskFunctionOperationResult, TaskFunctions, TaskSyncFunction } from './task-functions' @@ -201,7 +201,7 @@ export abstract class AbstractWorker< * @param name - The name of the task function to check. * @returns Whether the worker has a task function with the given name or not. */ - public hasTaskFunction (name: string): TaskFunctionOperationReturnType { + public hasTaskFunction (name: string): TaskFunctionOperationResult { try { this.checkTaskFunctionName(name) } catch (error) { @@ -221,7 +221,7 @@ export abstract class AbstractWorker< public addTaskFunction ( name: string, fn: TaskFunction - ): TaskFunctionOperationReturnType { + ): TaskFunctionOperationResult { try { this.checkTaskFunctionName(name) if (name === DEFAULT_TASK_NAME) { @@ -253,7 +253,7 @@ export abstract class AbstractWorker< * @param name - The name of the task function to remove. * @returns Whether the task function existed and was removed or not. */ - public removeTaskFunction (name: string): TaskFunctionOperationReturnType { + public removeTaskFunction (name: string): TaskFunctionOperationResult { try { this.checkTaskFunctionName(name) if (name === DEFAULT_TASK_NAME) { @@ -309,7 +309,7 @@ export abstract class AbstractWorker< * @param name - The name of the task function to use as default task function. * @returns Whether the default task function was set or not. */ - public setDefaultTaskFunction (name: string): TaskFunctionOperationReturnType { + public setDefaultTaskFunction (name: string): TaskFunctionOperationResult { try { this.checkTaskFunctionName(name) if (name === DEFAULT_TASK_NAME) { @@ -378,7 +378,7 @@ export abstract class AbstractWorker< message: MessageValue ): void { const { taskFunctionOperation, taskFunctionName, taskFunction } = message - let response!: TaskFunctionOperationReturnType + let response!: TaskFunctionOperationResult if (taskFunctionOperation === 'add') { response = this.addTaskFunction( taskFunctionName as string, diff --git a/src/worker/task-functions.ts b/src/worker/task-functions.ts index 353b8b0c..ef9e1f0a 100644 --- a/src/worker/task-functions.ts +++ b/src/worker/task-functions.ts @@ -45,9 +45,9 @@ TaskFunction > /** - * Task function operation return type. + * Task function operation result. */ -export interface TaskFunctionOperationReturnType { +export interface TaskFunctionOperationResult { status: boolean error?: Error } -- 2.34.1