From 561c2689efd7996b46ac3e5fcff5a2176a81b746 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Thu, 20 Dec 2018 17:36:57 +0100 Subject: [PATCH] console: use spread notation instead of Object.assign PR-URL: https://github.com/nodejs/node/pull/25149 Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Denys Otrishko --- lib/internal/console/constructor.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/internal/console/constructor.js b/lib/internal/console/constructor.js index 1090f8fde68d1f..dcfb5f4a70a826 100644 --- a/lib/internal/console/constructor.js +++ b/lib/internal/console/constructor.js @@ -411,11 +411,15 @@ Console.prototype.table = function(tabularData, properties) { const final = (k, v) => this.log(cliTable(k, v)); const inspect = (v) => { - const opt = { depth: 0, maxArrayLength: 3 }; - if (v !== null && typeof v === 'object' && - !isArray(v) && ObjectKeys(v).length > 2) - opt.depth = -1; - Object.assign(opt, this[kGetInspectOptions](this._stdout)); + const depth = v !== null && + typeof v === 'object' && + !isArray(v) && + ObjectKeys(v).length > 2 ? -1 : 0; + const opt = { + depth, + maxArrayLength: 3, + ...this[kGetInspectOptions](this._stdout) + }; return util.inspect(v, opt); }; const getIndexArray = (length) => ArrayFrom({ length }, (_, i) => inspect(i));