(value, opts)
| 352 | */ |
| 353 | /* Legacy: value, showHidden, depth, colors */ |
| 354 | function inspect(value, opts) { |
| 355 | // Default options |
| 356 | const ctx = { |
| 357 | budget: {}, |
| 358 | indentationLvl: 0, |
| 359 | seen: [], |
| 360 | currentDepth: 0, |
| 361 | stylize: stylizeNoColor, |
| 362 | showHidden: inspectDefaultOptions.showHidden, |
| 363 | depth: inspectDefaultOptions.depth, |
| 364 | colors: inspectDefaultOptions.colors, |
| 365 | customInspect: inspectDefaultOptions.customInspect, |
| 366 | showProxy: inspectDefaultOptions.showProxy, |
| 367 | maxArrayLength: inspectDefaultOptions.maxArrayLength, |
| 368 | maxStringLength: inspectDefaultOptions.maxStringLength, |
| 369 | breakLength: inspectDefaultOptions.breakLength, |
| 370 | compact: inspectDefaultOptions.compact, |
| 371 | sorted: inspectDefaultOptions.sorted, |
| 372 | getters: inspectDefaultOptions.getters, |
| 373 | numericSeparator: inspectDefaultOptions.numericSeparator, |
| 374 | }; |
| 375 | if (arguments.length > 1) { |
| 376 | // Legacy... |
| 377 | if (arguments.length > 2) { |
| 378 | if (arguments[2] !== undefined) { |
| 379 | ctx.depth = arguments[2]; |
| 380 | } |
| 381 | if (arguments.length > 3 && arguments[3] !== undefined) { |
| 382 | ctx.colors = arguments[3]; |
| 383 | } |
| 384 | } |
| 385 | // Set user-specified options |
| 386 | if (typeof opts === 'boolean') { |
| 387 | ctx.showHidden = opts; |
| 388 | } else if (opts) { |
| 389 | const optKeys = ObjectKeys(opts); |
| 390 | for (let i = 0; i < optKeys.length; ++i) { |
| 391 | const key = optKeys[i]; |
| 392 | // TODO(BridgeAR): Find a solution what to do about stylize. Either make |
| 393 | // this function public or add a new API with a similar or better |
| 394 | // functionality. |
| 395 | if ( |
| 396 | ObjectPrototypeHasOwnProperty(inspectDefaultOptions, key) || |
| 397 | key === 'stylize') { |
| 398 | ctx[key] = opts[key]; |
| 399 | } else if (ctx.userOptions === undefined) { |
| 400 | // This is required to pass through the actual user input. |
| 401 | ctx.userOptions = opts; |
| 402 | } |
| 403 | } |
| 404 | } |
| 405 | } |
| 406 | if (ctx.colors) ctx.stylize = stylizeWithColor; |
| 407 | if (ctx.maxArrayLength === null) ctx.maxArrayLength = Infinity; |
| 408 | if (ctx.maxStringLength === null) ctx.maxStringLength = Infinity; |
| 409 | return formatValue(ctx, value, 0); |
| 410 | } |
| 411 | inspect.custom = customInspectSymbol; |
no test coverage detected