Repository navigation
util: require validateStream === false for the styleText fast path - #67720
GBra-4-669 wants to merge 1 commit into
Conversation
|
Review requested:
|
|
Welcome to Node.js, and thank you for your first contribution! Before review, please take a moment to read:
Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal. |
araujogui
left a comment
There was a problem hiding this comment.
LGTM. Users relying on an integer validateStream will break, so I'm labeling this as semver-major.
This comment was marked as resolved.
This comment was marked as resolved.
Signed-off-by: GBra 4.669 <35969802+GBra-4-669@users.noreply.github.com>
52f4e2c to
db83b03
Compare
| // the high-miss-rate / large-cache scenario (e.g. user-randomised colors). | ||
| format: ['red', 'italic', 'invalid', '#ff0000', '#rotating'], | ||
| validateStream: [1, 0], | ||
| validateStream: [true, false], |
There was a problem hiding this comment.
I'm almost sure true and false are passed as strings to the benchmark function (unless something has changed recently).
There was a problem hiding this comment.
Yes, they are passed as strings, then _parseArgs converts them (benchmark/common.js:121-122) so [true, false] reaches main() as real bools.
Same convention as 42d0e1307 ("benchmark: use boolean options in benchmark tests").
|
Honestly, that would be better solved without a semver major change. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #67720 +/- ##
=======================================
Coverage 90.51% 90.51%
=======================================
Files 805 805
Lines 285786 285786
Branches 55171 55178 +7
=======================================
+ Hits 258669 258673 +4
- Misses 17207 17216 +9
+ Partials 9910 9897 -13
🚀 New features to boost your workflow:
|
are you suggesting casting integers to boolean or vice-versa? |
styleText('red', 'text', { validateStream: 0 })returned styled text instead of throwing. The single-format fast path checkedvalidateStreamfor truthiness before the options were validated so a falsy non-boolean value skipped validation. RequirevalidateStream === falsefor the fast path: other non-boolean values now reachvalidateBoolean()and throwERR_INVALID_ARG_TYPE,falsestill skips stream validation andnull/undefinedstill select the default.Updated the benchmark's
validateStreamaxis from[1, 0]to[true, false].Added cases to
test/parallel/test-util-styletext.js, currently failing onmain.Fixes: #67700