lib: replace Symbol.hasInstance by SymbolHasInstance

PR-URL: https://github.com/nodejs/node/pull/30948
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Sebastien Ahkrin 2019-12-13 22:13:49 +01:00 committed by Michaël Zasso
parent 593240d1a1
commit 48d986c40f
No known key found for this signature in database
GPG Key ID: 770F7A9A5AE15600
2 changed files with 6 additions and 4 deletions

View File

@ -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;

View File

@ -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];
}