From 7686865174ab637ecb8fbe96e2fccd0b395ef4b6 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sat, 30 Nov 2019 11:07:12 +0100 Subject: [PATCH] util: inspect (user defined) prototype properties MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is only active if the `showHidden` option is truthy. The implementation is a trade-off between accuracy and performance. This will miss properties such as properties added to built-in data types. The goal is mainly to visualize prototype getters and setters such as: class Foo { ownProperty = true get bar() { return 'Hello world!' } } const a = new Foo() The `bar` property is a non-enumerable property on the prototype while `ownProperty` will be set directly on the created instance. The output is similar to the one of Chromium when inspecting objects closer. The output from Firefox is difficult to compare, since it's always a structured interactive output and was therefore not taken into account. Backport-PR-URL: https://github.com/nodejs/node/pull/31431 PR-URL: https://github.com/nodejs/node/pull/30768 Fixes: https://github.com/nodejs/node/issues/30183 Reviewed-By: James M Snell Reviewed-By: Michaƫl Zasso --- doc/api/util.md | 7 +- lib/internal/util/inspect.js | 116 +++++++++++++++--- test/parallel/test-util-inspect.js | 80 +++++++++++- ...test-whatwg-encoding-custom-textdecoder.js | 17 ++- 4 files changed, 198 insertions(+), 22 deletions(-) diff --git a/doc/api/util.md b/doc/api/util.md index b26d2a9558c987..e2024764676653 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -398,6 +398,10 @@ stream.write('With ES6');