Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util.styleText(): Combining multiple styles in a single string? #52035

Closed
rauschma opened this issue Mar 10, 2024 · 4 comments · Fixed by #52040
Closed

util.styleText(): Combining multiple styles in a single string? #52035

rauschma opened this issue Mar 10, 2024 · 4 comments · Fixed by #52040
Labels
feature request Issues that request new features to be added to Node.js. util Issues and PRs related to the built-in util module.

Comments

@rauschma
Copy link

rauschma commented Mar 10, 2024

What is the problem this feature will solve?

Currently, using multiple styles with util.styleText() is slightly verbose:

console.log(
  util.styleText('bold', util.styleText('red', 'Bold and red!')),
); 

What is the feature you are proposing to solve the problem?

Maybe multiple styles per format string could be supported – e.g.:

console.log(
  util.styleText('bold+red', 'Bold and red!'),
); 

Downside: It would make autocomplete in IDEs less straightforward if not impossible.

@rauschma rauschma added the feature request Issues that request new features to be added to Node.js. label Mar 10, 2024
@marco-ippolito
Copy link
Member

marco-ippolito commented Mar 11, 2024

what about passing an array?

util.styleText(['bold', 'red'], 'Bold and red!')

@rauschma
Copy link
Author

rauschma commented Mar 11, 2024

Good idea! Same pros and autocomplete works.

@VoltrexKeyva VoltrexKeyva added the util Issues and PRs related to the built-in util module. label Mar 11, 2024
nodejs-github-bot pushed a commit that referenced this issue Mar 15, 2024
PR-URL: #52040
Fixes: #52035
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
rdw-msft pushed a commit to rdw-msft/node that referenced this issue Mar 26, 2024
PR-URL: nodejs#52040
Fixes: nodejs#52035
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
@ai
Copy link

ai commented Apr 3, 2024

Seems like we need also to add types to @types/node

@steffen-4s1
Copy link

Seems like we need also to add types to @types/node

Work is in progress -> #69212

marco-ippolito added a commit that referenced this issue May 2, 2024
PR-URL: #52040
Fixes: #52035
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
marco-ippolito added a commit that referenced this issue May 3, 2024
PR-URL: #52040
Fixes: #52035
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
jcbhmr pushed a commit to jcbhmr/node that referenced this issue May 15, 2024
PR-URL: nodejs#52040
Fixes: nodejs#52035
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. util Issues and PRs related to the built-in util module.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants