From a0cd961ccf3638de8f4ac34c44a36445bb3ea2ff Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Mon, 1 Sep 2025 21:43:16 +0200 Subject: [PATCH 01/11] util,console: colorize regexp groups, character classes, etc This adds a parser to parse the regular expression and to highlight different parts of a regular expression in case colors are active. It is a one time pass algorithm and should therefore not cause too much overhead during parsing. As side effect, it is now possible to create individual styles to colorize inspected values values as a user likes. This might for example be expanded to numbers with numeric separators, highlighting the separators or decimal points different. It would in theory also be possible to return a changed string. That is however not the intention for this API as it is only triggered in case colors are active. --- doc/api/util.md | 23 ++- lib/internal/util/inspect.js | 267 ++++++++++++++++++++++++++++++++++- 2 files changed, 284 insertions(+), 6 deletions(-) diff --git a/doc/api/util.md b/doc/api/util.md index 9d452311aa7468..25f103c8262baa 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -845,6 +845,11 @@ stream.write('With ES6');