diff --git a/lib/console.js b/lib/console.js index 07f177d595deb2..46b7f7627eddae 100644 --- a/lib/console.js +++ b/lib/console.js @@ -319,15 +319,6 @@ const iterKey = '(iteration index)'; const isArray = (v) => ArrayIsArray(v) || isTypedArray(v) || isBuffer(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; - return util.inspect(v, opt); -}; - -const getIndexArray = (length) => ArrayFrom({ length }, (_, i) => inspect(i)); // https://console.spec.whatwg.org/#table Console.prototype.table = function(tabularData, properties) { @@ -340,6 +331,16 @@ 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)); + return util.inspect(v, opt); + }; + const getIndexArray = (length) => ArrayFrom({ length }, (_, i) => inspect(i)); + const mapIter = isMapIterator(tabularData); if (mapIter) tabularData = previewMapIterator(tabularData);