Skip to content

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

@rauschma

Description

@rauschma

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.utilIssues and PRs related to the built-in util module.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions