From 77f22906f71bd6af7afb7ea4dd7fc95c68b55fb2 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 21 Jun 2022 17:33:24 +0200 Subject: [PATCH] util: add colorize functionality The colorize object allows to format strings with ansi color codes so that the string is stylized on a terminal. This is a utility function that should not yet be exposed to the users to allow some further polishing first. Signed-off-by: Ruben Bridgewater --- doc/api/util.md | 42 ++++++++++++++- lib/internal/debugger/inspect_repl.js | 7 ++- lib/internal/repl/utils.js | 4 +- lib/internal/util/inspect.js | 77 +++++++++++++++++++++++++++ 4 files changed, 125 insertions(+), 5 deletions(-) diff --git a/doc/api/util.md b/doc/api/util.md index fafc54c3fadbfe..2fdd6df1382927 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -239,7 +239,47 @@ The `--throw-deprecation` command-line flag and `process.throwDeprecation` property take precedence over `--trace-deprecation` and `process.traceDeprecation`. -## `util.format(format[, ...args])` +## `util.colorize` + + +The `util.colorize` object provides functions that add ansi color codes to the +provided string. These may be used to style terminal output. + +### `util.colorize.