1 import type { WorkerChoiceStrategyOptions
} from
'./pools/selection-strategies/selection-strategies-types'
4 * An intentional empty function.
6 export const EMPTY_FUNCTION
: () => void = Object.freeze(() => {
7 /* Intentionally empty */
11 * Default worker choice strategy options.
13 export const DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
: WorkerChoiceStrategyOptions
=
19 * Compute the median of the given data set.
21 * @param dataSet - Data set.
22 * @returns The median of the given data set.
24 export const median
= (dataSet
: number[]): number => {
25 if (Array.isArray(dataSet
) && dataSet
.length
=== 1) {
28 const sortedDataSet
= dataSet
.slice().sort((a
, b
) => a
- b
)
29 const middleIndex
= Math.floor(sortedDataSet
.length
/ 2)
30 if (sortedDataSet
.length
% 2 === 0) {
31 return sortedDataSet
[middleIndex
/ 2]
33 return (sortedDataSet
[middleIndex
- 1] + sortedDataSet
[middleIndex
]) / 2