diff options
Diffstat (limited to 'ext/console/02_console.js')
-rw-r--r-- | ext/console/02_console.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/ext/console/02_console.js b/ext/console/02_console.js index 8c33ac3bc..295fef4c3 100644 --- a/ext/console/02_console.js +++ b/ext/console/02_console.js @@ -204,7 +204,7 @@ function isFullWidthCodePoint(code) { ); } -function getStringWidth(str) { +export function getStringWidth(str) { str = StringPrototypeNormalize(colors.stripColor(str), "NFC"); let width = 0; @@ -1334,6 +1334,16 @@ function inspectObject(value, inspectOptions, proxyDetails) { ) { return String(value[customInspect](inspect, inspectOptions)); } + if ( + ReflectHas(value, nodeCustomInspect) && + typeof value[nodeCustomInspect] === "function" + ) { + // TODO(kt3k): The last inspect needs to be util.inspect of Node.js. + // We need to move the implementation of util.inspect to this file. + return String( + value[nodeCustomInspect](inspectOptions.depth, inspectOptions, inspect), + ); + } // This non-unique symbol is used to support op_crates, ie. // in extensions/web we don't want to depend on public // Symbol.for("Deno.customInspect") symbol defined in the public API. @@ -2310,6 +2320,7 @@ class Console { } const customInspect = SymbolFor("Deno.customInspect"); +const nodeCustomInspect = SymbolFor("nodejs.util.inspect.custom"); function inspect( value, |