Skip to content

Commit

Permalink
console: use spread notation instead of Object.assign
Browse files Browse the repository at this point in the history
PR-URL: #25149
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
  • Loading branch information
BridgeAR authored and targos committed Jan 1, 2019
1 parent e182ca9 commit 561c268
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/internal/console/constructor.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -411,11 +411,15 @@ Console.prototype.table = function(tabularData, properties) {
const final = (k, v) => this.log(cliTable(k, v)); const final = (k, v) => this.log(cliTable(k, v));


const inspect = (v) => { const inspect = (v) => {
const opt = { depth: 0, maxArrayLength: 3 }; const depth = v !== null &&
if (v !== null && typeof v === 'object' && typeof v === 'object' &&
!isArray(v) && ObjectKeys(v).length > 2) !isArray(v) &&
opt.depth = -1; ObjectKeys(v).length > 2 ? -1 : 0;
Object.assign(opt, this[kGetInspectOptions](this._stdout)); const opt = {
depth,
maxArrayLength: 3,
...this[kGetInspectOptions](this._stdout)
};
return util.inspect(v, opt); return util.inspect(v, opt);
}; };
const getIndexArray = (length) => ArrayFrom({ length }, (_, i) => inspect(i)); const getIndexArray = (length) => ArrayFrom({ length }, (_, i) => inspect(i));
Expand Down

0 comments on commit 561c268

Please sign in to comment.