Skip to content

Commit

Permalink
lib: replace Symbol.hasInstance by SymbolHasInstance
Browse files Browse the repository at this point in the history
PR-URL: #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>
  • Loading branch information
Sebastien-Ahkrin authored and targos committed Jan 14, 2020
1 parent 5cfcf6f commit 581e837
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const {
ObjectDefineProperty,
ObjectSetPrototypeOf,
Symbol,
SymbolHasInstance,
} = primordials;

module.exports = Writable;
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/console/constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const {
ObjectValues,
ReflectOwnKeys,
Symbol,
SymbolHasInstance,
} = primordials;

const { trace } = internalBinding('trace_events');
Expand Down Expand Up @@ -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];
}
Expand Down

0 comments on commit 581e837

Please sign in to comment.