Style overview
This module implements a PPStyle, a context-dependent styler whose context is the value being rendered. A PPStyle is an alias for ASContextStyler.Type<PPValue.Any> (see @parischap/ansi-styles/ASContextStyler). It allows the style applied to a part of the output to vary with the depth, runtime type, or key type of the value being rendered.
Three palette-based constructors are provided: makeDepthIndexed, makeTypeIndexed, and makeKeyTypeIndexed. Use any constructor of ASContextStyler to define more specialized styles.
Table of contents
Constructors
makeDepthIndexed
Constructor of a palette-based depth-indexed PPStyle that picks a color from palette using the current nesting depth of the value being rendered. Useful for bracket coloring.
Signature
export declare const makeDepthIndexed: (palette: ASPalette.Type) => Type
makeKeyTypeIndexed
Constructor of a palette-based key-type-indexed PPStyle that picks index 0 from palette for properties whose key is a string and index 1 for properties whose key is a symbol. Useful for property-key coloring.
Signature
export declare const makeKeyTypeIndexed: (palette: ASPalette.Type) => Type
makeTypeIndexed
Constructor of a palette-based type-indexed PPStyle that picks a color from palette using the runtime type of the value’s content (string, number, bigint, boolean, symbol, null, undefined). Useful for primitive-value coloring.
Signature
export declare const makeTypeIndexed: (palette: ASPalette.Type) => Type
Models
Type (type alias)
Type of a PPStyle
Signature
export type Type = ASContextStyler.Type<PPValue.Any>