Skip to content

Commit

Permalink
Avoid using Array#reduce (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante authored Sep 24, 2020
1 parent 5be19fc commit 8ac502b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,10 @@ class Ora {
updateLineCount() {
const columns = this.stream.columns || 80;
const fullPrefixText = this.getFullPrefixText(this.prefixText, '-');
this.lineCount = stripAnsi(fullPrefixText + '--' + this[TEXT]).split('\n').reduce((count, line) => {
return count + Math.max(1, Math.ceil(wcwidth(line) / columns));
}, 0);
this.lineCount = 0;
for (const line of stripAnsi(fullPrefixText + '--' + this[TEXT]).split('\n')) {
this.lineCount += Math.max(1, Math.ceil(wcwidth(line) / columns));
}
}

set text(value) {
Expand Down

0 comments on commit 8ac502b

Please sign in to comment.