repl: move completion logic to internal module #59889
Open
+865
−786
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR moves the repl completion logic into its own internal module, my reasoning for proposing this change is that the repl completion logic currently occupies a big chunk of the repl module and it's hard to tell which functions are relevant to it and which are not.
So, also given the fact that the completion logic is pretty self contained, I believe that isolating it will lead to a better, more maintainable and more understandable code structure.
This is also consistent with the repl history which has its own internal module (and also the await module).
Later I am also planning to do other code restructuring/cleanups, but for this PR, in order to make it easy to review I tried to minimize as much as possible code changes and just tried to move things over the new internal completion module. So in this PR I basically only moved code from
lib/repl.js
tolib/internal/repl/completion.js
, with the only exception being that I moved shared logic into thelib/internal/repl/utils.js
(and imported it in the other 2 modules).