Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Dec 12, 2021
1 parent c8a1218 commit e269a54
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/stats/cold.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ const getColdLoopsTarget = function (
const incrementalMeanMax = mean * (1 + precisionTarget)
const minIndex = getIndexFromLength(COLD_MIN_PERCENTAGE, length)
const maxIndex = length - 1
const { filteredIndex } = findHotIndex(array, {
const hotIndex = findHotIndex(array, {
minIndex,
maxIndex,
filter,
incrementalMeanMin,
incrementalMeanMax,
})
const coldLengthTarget = Math.max(
getLengthFromIndex(COLD_MAX_PERCENTAGE, filteredIndex - 1) - length,
getLengthFromIndex(COLD_MAX_PERCENTAGE, hotIndex - 1) - length,
0,
)
const filterRatio = array.length / length
Expand Down Expand Up @@ -178,7 +178,6 @@ const findHotIndex = function (
array,
{ mean, minIndex, maxIndex, filter, incrementalMeanMin, incrementalMeanMax },
) {
let closestMean = 0
let closestMeanDiff = Number.POSITIVE_INFINITY
let sum = 0
let index = -1
Expand Down Expand Up @@ -206,17 +205,16 @@ const findHotIndex = function (

if (closestMeanDiff > meanDiff) {
closestMeanDiff = meanDiff
closestMean = incrementalMean
}
} else if (
incrementalMean >= incrementalMeanMin &&
incrementalMean <= incrementalMeanMax
) {
return { filteredIndex }
return filteredIndex
}
}

return { closestMean, filteredIndex }
return filteredIndex
}
/* eslint-enable max-statements, complexity, fp/no-let, fp/no-loops,
fp/no-mutation, max-depth, no-continue */

0 comments on commit e269a54

Please sign in to comment.