[`util.styleText`] Allow `text` param to be any scalar value (ex. `number`, `bool` etc additionaly to `string`) which will be casted internally to `string`

Open Beginner friendly
#63,841 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
javascript
Domain
cli

Research direction

Start by locating the implementation and existing tests for util.styleText, then review how the text parameter is currently validated or used. Update the behavior so scalar values are accepted and converted to strings, and run the relevant tests to confirm string and non-string inputs produce the expected styled output.

Written by the indexing model from the issue text.

Description

feature request
What is the problem this feature will solve?

Sometimes need to pass as text param for styleText some value that is not string like number, in this case need to explicitly cast value to string which increases boilerplate code to work with styleText easily

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

Suggestion is to cast text parameter value in styleText method to String(text) if it is not string

What alternatives have you considered?

No response

Dominant language
JavaScript
Stars
122k
Forks
37.4k
Avg merge
4d 3h
Merged PRs (30d)
273

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nodejs/node

All issues in nodejs/node

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.