From e01433db8b6d2589775396e7f1dc1be4007ff65d Mon Sep 17 00:00:00 2001 From: Sebastien Ahkrin Date: Fri, 13 Dec 2019 22:13:49 +0100 Subject: [PATCH] lib: replace Symbol.hasInstance by SymbolHasInstance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/30948 Reviewed-By: Michaƫl Zasso Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat Reviewed-By: David Carlier Reviewed-By: Matteo Collina Reviewed-By: Rich Trott Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell --- lib/_stream_writable.js | 7 ++++--- lib/internal/console/constructor.js | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index c65db3cbee8880..e6195c60516354 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -30,6 +30,7 @@ const { ObjectDefineProperty, ObjectSetPrototypeOf, Symbol, + SymbolHasInstance, } = primordials; module.exports = Writable; @@ -196,9 +197,9 @@ ObjectDefineProperty(WritableState.prototype, 'buffer', { // Test _writableState for inheritance to account for Duplex streams, // whose prototype chain only points to Readable. var realHasInstance; -if (typeof Symbol === 'function' && Symbol.hasInstance) { - realHasInstance = Function.prototype[Symbol.hasInstance]; - ObjectDefineProperty(Writable, Symbol.hasInstance, { +if (typeof Symbol === 'function' && SymbolHasInstance) { + realHasInstance = Function.prototype[SymbolHasInstance]; + ObjectDefineProperty(Writable, SymbolHasInstance, { value: function(object) { if (realHasInstance.call(this, object)) return true; diff --git a/lib/internal/console/constructor.js b/lib/internal/console/constructor.js index 054e1bb2631a81..aab46fb6d40af8 100644 --- a/lib/internal/console/constructor.js +++ b/lib/internal/console/constructor.js @@ -14,6 +14,7 @@ const { ObjectValues, ReflectOwnKeys, Symbol, + SymbolHasInstance, } = primordials; const { trace } = internalBinding('trace_events'); @@ -128,7 +129,7 @@ const consolePropAttributes = { }; // Fixup global.console instanceof global.console.Console -ObjectDefineProperty(Console, Symbol.hasInstance, { +ObjectDefineProperty(Console, SymbolHasInstance, { value(instance) { return instance[kIsConsole]; }