]> Piment Noir Git Repositories - poolifier.git/commitdiff
chore: add opencode configuration
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 1 Nov 2025 21:56:35 +0000 (22:56 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 1 Nov 2025 21:56:35 +0000 (22:56 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
32 files changed:
.opencode/agent/review.md [new file with mode: 0644]
.opencode/command/format.md [new file with mode: 0644]
.opencode/command/test.md [new file with mode: 0644]
AGENTS.md [new file with mode: 0644]
benchmarks/worker-selection/least.mjs
benchmarks/worker-selection/round-robin.mjs
eslint.config.js
examples/javascript/multiFunctionWorker.mjs
examples/javascript/yourWorker.mjs
opencode.jsonc [new file with mode: 0644]
src/circular-buffer.ts
src/pools/abstract-pool.ts
src/pools/pool.ts
src/pools/selection-strategies/worker-choice-strategies-context.ts
src/pools/worker.ts
src/queues/abstract-fixed-queue.ts
src/queues/fixed-priority-queue.ts
src/queues/priority-queue.ts
src/queues/queue-types.ts
src/worker/abstract-worker.ts
tests/worker-files/cluster/asyncErrorWorker.cjs
tests/worker-files/cluster/asyncWorker.cjs
tests/worker-files/cluster/echoWorker.cjs
tests/worker-files/cluster/longRunningWorkerHardBehavior.cjs
tests/worker-files/cluster/longRunningWorkerSoftBehavior.cjs
tests/worker-files/cluster/testWorker.cjs
tests/worker-files/thread/asyncErrorWorker.mjs
tests/worker-files/thread/asyncWorker.mjs
tests/worker-files/thread/echoWorker.mjs
tests/worker-files/thread/longRunningWorkerHardBehavior.mjs
tests/worker-files/thread/longRunningWorkerSoftBehavior.mjs
tests/worker-files/thread/testWorker.mjs

diff --git a/.opencode/agent/review.md b/.opencode/agent/review.md
new file mode 100644 (file)
index 0000000..96f8b88
--- /dev/null
@@ -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 (file)
index 0000000..b7d3915
--- /dev/null
@@ -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 (file)
index 0000000..9d895fb
--- /dev/null
@@ -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 (file)
index 0000000..b4d3477
--- /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.
index 3b954b7f23bdf1355d3e80cfd785f586e5dcf95b..e5ac16257838ba2ee865d700ef934a1aa9593439 100644 (file)
@@ -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]
index 4b35793197ceba557d7180b04af18f51fb139b44..675fc98f80b295d2c1c9b916d9a4f54b59b959a1 100644 (file)
@@ -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]
index 0e36b4a33ff9b31789a9832bfa00e74ec7b41002..9c358f51949cc9e767581e4e5b15a79998806bb7 100644 (file)
@@ -26,6 +26,7 @@ export default defineConfig([
               'Quadflieg',
               'neostandard',
               'poolifier',
+              'quickselect',
             ],
           },
         },
index 47cc1a9826e7fe725225ad2cad8e9f9d8458dbf7..505ede1984a9340d978d97db669ebfd038b58b59 100644 (file)
@@ -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')
index f22fc4f34b660d108cc74acff626f65a3b3297c6..dc79d2c46704f8d0fa1be555add156536143d621 100644 (file)
@@ -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 (file)
index 0000000..8a9a6fc
--- /dev/null
@@ -0,0 +1,8 @@
+{
+  "$schema": "https://opencode.ai/config.json",
+  "formatter": {
+    "prettier": {
+      "disabled": true
+    }
+  }
+}
index 13df03c132350dff5fa6398d54cf880c7a56e061..63fa44563f728c8559ad1bbcaa7e19f0ae63040d 100644 (file)
@@ -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) {
index 6da9d16278dffb5b4c0aa888c526b6ebba45c140..f96355b1ea5f8044b91ee91a34e2c3b86d9b6820 100644 (file)
@@ -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<Worker, Data>): 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<Data | Response>): 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) {
index ba9d3b479fb88d8aaf52861e65063dce478672af..7a03b7c68124a1e42cb4264d525324b0f4870315 100644 (file)
@@ -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,
index 3092b14ba66dbdb7f261342c509e7d9d3f509f31..47107aee305818ea3f556697fe1ab933969ff6f3 100644 (file)
@@ -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()
index 63c508d08cfa5fa976ea2b75985a15b2d11a6170..686389321812b7907d906d7520079afb71712306 100644 (file)
@@ -215,7 +215,8 @@ export interface IWorkerNode<Worker extends IWorker, Data = unknown>
   readonly dequeueLastPrioritizedTask: () => Task<Data> | 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<Data> | undefined
index 0c8677e09f4d2ff6ab65024c3217f7ecb01b6598..a90849ba3934086edd5e1266e122d054a186010c 100644 (file)
@@ -20,7 +20,8 @@ export abstract class AbstractFixedQueue<T> implements IFixedQueue<T> {
 
   /**
    * Constructs a fixed queue.
-   * @param size - Fixed queue size. @defaultValue defaultQueueSize
+   * @param size - Fixed queue size.
+   * @defaultValue defaultQueueSize
    * @returns IFixedQueue.
    */
   constructor (size: number = defaultQueueSize) {
index 83a44ae17f5692a93df61e1fd31459f2a5628350..6940d8e73cc86b77c8a522616955ee7ae6e60828 100644 (file)
@@ -15,7 +15,8 @@ export class FixedPriorityQueue<T>
 
   /**
    * 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.
index bcd93cdabb40018a3a79ec00b8862a7dc5713a42..2b3db24ea3819a20bee3884cf7f7342822fb8742 100644 (file)
@@ -57,8 +57,10 @@ export class PriorityQueue<T> {
 
   /**
    * 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 (
index 8ee433cddf089271981b43d8fd667ba8c80ec8e8..b4d226dfae06d509f764b5c411bbe234aacde5c6 100644 (file)
@@ -54,7 +54,7 @@ export interface IFixedQueue<T> {
    * @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
   /**
index ba8b00aa01f3e8b1c8d50428ab5d3d2a2c02c505..13372cf27d5ca245b4c93443b7a1b4ca0e90631c 100644 (file)
@@ -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<Data>): void {
     if (message.workerId == null) {
index cc63d155a218c1acfbb550d01bab882ecc8455e3..ffab9c176c8e6f856043dbcde0271c502fb54884 100644 (file)
@@ -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(
index 7e864bd9370d1ead8ae44dc0a009058361f8cf18..1ebe9a5e3e74b72d18953f7aaae03be50eb470bc 100644 (file)
@@ -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)
index 5196b5db1522820aecd9de332f291319bca63a63..e9e816f6e819d15f9dac2fdac45a9c9d4cc71be7 100644 (file)
@@ -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
index b81619a30593b341c027dcdc3c56002dd94d6253..eb31dfa3d320ad3760523591e4a7a4153a7368a4 100644 (file)
@@ -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)
index 408b938ffbb72d2c4e94d6f6fe6d9a360090ae8d..94ad584f2bfa494e283a14e2dca46708614bb522 100644 (file)
@@ -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)
index 5af94942bbfadac50145c551dcaaa1b8cd9c2f62..871f74d090c71cb33b13506b81220083f131fbf0 100644 (file)
@@ -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 || {}
index c6fa8910f3b549d005d4356ae6b15d361d8ed094..917ded48fd49f77132317b8ba8d709b4e3fc5e63 100644 (file)
@@ -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(
index 63db364ad1e1cc8129a701f55a5389ae1aea2c2a..e72e9798d0d77a68d092ad6c824afbb4a919305b 100644 (file)
@@ -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)
index e1ac41eebc419140ea97f53cc8e5a191900b638e..4bee1c2dc7aaeb517f1a52a553424ab6e4045a9c 100644 (file)
@@ -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
index 1762947a8d4fa2cf61d6d89eb0afe5c40459b6c0..05ffe47a48a5ba53bff93b328d59bbb2d647bcf3 100644 (file)
@@ -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)
index ae98f767e74930f161ffedadffb99e2da8219930..45dc3894b4ae17674ee401f60a35f1ccaafef481 100644 (file)
@@ -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)
index 67959837807c1e89aa5f7ac27b112cdb9832b318..9e32858afda214132071034da7ace6602920bac4 100644 (file)
@@ -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 || {}