build: build fix package publishing on JSR
[poolifier.git] / src / pools / pool.ts
index 73ca3aa105e477add5fd11d3d5cd19911c41f115..d7b6eeabeb074c31103854ec2f9789d137ff8409 100644 (file)
@@ -1,7 +1,12 @@
-import type { TransferListItem, WorkerOptions } from 'node:worker_threads'
-import type { EventEmitterAsyncResource } from 'node:events'
 import type { ClusterSettings } from 'node:cluster'
+import type { EventEmitterAsyncResource } from 'node:events'
+import type { TransferListItem, WorkerOptions } from 'node:worker_threads'
+
 import type { TaskFunction } from '../worker/task-functions.js'
+import type {
+  WorkerChoiceStrategy,
+  WorkerChoiceStrategyOptions
+} from './selection-strategies/selection-strategies-types.js'
 import type {
   ErrorHandler,
   ExitHandler,
@@ -11,15 +16,14 @@ import type {
   OnlineHandler,
   WorkerType
 } from './worker.js'
-import type {
-  WorkerChoiceStrategy,
-  WorkerChoiceStrategyOptions
-} from './selection-strategies/selection-strategies-types.js'
 
 /**
  * Enumeration of pool types.
  */
-export const PoolTypes = Object.freeze({
+export const PoolTypes: Readonly<{
+  fixed: 'fixed'
+  dynamic: 'dynamic'
+}> = Object.freeze({
   /**
    * Fixed pool type.
    */
@@ -38,7 +42,16 @@ export type PoolType = keyof typeof PoolTypes
 /**
  * Enumeration of pool events.
  */
-export const PoolEvents = Object.freeze({
+export const PoolEvents: Readonly<{
+  ready: 'ready'
+  busy: 'busy'
+  full: 'full'
+  empty: 'empty'
+  destroy: 'destroy'
+  error: 'error'
+  taskError: 'taskError'
+  backPressure: 'backPressure'
+}> = Object.freeze({
   ready: 'ready',
   busy: 'busy',
   full: 'full',
@@ -243,7 +256,7 @@ export interface IPool<
    */
   readonly workerNodes: Array<IWorkerNode<Worker, Data>>
   /**
-   * Event emitter integrated with async resource on which events can be listened to.
+   * Pool event emitter integrated with async resource.
    * The async tracking tooling identifier is `poolifier:<PoolType>-<WorkerType>-pool`.
    *
    * Events that can currently be listened to: