roundel
API reference

roundel/supports-color

Every export of roundel/supports-color, with its signature and doc comment: createSupportsColor, supportsColor, plus 4 types.

import supportsColor from 'roundel/supports-color';
import { createSupportsColor } from 'roundel/supports-color';

Functions

createSupportsColor

The colour support of stream, or of no stream in particular when it is left out.

function createSupportsColor(stream?: Pick<WriteStream, 'isTTY'>, options?: Options): ColorInfo;
ParameterType
stream (optional)Pick<WriteStream, 'isTTY'>
options (optional)Options

Returns ColorInfo

Constants

default

The default export, declared as supportsColor.

supports-color's module: stdout's and stderr's support, decided at import.

const supportsColor: {
    stdout: ColorInfo;
    stderr: ColorInfo;
};

Interfaces

ColorSupport

A level and what it implies.

interface ColorSupport {
    level: ColorSupportLevel;
    hasBasic: boolean;
    has256: boolean;
    has16m: boolean;
}

Options

interface Options {
    /** Whether `process.argv` is sniffed for `--color` and `--no-color` flags. Default `true`. */
    readonly sniffFlags?: boolean;
    /** The stream's TTY-ness, when it is not the stream's own `isTTY`. */
    readonly streamIsTTY?: boolean | undefined;
}

Types

ColorInfo

false when the stream gets no colour.

type ColorInfo = ColorSupport | false;

ColorSupportLevel

0 no colour, 1 the basic 16, 2 ANSI 256, 3 truecolor.

type ColorSupportLevel = 0 | 1 | 2 | 3;

On this page