roundel
API reference

roundel/chalk

Every export of roundel/chalk, with its signature and doc comment: modifierNames, foregroundColorNames, backgroundColorNames, underlineColorNames, colorNames, supportsColor and 3 more, plus 16 types.

roundel/chalk (R6): chalk 6's public API — the chainable builder, the mutable level, Chalk, chalkStderr, supportsColor — over the tokens' emitter and the policy's level, graded by chalk's own suite vendored into compat-oracle.

chalk's mutable level is honoured here and nowhere else: chalk.level = 0 silences this façade, not the tokens, which read the policy. The template literal (chalk`{red x}`) went with chalk 5 and is not resurrected. Not one escape is written here: parameters are computed, sgr() in tokens emits them (R3).

The SGR numbers below are chalk's tables (ansi-styles) as written; naming each would double the file the R8 ceiling measures, so the lint's magic-number rule is off here.

import chalk from 'roundel/chalk';
import { modifierNames, foregroundColorNames, backgroundColorNames, … } from 'roundel/chalk';

Constants

default

The default export, declared as chalk.

const chalk: ChalkInstance;

backgroundColorNames

const backgroundColorNames: BackgroundColorName[];

chalkStderr

const chalkStderr: ChalkInstance;

colorNames

const colorNames: ColorName[];

foregroundColorNames

const foregroundColorNames: ForegroundColorName[];

modifierNames

const modifierNames: ModifierName[];

supportsColor

const supportsColor: ColorInfo;

supportsColorStderr

const supportsColorStderr: ColorInfo;

underlineColorNames

const underlineColorNames: UnderlineColorName[];

Interfaces

Chalk

new Chalk({ level }) — an instance with its own level, detected when the option is omitted.

interface Chalk extends ChalkInstance {
}

class Chalk {
    constructor(options?: ChalkOptions);
}

ChalkOptions

interface ChalkOptions {
    /** `undefined` asks for the level to be detected, as omitting it does. */
    readonly level?: ColorSupportLevel | undefined;
}

ColorSupport

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

Types

BackgroundColor

type BackgroundColor = BackgroundColorName;

BackgroundColorName

type BackgroundColorName = `bg${Capitalize<Basic | Bright>}`;

ChalkInstance

type ChalkInstance = Base & {
    readonly [K in ModifierName | ColorName | UnderlineColorName | 'visible']: ChalkInstance;
};

Color

type Color = ColorName;

ColorInfo

type ColorInfo = ColorSupport | false;

ColorName

type ColorName = ForegroundColorName | BackgroundColorName;

ColorSupportLevel

Colour support: none, 16 colours, 256 colours, truecolor. chalk's name for the policy's level.

type ColorSupportLevel = ColorLevel;

ForegroundColor

type ForegroundColor = ForegroundColorName;

ForegroundColorName

type ForegroundColorName = Basic | Bright;

ModifierName

type ModifierName = keyof typeof MODIFIERS;

Modifiers

type Modifiers = ModifierName;

Options

type Options = ChalkOptions;

UnderlineColorName

type UnderlineColorName = `underline${Capitalize<Basic | Bright>}`;

On this page