lib: optimize styleText when validateStream is false#61792
Open
RafaelGSS wants to merge 2 commits intonodejs:mainfrom
Open
lib: optimize styleText when validateStream is false#61792RafaelGSS wants to merge 2 commits intonodejs:mainfrom
RafaelGSS wants to merge 2 commits intonodejs:mainfrom
Conversation
This commit optimizes the util.styleText when validateStream is false Co-Authored-By: Bruno Rodrigues <swe@brunocroh.com> Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com>
Member
Author
|
@BridgeAR In our understanding to further optimize this, we would need to encapsulate this API into a Any objections to us pursuing that idea in a separate PR? |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #61792 +/- ##
==========================================
- Coverage 89.76% 89.73% -0.03%
==========================================
Files 675 675
Lines 204674 204823 +149
Branches 39330 39367 +37
==========================================
+ Hits 183716 183803 +87
- Misses 13235 13296 +61
- Partials 7723 7724 +1
🚀 New features to boost your workflow:
|
Member
Author
|
PTAL @brunocroh @nodejs/performance |
brunocroh
approved these changes
Feb 16, 2026
santigimeno
approved these changes
Feb 17, 2026
Member
santigimeno
left a comment
There was a problem hiding this comment.
LGTM with some questions.
Comment on lines
-143
to
+200
| const formatArray = ArrayIsArray(format) ? format : [format]; | ||
| const isArray = ArrayIsArray(format); | ||
| const formatArray = isArray ? format : [format]; |
Comment on lines
-146
to
+206
| for (const key of formatArray) { | ||
| for (let i = 0; i < formatArray.length; i++) { |
Comment on lines
-124
to
+166
| function styleText(format, text, { validateStream = true, stream = process.stdout } = {}) { | ||
| function styleText(format, text, options) { |
Member
There was a problem hiding this comment.
Why getting rid of the default values here?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 commit optimizes the util.styleText when validateStream is false
We are investigating how we can further optimise it without changing the API drastically.