-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
[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.25% 90.25% -0.01%
==========================================
Files 630 630
Lines 185697 185957 +260
Branches 36409 36447 +38
==========================================
+ Hits 167603 167834 +231
- Misses 10998 11003 +5
- Partials 7096 7120 +24
🚀 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. 😅
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.