自定义 util.inspect 颜色
🌐 Customizing util.inspect colors
util.inspect 的颜色输出(如果启用)可以通过 util.inspect.styles 和 util.inspect.colors 属性在全局范围内自定义。
🌐 Color output (if enabled) of util.inspect is customizable globally
via the util.inspect.styles and util.inspect.colors properties.
util.inspect.styles 是一个将样式名称与 util.inspect.colors 中的颜色关联的映射。
默认的样式和相关的颜色为:
🌐 The default styles and associated colors are:
bigint:yellowboolean:yellowdate:magentamodule:underlinename:(无样式)null:boldnumber:yellowregexp:一种为字符类、分组、断言及其他部分着色以提高可读性的方法。要自定义着色,请更改colors属性。默认情况下设置为['red', 'green', 'yellow', 'cyan', 'magenta'],并可根据需要进行调整。该数组会根据“深度”重复迭代。special:cyan(例如,Proxies)string:greensymbol:greenundefined:grey
颜色样式使用 ANSI 控制码,某些终端可能不支持。要验证颜色支持,请使用 tty.hasColors()。
🌐 Color styling uses ANSI control codes that may not be supported on all
terminals. To verify color support use tty.hasColors().
预定义的控制代码列在下面(分为“修饰符”、“前景色”和“背景色”)。
🌐 Predefined control codes are listed below (grouped as "Modifiers", "Foreground colors", and "Background colors").