Skip to content

Commit 4ea2c1c

Browse files
committed
console: use spread notation instead of Object.assign
PR-URL: #25149 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Denys Otrishko <[email protected]>
1 parent 5ac30c9 commit 4ea2c1c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/internal/console/constructor.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,15 @@ Console.prototype.table = function(tabularData, properties) {
434434
const final = (k, v) => this.log(cliTable(k, v));
435435

436436
const inspect = (v) => {
437-
const opt = { depth: 0, maxArrayLength: 3 };
438-
if (v !== null && typeof v === 'object' &&
439-
!isArray(v) && ObjectKeys(v).length > 2)
440-
opt.depth = -1;
441-
Object.assign(opt, this[kGetInspectOptions](this._stdout));
437+
const depth = v !== null &&
438+
typeof v === 'object' &&
439+
!isArray(v) &&
440+
ObjectKeys(v).length > 2 ? -1 : 0;
441+
const opt = {
442+
depth,
443+
maxArrayLength: 3,
444+
...this[kGetInspectOptions](this._stdout)
445+
};
442446
return util.inspect(v, opt);
443447
};
444448
const getIndexArray = (length) => ArrayFrom({ length }, (_, i) => inspect(i));

0 commit comments

Comments
 (0)