diff --git a/lib/util.js b/lib/util.js index f0b7285fe010..4b539088c97e 100644 --- a/lib/util.js +++ b/lib/util.js @@ -378,10 +378,9 @@ function debuglog(set) { * in the best way possible given the different types. * * @param {any} value The value to print out. - * @param {Object} opts Optional options object that alters the output. + * @param {Object} options Optional options object that alters the output. */ -/* Legacy: value, showHidden, depth, colors */ -function inspect(value, opts) { +function inspect(value, options) { // Default options const ctx = { seen: [], @@ -398,22 +397,15 @@ function inspect(value, opts) { indentationLvl: 0, compact: inspectDefaultOptions.compact }; - // Legacy... - if (arguments.length > 2) { - if (arguments[2] !== undefined) { - ctx.depth = arguments[2]; - } - if (arguments.length > 3 && arguments[3] !== undefined) { - ctx.colors = arguments[3]; - } - } // Set user-specified options - if (typeof opts === 'boolean') { - ctx.showHidden = opts; - } else if (opts) { - const optKeys = Object.keys(opts); - for (var i = 0; i < optKeys.length; i++) { - ctx[optKeys[i]] = opts[optKeys[i]]; + if (options !== undefined) { + if (typeof options !== 'object') { + throw new ERR_INVALID_ARG_TYPE('options', 'Object', options); + } else { + const optKeys = Object.keys(options); + for (var i = 0; i < optKeys.length; i++) { + ctx[optKeys[i]] = options[optKeys[i]]; + } } } if (ctx.colors) ctx.stylize = stylizeWithColor;