diff --git a/doc/api/util.md b/doc/api/util.md index 8cafd120503764..9c0c010f86875b 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -71,6 +71,25 @@ callbackFunction((err, ret) => { }); ``` +## `util.colorText(format, text)` + + + +* `format` {string} A color format defined in `util.inspect.colors`. +* `text` {string} The text to color. +* Returns: {string} Colored text string. + +Takes `format` and `text` and returns the colored text form + +```js +const util = require('node:util'); + +console.log(util.colorText('red', 'This text shall be in red color')); +// ^ '\u001b[31mThis text shall be in red color\u001b[39m' +``` + ## `util.debuglog(section[, callback])`