Skip to main content
WriteStream.prototype.hasColors - Node documentation
method WriteStream.prototype.hasColors

Usage in Deno

import { WriteStream } from "node:tty";
WriteStream.prototype.hasColors(count?: number): boolean

Returns true if the writeStream supports at least as many colors as provided in count. Minimum support is 2 (black and white).

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).

Parameters

optional
count: number = 16

The number of colors that are requested (minimum 2).

Return Type

boolean
WriteStream.prototype.hasColors(env?: object): boolean

Parameters

optional
env: object

Return Type

boolean
WriteStream.prototype.hasColors(
count: number,
env?: object,
): boolean

Parameters

count: number
optional
env: object

Return Type

boolean