From a4d2e4e515c671a1666ee19f57c2e06e4e62726c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 1 Nov 2025 22:56:35 +0100 Subject: [PATCH] chore: add opencode configuration MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .opencode/agent/review.md | 21 ++++ .opencode/command/format.md | 8 ++ .opencode/command/test.md | 8 ++ AGENTS.md | 29 ++++++ benchmarks/worker-selection/least.mjs | 98 +++++++++---------- benchmarks/worker-selection/round-robin.mjs | 18 ++-- eslint.config.js | 1 + examples/javascript/multiFunctionWorker.mjs | 12 +-- examples/javascript/yourWorker.mjs | 3 +- opencode.jsonc | 8 ++ src/circular-buffer.ts | 3 +- src/pools/abstract-pool.ts | 7 +- src/pools/pool.ts | 4 +- .../worker-choice-strategies-context.ts | 10 +- src/pools/worker.ts | 3 +- src/queues/abstract-fixed-queue.ts | 3 +- src/queues/fixed-priority-queue.ts | 3 +- src/queues/priority-queue.ts | 6 +- src/queues/queue-types.ts | 2 +- src/worker/abstract-worker.ts | 4 +- .../worker-files/cluster/asyncErrorWorker.cjs | 6 +- tests/worker-files/cluster/asyncWorker.cjs | 6 +- tests/worker-files/cluster/echoWorker.cjs | 6 +- .../cluster/longRunningWorkerHardBehavior.cjs | 6 +- .../cluster/longRunningWorkerSoftBehavior.cjs | 6 +- tests/worker-files/cluster/testWorker.cjs | 6 +- .../worker-files/thread/asyncErrorWorker.mjs | 6 +- tests/worker-files/thread/asyncWorker.mjs | 6 +- tests/worker-files/thread/echoWorker.mjs | 6 +- .../thread/longRunningWorkerHardBehavior.mjs | 6 +- .../thread/longRunningWorkerSoftBehavior.mjs | 6 +- tests/worker-files/thread/testWorker.mjs | 6 +- 32 files changed, 206 insertions(+), 117 deletions(-) create mode 100644 .opencode/agent/review.md create mode 100644 .opencode/command/format.md create mode 100644 .opencode/command/test.md create mode 100644 AGENTS.md create mode 100644 opencode.jsonc diff --git a/.opencode/agent/review.md b/.opencode/agent/review.md new file mode 100644 index 000000000..96f8b88a5 --- /dev/null +++ b/.opencode/agent/review.md @@ -0,0 +1,21 @@ +--- +description: Reviews code. +mode: subagent +temperature: 0.1 +tools: + write: false + edit: false + bash: false +--- + +You are in code review mode. Focus on: + +- Code quality +- Best practices +- Algorithmic +- Bugs +- Edge cases +- Performance +- Security + +Provide constructive and detailed feedbacks. diff --git a/.opencode/command/format.md b/.opencode/command/format.md new file mode 100644 index 000000000..b7d391528 --- /dev/null +++ b/.opencode/command/format.md @@ -0,0 +1,8 @@ +--- +description: Run code linter and formatter. +--- + +Run code linter and formatter with autofixes. +Raw output: +!`pnpm format` +Summarize code linter or formatter failures and propose targeted fixes. diff --git a/.opencode/command/test.md b/.opencode/command/test.md new file mode 100644 index 000000000..9d895fb02 --- /dev/null +++ b/.opencode/command/test.md @@ -0,0 +1,8 @@ +--- +description: Run test suite. +--- + +Run test suite. +Raw output: +!`pnpm test` +Summarize failing tests and propose targeted fixes. diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 000000000..b4d347796 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,29 @@ +# Agent Guidelines for Poolifier + +## Build/Test Commands + +- `pnpm build` - Build for development +- `pnpm test` - Run all tests +- `pnpm test -- --grep "pattern"` - Run tests matching pattern +- `pnpm lint` - Run ESLint +- `pnpm format` - Format with Biome + ESLint fix + +## Code Style + +- **Imports**: Use `.js` extensions for TypeScript imports (Node16 module resolution) +- **Naming**: camelCase for variables/functions, PascalCase for classes/types/interfaces +- **Types**: Explicit types over `any`, use type guards and discriminated unions +- **Async**: Prefer async/await over raw Promises, handle rejections with try/catch +- **Formatting**: 2-space indent, single quotes, no semicolons, trailing commas (ES5) +- **Error Handling**: Use typed errors with structured properties + +## Key Patterns + +- Export types with `export type {}` syntax +- Use `.js` file extensions in imports even for `.ts` files +- Follow established factory/strategy patterns for pool implementations +- Maintain single source of truth for configuration defaults + +## Repository Rules + +See `.github/copilot-instructions.md` for comprehensive coding standards including DRY principles, naming coherence, and TypeScript conventions. Follow quality gates: lint, format, and test passes required. diff --git a/benchmarks/worker-selection/least.mjs b/benchmarks/worker-selection/least.mjs index 3b954b7f2..e5ac16257 100644 --- a/benchmarks/worker-selection/least.mjs +++ b/benchmarks/worker-selection/least.mjs @@ -2,10 +2,10 @@ import { randomInt } from 'node:crypto' import { bench, group, run } from 'tatami-ng' /** - * - * @param numberOfWorkers - * @param maxNumberOfTasksPerWorker - * @returns + * Generates a random tasks map for benchmarking. + * @param numberOfWorkers - The number of workers. + * @param maxNumberOfTasksPerWorker - The maximum number of tasks per worker. + * @returns The generated tasks map. */ function generateRandomTasksMap ( numberOfWorkers, @@ -22,9 +22,9 @@ function generateRandomTasksMap ( const tasksMap = generateRandomTasksMap(60, 20) /** - * - * @param tasksMap - * @returns + * Selects the worker with least tasks using array sort. + * @param tasksMap - The tasks map. + * @returns The worker with least tasks. */ function arraySortSelect (tasksMap) { const tasksArray = Array.from(tasksMap) @@ -40,9 +40,9 @@ function arraySortSelect (tasksMap) { } /** - * - * @param tasksMap - * @returns + * Selects the worker with least tasks using loop iteration. + * @param tasksMap - The tasks map. + * @returns The worker with least tasks. */ function loopSelect (tasksMap) { let minKey @@ -72,13 +72,13 @@ const randomPivotIndexSelect = (leftIndex, rightIndex) => { } /** - * - * @param array - * @param leftIndex - * @param rightIndex - * @param pivotIndex - * @param compare - * @returns + * Partitions an array for quickselect algorithm. + * @param array - The array to partition. + * @param leftIndex - The left boundary index. + * @param rightIndex - The right boundary index. + * @param pivotIndex - The pivot element index. + * @param compare - The comparison function. + * @returns The new pivot index after partitioning. */ function partition ( array, @@ -101,9 +101,9 @@ function partition ( } /** - * - * @param tasksMap - * @returns + * Selects the worker with least tasks using quickselect loop algorithm. + * @param tasksMap - The tasks map. + * @returns The worker with least tasks. */ function quickSelectLoop (tasksMap) { const tasksArray = Array.from(tasksMap) @@ -114,9 +114,9 @@ function quickSelectLoop (tasksMap) { } /** - * - * @param tasksMap - * @returns + * Selects the worker with least tasks using quickselect loop with random pivot. + * @param tasksMap - The tasks map. + * @returns The worker with least tasks. */ function quickSelectLoopRandomPivot (tasksMap) { const tasksArray = Array.from(tasksMap) @@ -134,9 +134,9 @@ function quickSelectLoopRandomPivot (tasksMap) { } /** - * - * @param tasksMap - * @returns + * Selects the worker with least tasks using quickselect recursion algorithm. + * @param tasksMap - The tasks map. + * @returns The worker with least tasks. */ function quickSelectRecursion (tasksMap) { const tasksArray = Array.from(tasksMap) @@ -147,9 +147,9 @@ function quickSelectRecursion (tasksMap) { } /** - * - * @param tasksMap - * @returns + * Selects the worker with least tasks using quickselect recursion with random pivot. + * @param tasksMap - The tasks map. + * @returns The worker with least tasks. */ function quickSelectRecursionRandomPivot (tasksMap) { const tasksArray = Array.from(tasksMap) @@ -167,14 +167,14 @@ function quickSelectRecursionRandomPivot (tasksMap) { } /** - * - * @param array - * @param k - * @param leftIndex - * @param rightIndex - * @param compare - * @param pivotIndexSelect - * @returns + * Selects the k-th smallest element using quickselect loop algorithm. + * @param array - The array to select from. + * @param k - The index of the element to select. + * @param leftIndex - The left boundary index. + * @param rightIndex - The right boundary index. + * @param compare - The comparison function. + * @param pivotIndexSelect - The pivot selection function. + * @returns The k-th smallest element. */ function selectLoop ( array, @@ -200,14 +200,14 @@ function selectLoop ( } /** - * - * @param array - * @param k - * @param leftIndex - * @param rightIndex - * @param compare - * @param pivotIndexSelect - * @returns + * Selects the k-th smallest element using quickselect recursion algorithm. + * @param array - The array to select from. + * @param k - The index of the element to select. + * @param leftIndex - The left boundary index. + * @param rightIndex - The right boundary index. + * @param compare - The comparison function. + * @param pivotIndexSelect - The pivot selection function. + * @returns The k-th smallest element. */ function selectRecursion ( array, @@ -230,10 +230,10 @@ function selectRecursion ( } /** - * - * @param array - * @param index1 - * @param index2 + * Swaps two elements in an array. + * @param array - The array containing elements to swap. + * @param index1 - The index of the first element. + * @param index2 - The index of the second element. */ function swap (array, index1, index2) { const tmp = array[index1] diff --git a/benchmarks/worker-selection/round-robin.mjs b/benchmarks/worker-selection/round-robin.mjs index 4b3579319..675fc98f8 100644 --- a/benchmarks/worker-selection/round-robin.mjs +++ b/benchmarks/worker-selection/round-robin.mjs @@ -1,9 +1,9 @@ import { bench, group, run } from 'tatami-ng' /** - * - * @param numberOfWorkers - * @returns + * Generates an array of worker indices. + * @param numberOfWorkers - The number of workers. + * @returns The array of worker indices. */ function generateWorkersArray (numberOfWorkers) { return [...Array(numberOfWorkers).keys()] @@ -14,7 +14,8 @@ const workers = generateWorkersArray(60) let nextWorkerIndex /** - * @returns + * Round-robin worker selection using increment and modulo operation. + * @returns The selected worker. */ function roundRobinIncrementModulo () { const chosenWorker = workers[nextWorkerIndex] @@ -24,7 +25,8 @@ function roundRobinIncrementModulo () { } /** - * @returns + * Round-robin worker selection using ternary operator with off-by-one logic. + * @returns The selected worker. */ function roundRobinTernaryOffByOne () { nextWorkerIndex = @@ -33,7 +35,8 @@ function roundRobinTernaryOffByOne () { } /** - * @returns + * Round-robin worker selection using ternary operator with negation. + * @returns The selected worker. */ function roundRobinTernaryWithNegation () { nextWorkerIndex = @@ -44,7 +47,8 @@ function roundRobinTernaryWithNegation () { } /** - * @returns + * Round-robin worker selection using ternary operator with pre-choosing. + * @returns The selected worker. */ function roundRobinTernaryWithPreChoosing () { const chosenWorker = workers[nextWorkerIndex] diff --git a/eslint.config.js b/eslint.config.js index 0e36b4a33..9c358f519 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -26,6 +26,7 @@ export default defineConfig([ 'Quadflieg', 'neostandard', 'poolifier', + 'quickselect', ], }, }, diff --git a/examples/javascript/multiFunctionWorker.mjs b/examples/javascript/multiFunctionWorker.mjs index 47cc1a982..505ede198 100644 --- a/examples/javascript/multiFunctionWorker.mjs +++ b/examples/javascript/multiFunctionWorker.mjs @@ -1,9 +1,9 @@ import { ThreadWorker } from 'poolifier' /** - * - * @param data - * @returns + * First worker function example. + * @param data - The input data containing text. + * @returns The processed result with modified text. */ function fn0 (data) { console.info('Executing fn0') @@ -11,9 +11,9 @@ function fn0 (data) { } /** - * - * @param data - * @returns + * Second worker function example. + * @param data - The input data containing text. + * @returns The processed result with modified text. */ function fn1 (data) { console.info('Executing fn1') diff --git a/examples/javascript/yourWorker.mjs b/examples/javascript/yourWorker.mjs index f22fc4f34..dc79d2c46 100644 --- a/examples/javascript/yourWorker.mjs +++ b/examples/javascript/yourWorker.mjs @@ -1,7 +1,8 @@ import { ThreadWorker } from 'poolifier' /** - * @returns + * Example worker function that performs JSON serialization operations. + * @returns The result indicating successful completion. */ function yourFunction () { for (let i = 0; i <= 1000; i++) { diff --git a/opencode.jsonc b/opencode.jsonc new file mode 100644 index 000000000..8a9a6fc3b --- /dev/null +++ b/opencode.jsonc @@ -0,0 +1,8 @@ +{ + "$schema": "https://opencode.ai/config.json", + "formatter": { + "prettier": { + "disabled": true + } + } +} diff --git a/src/circular-buffer.ts b/src/circular-buffer.ts index 13df03c13..63fa44563 100644 --- a/src/circular-buffer.ts +++ b/src/circular-buffer.ts @@ -15,7 +15,8 @@ export class CircularBuffer { private writeIdx: number /** - * @param size - Buffer size. @defaultValue defaultBufferSize + * @param size - Buffer size. + * @defaultValue defaultBufferSize * @returns CircularBuffer. */ constructor (size: number = defaultBufferSize) { diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 6da9d1627..f96355b1e 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -1390,7 +1390,7 @@ export abstract class AbstractPool< * Adds the given worker node in the pool worker nodes. * @param workerNode - The worker node. * @returns The added worker node key. - * @throws {@link https://nodejs.org/api/errors.html#class-error} If the added worker node is not found. + * @throws {Error} If the added worker node is not found. */ private addWorkerNode (workerNode: IWorkerNode): number { this.workerNodes.push(workerNode) @@ -1473,7 +1473,7 @@ export abstract class AbstractPool< /** * Checks if the worker id sent in the received message from a worker is valid. * @param message - The received message. - * @throws {@link https://nodejs.org/api/errors.html#class-error} If the worker id is invalid. + * @throws {Error} If the worker id is invalid. */ private checkMessageWorkerId (message: MessageValue): void { if (message.workerId == null) { @@ -2432,7 +2432,8 @@ export abstract class AbstractPool< /** * Starts the minimum number of workers. - * @param initWorkerNodeUsage - Whether to initialize the worker node usage or not. @defaultValue false + * @param initWorkerNodeUsage - Whether to initialize the worker node usage or not. + * @defaultValue false */ private startMinimumNumberOfWorkers (initWorkerNodeUsage = false): void { if (this.minimumNumberOfWorkers === 0) { diff --git a/src/pools/pool.ts b/src/pools/pool.ts index ba9d3b479..7a03b7c68 100644 --- a/src/pools/pool.ts +++ b/src/pools/pool.ts @@ -89,8 +89,8 @@ export interface IPool< * @param name - The name of the task function. * @param fn - The task function. * @returns `true` if the task function was added, `false` otherwise. - * @throws {@link https://nodejs.org/api/errors.html#class-typeerror} If the `name` parameter is not a string or an empty string. - * @throws {@link https://nodejs.org/api/errors.html#class-typeerror} If the `fn` parameter is not a function or task function object. + * @throws {TypeError} If the `name` parameter is not a string or an empty string. + * @throws {TypeError} If the `fn` parameter is not a function or task function object. */ readonly addTaskFunction: ( name: string, diff --git a/src/pools/selection-strategies/worker-choice-strategies-context.ts b/src/pools/selection-strategies/worker-choice-strategies-context.ts index 3092b14ba..47107aee3 100644 --- a/src/pools/selection-strategies/worker-choice-strategies-context.ts +++ b/src/pools/selection-strategies/worker-choice-strategies-context.ts @@ -59,7 +59,8 @@ export class WorkerChoiceStrategiesContext< /** * Worker choice strategies context constructor. * @param pool - The pool instance. - * @param workerChoiceStrategies - The worker choice strategies. @defaultValue [WorkerChoiceStrategies.ROUND_ROBIN] + * @param workerChoiceStrategies - The worker choice strategies. + * @defaultValue [WorkerChoiceStrategies.ROUND_ROBIN] * @param opts - The worker choice strategy options. */ public constructor ( @@ -93,9 +94,10 @@ export class WorkerChoiceStrategiesContext< /** * Executes the given worker choice strategy in the context algorithm. - * @param workerChoiceStrategy - The worker choice strategy algorithm to execute. @defaultValue this.defaultWorkerChoiceStrategy + * @param workerChoiceStrategy - The worker choice strategy algorithm to execute. + * @defaultValue this.defaultWorkerChoiceStrategy * @returns The key of the worker node. - * @throws {@link https://nodejs.org/api/errors.html#class-error} If after computed retries the worker node key is null or undefined. + * @throws {Error} If after computed retries the worker node key is null or undefined. */ public execute ( workerChoiceStrategy: WorkerChoiceStrategy = this @@ -241,7 +243,7 @@ export class WorkerChoiceStrategiesContext< * Executes the given worker choice strategy. * @param workerChoiceStrategy - The worker choice strategy. * @returns The key of the worker node. - * @throws {@link https://nodejs.org/api/errors.html#class-error} If after computed retries the worker node key is null or undefined. + * @throws {Error} If after computed retries the worker node key is null or undefined. */ private executeStrategy (workerChoiceStrategy: IWorkerChoiceStrategy): number { let workerNodeKey: number | undefined = workerChoiceStrategy.choose() diff --git a/src/pools/worker.ts b/src/pools/worker.ts index 63c508d08..686389321 100644 --- a/src/pools/worker.ts +++ b/src/pools/worker.ts @@ -215,7 +215,8 @@ export interface IWorkerNode readonly dequeueLastPrioritizedTask: () => Task | undefined /** * Dequeue task. - * @param bucket - The prioritized bucket to dequeue from. @defaultValue 0 + * @param bucket - The prioritized bucket to dequeue from. + * @defaultValue 0 * @returns The dequeued task. */ readonly dequeueTask: (bucket?: number) => Task | undefined diff --git a/src/queues/abstract-fixed-queue.ts b/src/queues/abstract-fixed-queue.ts index 0c8677e09..a90849ba3 100644 --- a/src/queues/abstract-fixed-queue.ts +++ b/src/queues/abstract-fixed-queue.ts @@ -20,7 +20,8 @@ export abstract class AbstractFixedQueue implements IFixedQueue { /** * Constructs a fixed queue. - * @param size - Fixed queue size. @defaultValue defaultQueueSize + * @param size - Fixed queue size. + * @defaultValue defaultQueueSize * @returns IFixedQueue. */ constructor (size: number = defaultQueueSize) { diff --git a/src/queues/fixed-priority-queue.ts b/src/queues/fixed-priority-queue.ts index 83a44ae17..6940d8e73 100644 --- a/src/queues/fixed-priority-queue.ts +++ b/src/queues/fixed-priority-queue.ts @@ -15,7 +15,8 @@ export class FixedPriorityQueue /** * Constructs a FixedPriorityQueue. - * @param size - Fixed queue size. @defaultValue defaultQueueSize + * @param size - Fixed queue size. + * @defaultValue defaultQueueSize * @param agingFactor - Aging factor to apply to items (priority points per millisecond). * @param loadExponent - Load exponent applied to normalized load when computing effective aging. * @returns IFixedQueue. diff --git a/src/queues/priority-queue.ts b/src/queues/priority-queue.ts index bcd93cdab..2b3db24ea 100644 --- a/src/queues/priority-queue.ts +++ b/src/queues/priority-queue.ts @@ -57,8 +57,10 @@ export class PriorityQueue { /** * Constructs a priority queue. - * @param bucketSize - Prioritized bucket size. @defaultValue defaultBucketSize - * @param enablePriority - Whether to enable priority. @defaultValue false + * @param bucketSize - Prioritized bucket size. + * @defaultValue defaultBucketSize + * @param enablePriority - Whether to enable priority. + * @defaultValue false * @returns PriorityQueue. */ public constructor ( diff --git a/src/queues/queue-types.ts b/src/queues/queue-types.ts index 8ee433cdd..b4d226dfa 100644 --- a/src/queues/queue-types.ts +++ b/src/queues/queue-types.ts @@ -54,7 +54,7 @@ export interface IFixedQueue { * @param data - Data to enqueue. * @param priority - Priority of the data. Lower values have higher priority. * @returns The new size of the fixed queue. - * @throws If the fixed queue is full. + * @throws {Error} If the fixed queue is full. */ enqueue: (data: T, priority?: number) => number /** diff --git a/src/worker/abstract-worker.ts b/src/worker/abstract-worker.ts index ba8b00aa0..13372cf27 100644 --- a/src/worker/abstract-worker.ts +++ b/src/worker/abstract-worker.ts @@ -265,7 +265,7 @@ export abstract class AbstractWorker< /** * Returns the main worker. * @returns Reference to the main worker. - * @throws {@link https://nodejs.org/api/errors.html#class-error} If the main worker is not set. + * @throws {Error} If the main worker is not set. */ protected getMainWorker (): MainWorker { if (this.mainWorker == null) { @@ -575,7 +575,7 @@ export abstract class AbstractWorker< /** * Check if the message worker id is set and matches the worker id. * @param message - The message to check. - * @throws {@link https://nodejs.org/api/errors.html#class-error} If the message worker id is not set or does not match the worker id. + * @throws {Error} If the message worker id is not set or does not match the worker id. */ private checkMessageWorkerId (message: MessageValue): void { if (message.workerId == null) { diff --git a/tests/worker-files/cluster/asyncErrorWorker.cjs b/tests/worker-files/cluster/asyncErrorWorker.cjs index cc63d155a..ffab9c176 100644 --- a/tests/worker-files/cluster/asyncErrorWorker.cjs +++ b/tests/worker-files/cluster/asyncErrorWorker.cjs @@ -3,9 +3,9 @@ const { ClusterWorker, KillBehaviors } = require('../../../lib/index.cjs') const { sleepTaskFunction } = require('../../test-utils.cjs') /** - * - * @param data - * @returns + * Test worker function that throws an error after sleeping. + * @param data - The task data. + * @returns The result after sleeping and potentially throwing an error. */ async function error (data) { return sleepTaskFunction( diff --git a/tests/worker-files/cluster/asyncWorker.cjs b/tests/worker-files/cluster/asyncWorker.cjs index 7e864bd93..1ebe9a5e3 100644 --- a/tests/worker-files/cluster/asyncWorker.cjs +++ b/tests/worker-files/cluster/asyncWorker.cjs @@ -3,9 +3,9 @@ const { ClusterWorker, KillBehaviors } = require('../../../lib/index.cjs') const { sleepTaskFunction } = require('../../test-utils.cjs') /** - * - * @param data - * @returns + * Test worker function that sleeps for a specified duration. + * @param data - The task data. + * @returns The result after sleeping. */ async function sleep (data) { return sleepTaskFunction(data, 2000) diff --git a/tests/worker-files/cluster/echoWorker.cjs b/tests/worker-files/cluster/echoWorker.cjs index 5196b5db1..e9e816f6e 100644 --- a/tests/worker-files/cluster/echoWorker.cjs +++ b/tests/worker-files/cluster/echoWorker.cjs @@ -2,9 +2,9 @@ const { ClusterWorker, KillBehaviors } = require('../../../lib/index.cjs') /** - * - * @param data - * @returns + * Test worker function that echoes the input data. + * @param data - The task data to echo. + * @returns The same data that was passed in. */ function echo (data) { return data diff --git a/tests/worker-files/cluster/longRunningWorkerHardBehavior.cjs b/tests/worker-files/cluster/longRunningWorkerHardBehavior.cjs index b81619a30..eb31dfa3d 100644 --- a/tests/worker-files/cluster/longRunningWorkerHardBehavior.cjs +++ b/tests/worker-files/cluster/longRunningWorkerHardBehavior.cjs @@ -3,9 +3,9 @@ const { ClusterWorker, KillBehaviors } = require('../../../lib/index.cjs') const { sleepTaskFunction } = require('../../test-utils.cjs') /** - * - * @param data - * @returns + * Test worker function for long-running tasks with hard kill behavior. + * @param data - The task data. + * @returns The result after sleeping. */ async function sleep (data) { return sleepTaskFunction(data, 50000) diff --git a/tests/worker-files/cluster/longRunningWorkerSoftBehavior.cjs b/tests/worker-files/cluster/longRunningWorkerSoftBehavior.cjs index 408b938ff..94ad584f2 100644 --- a/tests/worker-files/cluster/longRunningWorkerSoftBehavior.cjs +++ b/tests/worker-files/cluster/longRunningWorkerSoftBehavior.cjs @@ -3,9 +3,9 @@ const { ClusterWorker } = require('../../../lib/index.cjs') const { sleepTaskFunction } = require('../../test-utils.cjs') /** - * - * @param data - * @returns + * Test worker function that performs a long-running sleep operation with soft behavior. + * @param data - The task data. + * @returns The result of the sleep operation. */ async function sleep (data) { return sleepTaskFunction(data, 50000) diff --git a/tests/worker-files/cluster/testWorker.cjs b/tests/worker-files/cluster/testWorker.cjs index 5af94942b..871f74d09 100644 --- a/tests/worker-files/cluster/testWorker.cjs +++ b/tests/worker-files/cluster/testWorker.cjs @@ -4,9 +4,9 @@ const { TaskFunctions } = require('../../test-types.cjs') const { executeTaskFunction } = require('../../test-utils.cjs') /** - * - * @param data - * @returns + * Test worker function that executes configurable task functions for testing. + * @param data - The task data containing function configuration. + * @returns The result of the executed task function. */ function test (data) { data = data || {} diff --git a/tests/worker-files/thread/asyncErrorWorker.mjs b/tests/worker-files/thread/asyncErrorWorker.mjs index c6fa8910f..917ded48f 100644 --- a/tests/worker-files/thread/asyncErrorWorker.mjs +++ b/tests/worker-files/thread/asyncErrorWorker.mjs @@ -2,9 +2,9 @@ import { KillBehaviors, ThreadWorker } from '../../../lib/index.cjs' import { sleepTaskFunction } from '../../test-utils.cjs' /** - * - * @param data - * @returns + * Test worker function that generates an asynchronous error for testing error handling. + * @param data - The task data. + * @returns Promise that rejects with an error message. */ async function error (data) { return sleepTaskFunction( diff --git a/tests/worker-files/thread/asyncWorker.mjs b/tests/worker-files/thread/asyncWorker.mjs index 63db364ad..e72e9798d 100644 --- a/tests/worker-files/thread/asyncWorker.mjs +++ b/tests/worker-files/thread/asyncWorker.mjs @@ -2,9 +2,9 @@ import { KillBehaviors, ThreadWorker } from '../../../lib/index.cjs' import { sleepTaskFunction } from '../../test-utils.cjs' /** - * - * @param data - * @returns + * Test worker function that sleeps for a specified duration. + * @param data - The task data + * @returns The result after sleeping */ async function sleep (data) { return sleepTaskFunction(data, 2000) diff --git a/tests/worker-files/thread/echoWorker.mjs b/tests/worker-files/thread/echoWorker.mjs index e1ac41eeb..4bee1c2dc 100644 --- a/tests/worker-files/thread/echoWorker.mjs +++ b/tests/worker-files/thread/echoWorker.mjs @@ -1,9 +1,9 @@ import { KillBehaviors, ThreadWorker } from '../../../lib/index.cjs' /** - * - * @param data - * @returns + * Test worker function that echoes the input data. + * @param data - The task data to echo + * @returns The same data that was passed in */ function echo (data) { return data diff --git a/tests/worker-files/thread/longRunningWorkerHardBehavior.mjs b/tests/worker-files/thread/longRunningWorkerHardBehavior.mjs index 1762947a8..05ffe47a4 100644 --- a/tests/worker-files/thread/longRunningWorkerHardBehavior.mjs +++ b/tests/worker-files/thread/longRunningWorkerHardBehavior.mjs @@ -2,9 +2,9 @@ import { KillBehaviors, ThreadWorker } from '../../../lib/index.cjs' import { sleepTaskFunction } from '../../test-utils.cjs' /** - * - * @param data - * @returns + * Test worker function for long-running tasks with hard kill behavior. + * @param data - The task data + * @returns The result after sleeping */ async function sleep (data) { return sleepTaskFunction(data, 50000) diff --git a/tests/worker-files/thread/longRunningWorkerSoftBehavior.mjs b/tests/worker-files/thread/longRunningWorkerSoftBehavior.mjs index ae98f767e..45dc3894b 100644 --- a/tests/worker-files/thread/longRunningWorkerSoftBehavior.mjs +++ b/tests/worker-files/thread/longRunningWorkerSoftBehavior.mjs @@ -2,9 +2,9 @@ import { ThreadWorker } from '../../../lib/index.cjs' import { sleepTaskFunction } from '../../test-utils.cjs' /** - * - * @param data - * @returns + * Test worker function that performs a long-running sleep operation with soft behavior. + * @param data - The task data + * @returns The result of the sleep operation */ async function sleep (data) { return sleepTaskFunction(data, 50000) diff --git a/tests/worker-files/thread/testWorker.mjs b/tests/worker-files/thread/testWorker.mjs index 679598378..9e32858af 100644 --- a/tests/worker-files/thread/testWorker.mjs +++ b/tests/worker-files/thread/testWorker.mjs @@ -3,9 +3,9 @@ import { TaskFunctions } from '../../test-types.cjs' import { executeTaskFunction } from '../../test-utils.cjs' /** - * - * @param data - * @returns + * Test worker function that executes configurable task functions for testing. + * @param data - The task data containing function configuration + * @returns The result of the executed task function */ function test (data) { data = data || {} -- 2.43.0