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
=
20 * Compute the median of the given data set.
22 * @param dataSet - Data set.
23 * @returns The median of the given data set.
25 export const median
= (dataSet
: number[]): number => {
26 if (Array.isArray(dataSet
) && dataSet
.length
=== 0) {
29 if (Array.isArray(dataSet
) && dataSet
.length
=== 1) {
32 const sortedDataSet
= dataSet
.slice().sort((a
, b
) => a
- b
)
34 (sortedDataSet
[(sortedDataSet
.length
- 1) >> 1] +
35 sortedDataSet
[sortedDataSet
.length
>> 1]) /
41 * Is the given object a plain object?
43 * @param obj - The object to check.
44 * @returns `true` if the given object is a plain object, `false` otherwise.
46 export const isPlainObject
= (obj
: unknown
): boolean =>
47 typeof obj
=== 'object' &&
49 obj
?.constructor
=== Object &&
50 Object.prototype
.toString
.call(obj
) === '[object Object]'