From f51b5bd3dcb2269dc6fd2fb7ca493091c17f497b 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 5a88c817bd9fcc..e2e1900506acc9 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -30,6 +30,7 @@ const { ObjectDefineProperty, ObjectSetPrototypeOf, Symbol, + SymbolHasInstance, } = primordials; module.exports = Writable; @@ -203,9 +204,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 d785b7f8dea292..aff24f93455c8b 100644 --- a/lib/internal/console/constructor.js +++ b/lib/internal/console/constructor.js @@ -16,6 +16,7 @@ const { ObjectValues, ReflectOwnKeys, Symbol, + SymbolHasInstance, } = primordials; const { trace } = internalBinding('trace_events'); @@ -133,7 +134,7 @@ const consolePropAttributes = { }; // Fixup global.console instanceof global.console.Console -ObjectDefineProperty(Console, Symbol.hasInstance, { +ObjectDefineProperty(Console, SymbolHasInstance, { value(instance) { return instance[kIsConsole]; }