From 5e6940d4f6e59433976dc09979f3c8fb116b4230 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Wed, 26 Sep 2018 23:17:26 +0200 Subject: util: set `super_` property to non-enumerable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using `util.inherits()` adds a `super_` property to the constructor and inspecting that constructor is going to show that property even though it's not useful for the user. Therefore the property is now set as non-enumerable and such entries are not visible by default when using `console.log()` or `util.inspect()`. PR-URL: https://github.com/nodejs/node/pull/23107 Reviewed-By: Anna Henningsen Reviewed-By: Jeremiah Senkpiel Reviewed-By: Matteo Collina Reviewed-By: Michaƫl Zasso Reviewed-By: James M Snell --- lib/util.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/util.js') diff --git a/lib/util.js b/lib/util.js index ae2295533d..8eaf62f0ab 100644 --- a/lib/util.js +++ b/lib/util.js @@ -285,7 +285,11 @@ function inherits(ctor, superCtor) { throw new ERR_INVALID_ARG_TYPE('superCtor.prototype', 'Function', superCtor.prototype); } - ctor.super_ = superCtor; + Object.defineProperty(ctor, 'super_', { + value: superCtor, + writable: true, + configurable: true + }); Object.setPrototypeOf(ctor.prototype, superCtor.prototype); } -- cgit v1.2.3