lib: optimize styleText when validateStream is false#61792
lib: optimize styleText when validateStream is false#61792RafaelGSS 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>
|
@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:
|
|
PTAL @brunocroh @nodejs/performance |
santigimeno
left a comment
There was a problem hiding this comment.
LGTM with some questions.
| const formatArray = ArrayIsArray(format) ? format : [format]; | ||
| const isArray = ArrayIsArray(format); | ||
| const formatArray = isArray ? format : [format]; |
| for (const key of formatArray) { | ||
| for (let i = 0; i < formatArray.length; i++) { |
| function styleText(format, text, { validateStream = true, stream = process.stdout } = {}) { | ||
| function styleText(format, text, options) { |
There was a problem hiding this comment.
Why getting rid of the default values here?
There was a problem hiding this comment.
process.stdout doesn't need to be evaluated if validateStream is false. Just moved it to the runtime opts check.
This commit optimizes the util.styleText when validateStream is false
We are investigating how we can further optimise it without changing the API drastically.