Repository navigation
lib: reduce internal usage of public require('util') #26546
Description
Activity
- addedhelp wantedIssues that need assistance from volunteers or PRs that need help to proceed.Issues that need assistance from volunteers or PRs that need help to proceed.utilIssues and PRs related to the built-in util module.Issues and PRs related to the built-in util module.good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.
on Mar 9, 2019 I can work on it 🎉
@micheleriva That's great! If possible please try to refactor each file in single commit and submit them as separate PRs, otherwise the PR is bound to require manual backport.
- added a commit that references this issue
on Mar 10, 2019 @joyeecheung Just curious, in many cases
util.inheritscould be replaced byclass ... extends ...instead, is there a reasonsetPrototypeOfshould be used instead?Reacted by Vitali Kuzmich and Rouven Weßling@joyeecheung ok no prob! So I'll close my PR #26552 in flavour of single PRs.
@SimonSchick For public ES5-style classes we have to support instantiation without new so we cannot refactor them to ES6 classes.
I was talking about those that do not support instantiation without
new.Might also be worth mentioning that we dealt with the same issue in sequelize using
Proxys https://github.com/sequelize/sequelize/blob/master/lib/utils/classToInvokable.js#L9
I'm not sure what the exact performance penalties are tho.- added a commit that references this issue
on Mar 12, 2019 - added a commit that references this issue
on Mar 12, 2019 I can work on it!
I was talking about those that do not support instantiation without new.
@SimonSchick I guess if you are sure those do not support instantiation without new, those could be refactored if the tests are happy (probably also needs a CITGM run anyway because undoing
util.inheritsalso removes the hackysuper_property on the classes)157 remaining items
Load more actions- added 2 commits that reference this issue
on Apr 5, 2019 - added a commit that references this issue
on Apr 10, 2019 - added a commit that references this issue
on Apr 10, 2019 - added a commit that references this issue
on Apr 17, 2019 - added a commit that references this issue
on Apr 21, 2019 - added a commit that references this issue
on May 16, 2019 Was looking for issues to work on and noticed that required changes have already been made and merged for timers in lib/internal/timers.js and lib/timers.js. Corresponding PRs can be updated in the original post.
Any reason that this is still open?
Seems like everything was refactored? (given what @karansapolia said).I can only find a single
require('util')in lib at the moment that could be replaced. I'll open a PR for that and close this issue as resolved.
A few patterns (modulo destructuring):
require('util').inherits()usages underlib: Remove util.inherits usage internally? #24395require('util').inspectwithrequire('internal/util/inspect').inspectrequire('util').formatwithrequire('internal/util/inspect').formatrequire('util').debuglogwithrequire('internal/util/debuglog').debuglogrequire('util').typeswithrequire('internal/util/types')require('util').deprecatewithrequire('internal/util').deprecaterequire('util').promisifywithrequire('internal/util').promisifyList of JS files that can be refactored:
lib/domain.js#L29lib/inspector.js#L19