writeStream.hasColors([count][, env])
-
count
<integer> 请求的颜色数量(最小为 2)。默认值:16.¥
count
<integer> The number of colors that are requested (minimum 2). Default: 16. -
env
<Object> 包含要检查的环境变量的对象。这使得模拟特定终端的使用成为可能。默认值:process.env
。¥
env
<Object> An object containing the environment variables to check. This enables simulating the usage of a specific terminal. Default:process.env
. -
返回:<boolean>
¥Returns: <boolean>
如果 writeStream
支持的颜色至少与 count
中提供的颜色一样多,则返回 true
。最小支持为 2(黑色和白色)。
¥Returns true
if the writeStream
supports at least as many colors as provided
in count
. Minimum support is 2 (black and white).
这具有与 writeStream.getColorDepth()
中描述的相同的误报和漏报。
¥This has the same false positives and negatives as described in
writeStream.getColorDepth()
.
process.stdout.hasColors();
// Returns true or false depending on if `stdout` supports at least 16 colors.
process.stdout.hasColors(256);
// Returns true or false depending on if `stdout` supports at least 256 colors.
process.stdout.hasColors({ TMUX: '1' });
// Returns true.
process.stdout.hasColors(2 ** 24, { TMUX: '1' });
// Returns false (the environment setting pretends to support 2 ** 8 colors).