GeezerVison is showing github.com — tty: refactor to avoid unsafe array iteration · nodejs/node@258aa50
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/tty.js +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
23 | 23 | 'use strict'; |
24 | 24 |
|
25 | 25 | const { |
| 26 | + ArrayPrototypeSome, |
26 | 27 | RegExpPrototypeTest, |
27 | 28 | StringPrototypeSplit, |
28 | 29 | StringPrototypeToLowerCase, |
@@ -202,10 +203,9 @@ function getColorDepth(env = process.env) { |
202 | 203 | if (TERM_ENVS[termEnv]) { |
203 | 204 | return TERM_ENVS[termEnv]; |
204 | 205 | } |
205 | | - for (const term of TERM_ENVS_REG_EXP) { |
206 | | - if (RegExpPrototypeTest(term, termEnv)) { |
207 | | - return COLORS_16; |
208 | | - } |
| 206 | + if (ArrayPrototypeSome(TERM_ENVS_REG_EXP, |
| 207 | + (term) => RegExpPrototypeTest(term, termEnv))) { |
| 208 | + return COLORS_16; |
209 | 209 | } |
210 | 210 | } |
211 | 211 | // Move 16 color COLORTERM below 16m and 256 |
|
Collapse file
Copy file name to clipboardExpand all lines: lib/tty.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -132,7 +132,7 @@ WriteStream.prototype._refreshSize = function() { |
132 | 132 | this.emit('error', errors.errnoException(err, 'getWindowSize')); |
133 | 133 | return; |
134 | 134 | } |
135 | | - const [newCols, newRows] = winSize; |
| 135 | + const { 0: newCols, 1: newRows } = winSize; |
136 | 136 | if (oldCols !== newCols || oldRows !== newRows) { |
137 | 137 | this.columns = newCols; |
138 | 138 | this.rows = newRows; |
|