From 8dec909aa75fee206186c57f443403671c8c35b9 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. 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 88e2f34b7c8b26..f4e689a2130bd5 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -398,6 +398,10 @@ stream.write('With ES6');