Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Sep 5, 2021
1 parent 8da9512 commit 4461976
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/report/reporters/boxplot/box.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ const getLeftSpace = function (min, minBlockWidth, mini) {
}

const getMinLine = function (min, q1) {
const leftLineWidth = Math.max(q1.index - min.index, 0)
const leftLine = LINE_CHARACTER.repeat(leftLineWidth)
const leftLine = fillCharacter(LINE_CHARACTER, min, q1)
const leftLineA =
leftLine === '' ? leftLine : MIN_CHARACTER + leftLine.slice(1)
return separatorColor(leftLineA)
Expand All @@ -42,19 +41,18 @@ const getQ3Box = function (median, q3) {
return fillCharacter(BOX_CHARACTER, median, q3)
}

const fillCharacter = function (character, start, end) {
const width = Math.max(end.index - start.index, 0)
return character.repeat(width)
}

const getMaxLine = function (q3, max) {
const rightLineWidth = Math.max(max.index - q3.index, 0)
const rightLine = LINE_CHARACTER.repeat(rightLineWidth)
const rightLine = fillCharacter(LINE_CHARACTER, q3, max)
const rightLineA =
rightLine === '' ? rightLine : rightLine.slice(0, -1) + MAX_CHARACTER
return separatorColor(rightLineA)
}

const fillCharacter = function (character, start, end) {
const width = Math.max(end.index - start.index, 0)
return character.repeat(width)
}

// Works on most terminals
const MIN_CHARACTER = '\u251C'
const LINE_CHARACTER = '\u2500'
Expand Down

0 comments on commit 4461976

Please sign in to comment.