Skip to content

Commit

Permalink
tty: refactor to avoid unsafe array iteration
Browse files Browse the repository at this point in the history
PR-URL: #36771
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Pooja D P <[email protected]>
  • Loading branch information
aduh95 authored and targos committed Jun 11, 2021
1 parent 0dea866 commit 716076e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/internal/tty.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
'use strict';

const {
ArrayPrototypeSome,
RegExpPrototypeTest,
StringPrototypeSplit,
StringPrototypeToLowerCase,
Expand Down Expand Up @@ -202,10 +203,9 @@ function getColorDepth(env = process.env) {
if (TERM_ENVS[termEnv]) {
return TERM_ENVS[termEnv];
}
for (const term of TERM_ENVS_REG_EXP) {
if (RegExpPrototypeTest(term, termEnv)) {
return COLORS_16;
}
if (ArrayPrototypeSome(TERM_ENVS_REG_EXP,
(term) => RegExpPrototypeTest(term, termEnv))) {
return COLORS_16;
}
}
// Move 16 color COLORTERM below 16m and 256
Expand Down
2 changes: 1 addition & 1 deletion lib/tty.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ WriteStream.prototype._refreshSize = function() {
this.emit('error', errors.errnoException(err, 'getWindowSize'));
return;
}
const [newCols, newRows] = winSize;
const { 0: newCols, 1: newRows } = winSize;
if (oldCols !== newCols || oldRows !== newRows) {
this.columns = newCols;
this.rows = newRows;
Expand Down

0 comments on commit 716076e

Please sign in to comment.