## [Unreleased]
+### Changed
+
+- Introduce ESM module support along with CommonJS one.
+
+### Fixed
+
+- Fix brown paper bag bug referencing the same object literal.
+
## [2.3.8] - 2023-03-18
### Changed
- Switch internal benchmarking code to benny.
- Switch to TypeScript 5.x.x.
- Switch rollup bundler plugins to core ones.
+- Switch to TSDoc syntax.
- Enforce conventional commits.
### Fixed
MessageValue,
PromiseWorkerResponseWrapper
} from '../utility-types'
-import { EMPTY_FUNCTION, EMPTY_OBJECT_LITERAL } from '../utils'
+import { EMPTY_FUNCTION } from '../utils'
import { KillBehaviors, isKillBehavior } from '../worker/worker-options'
import type { PoolOptions } from './pool'
import { PoolEmitter } from './pool'
const res = this.internalExecute(worker, this.nextMessageId)
this.checkAndEmitBusy()
this.sendToWorker(worker, {
- data: data ?? (EMPTY_OBJECT_LITERAL as Data),
+ data,
id: this.nextMessageId
})
++this.nextMessageId
-import { EMPTY_OBJECT_LITERAL } from '../../utils'
import { PoolType } from '../pool-internal'
import type { ClusterPoolOptions } from './fixed'
import { FixedClusterPool } from './fixed'
min: number,
protected readonly max: number,
filePath: string,
- opts: ClusterPoolOptions = EMPTY_OBJECT_LITERAL
+ opts: ClusterPoolOptions = {}
) {
super(min, filePath, opts)
}
import type { ClusterSettings, Worker } from 'cluster'
import cluster from 'cluster'
import type { MessageValue } from '../../utility-types'
-import { EMPTY_OBJECT_LITERAL } from '../../utils'
import { AbstractPool } from '../abstract-pool'
import type { PoolOptions } from '../pool'
import { PoolType } from '../pool-internal'
public constructor (
numberOfWorkers: number,
filePath: string,
- public readonly opts: ClusterPoolOptions = EMPTY_OBJECT_LITERAL
+ public readonly opts: ClusterPoolOptions = {}
) {
super(numberOfWorkers, filePath, opts)
}
export const EMPTY_FUNCTION: () => void = Object.freeze(() => {
/* Intentionally empty */
})
-
-/**
- * An intentional empty object literal.
- */
-export const EMPTY_OBJECT_LITERAL = {}
import type { Worker } from 'cluster'
import cluster from 'cluster'
import type { MessageValue } from '../utility-types'
-import { EMPTY_OBJECT_LITERAL } from '../utils'
import { AbstractWorker } from './abstract-worker'
import type { WorkerOptions } from './worker-options'
* @param fn - Function processed by the worker when the pool's `execution` function is invoked.
* @param opts - Options for the worker.
*/
- public constructor (
- fn: (data: Data) => Response,
- opts: WorkerOptions = EMPTY_OBJECT_LITERAL
- ) {
+ public constructor (fn: (data: Data) => Response, opts: WorkerOptions = {}) {
super(
'worker-cluster-pool:poolifier',
cluster.isPrimary,
import type { MessagePort } from 'worker_threads'
import { isMainThread, parentPort } from 'worker_threads'
import type { MessageValue } from '../utility-types'
-import { EMPTY_OBJECT_LITERAL } from '../utils'
import { AbstractWorker } from './abstract-worker'
import type { WorkerOptions } from './worker-options'
* @param fn - Function processed by the worker when the pool's `execution` function is invoked.
* @param opts - Options for the worker.
*/
- public constructor (
- fn: (data: Data) => Response,
- opts: WorkerOptions = EMPTY_OBJECT_LITERAL
- ) {
+ public constructor (fn: (data: Data) => Response, opts: WorkerOptions = {}) {
super('worker-thread-pool:poolifier', isMainThread, fn, parentPort, opts)
}