-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
[WIP] lib: rename functions named value
#57901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Review requested:
|
it'd be great to get a PR that just fixes the |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #57901 +/- ##
=======================================
Coverage 90.17% 90.18%
=======================================
Files 630 630
Lines 186503 186508 +5
Branches 36618 36611 -7
=======================================
+ Hits 168188 168200 +12
+ Misses 11120 11112 -8
- Partials 7195 7196 +1
🚀 New features to boost your workflow:
|
lib/internal/streams/writable.js
Outdated
function hasInstanceFn(instance) { | ||
if (FunctionPrototypeSymbolHasInstance(this, instance)) return true; | ||
if (this !== Writable) return false; | ||
|
||
return instance && instance._writableState instanceof WritableState; | ||
}; | ||
ObjectDefineProperty(hasInstanceFn, 'name', { | ||
__proto__: null, | ||
value: '[Symbol.hasInstance]', | ||
writable: false, | ||
enumerable: false, | ||
configurable: true, | ||
}); | ||
ObjectDefineProperty(Writable, SymbolHasInstance, { | ||
__proto__: null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's set up a util to simplify that
function hasInstanceFn(instance) { | |
if (FunctionPrototypeSymbolHasInstance(this, instance)) return true; | |
if (this !== Writable) return false; | |
return instance && instance._writableState instanceof WritableState; | |
}; | |
ObjectDefineProperty(hasInstanceFn, 'name', { | |
__proto__: null, | |
value: '[Symbol.hasInstance]', | |
writable: false, | |
enumerable: false, | |
configurable: true, | |
}); | |
ObjectDefineProperty(Writable, SymbolHasInstance, { | |
__proto__: null, | |
ObjectDefineProperty(Writable, SymbolHasInstance, { | |
__proto__: null, | |
value: setName(function(object) { | |
if (FunctionPrototypeSymbolHasInstance(this, object)) return true; | |
if (this !== Writable) return false; | |
return object && object._writableState instanceof WritableState; | |
}, '[Symbol.hasInstance]'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. I'm thinking of util that would take the symbol directly and [${kPrivateProperty.toString()}]
-fy it.
Fixing something like
for (const prop of Object.getOwnPropertySymbols(require('console').Console.prototype))
console.log(prop, '-->', require('console').Console.prototype[prop]);
will definitely require a helper function. 😅
8345a46
to
c969ef7
Compare
Refs: #57899
This requires adjusting linter rules. Or slapping
// eslint-disable-line func-name-matching
and regression tests as temporal solution.If anyone is willing to make this into linter rule, feel free to takeover this.