beta export interface IColorableSequence { text : string ; isEol ? : boolean ; foregroundColor ? : ColorValue ; backgroundColor ? : ColorValue ; textAttributes ? : TextAttribute [ ] ; } export const eolSequence = { isEol : true } as IColorableSequence ; /**
 * Colors used with  IColorableSequence .
 *  beta export enum ColorValue { Black , Red , Green , Yellow , Blue , Magenta , Cyan , White , Gray } /**
 * Text styles used with  IColorableSequence .
 *  beta export enum TextAttribute { Bold , Dim , Underline , Blink , InvertColor , Hidden } export enum ConsoleColorCodes { BlackForeground = 30 , RedForeground = 31 , GreenForeground = 32 , YellowForeground = 33 , BlueForeground = 34 , MagentaForeground = 35 , CyanForeground = 36 , WhiteForeground = 37 , GrayForeground = 90 , DefaultForeground = 39 , BlackBackground = 40 , RedBackground = 41 , GreenBackground = 42 , YellowBackground = 43 , BlueBackground = 44 , MagentaBackground = 45 , CyanBackground = 46 , WhiteBackground = 47 , GrayBackground = 100 , DefaultBackground = 49 , Bold = 1 , Dim = 2 , NormalColorOrIntensity = 22 , Underline = 4 , UnderlineOff = 24 , Blink = 5 , BlinkOff = 25 , InvertColor = 7 , InvertColorOff = 27 , Hidden = 8 , HiddenOff = 28 } example beta export class Colors { public static black ( text ) { return { ... Colors . _normalizeStringOrColorableSequence ( text ) , foregroundColor : ColorValue . Black } ; } public static red ( text ) { return { ... Colors . _normalizeStringOrColorableSequence ( text ) , foregroundColor : ColorValue . Red } ; } public static green ( text ) { return { ... Colors . _normalizeStringOrColorableSequence ( text ) , foregroundColor : ColorValue . Green } ; } public static yellow ( text ) { return { ... Colors . _normalizeStringOrColorableSequence ( text ) , foregroundColor : ColorValue . Yellow } ; } public static blue ( text ) { return { ... Colors . _normalizeStringOrColorableSequence ( text ) , foregroundColor : ColorValue . Blue } ; } public static magenta ( text ) { return { ... Colors . _normalizeStringOrColorableSequence ( text ) , foregroundColor : ColorValue . Magenta } ; } public static cyan ( text ) { return { ... Colors . _normalizeStringOrColorableSequence ( text ) , foregroundColor : ColorValue . Cyan } ; } public static white ( text ) { return { ... Colors . _normalizeStringOrColorableSequence ( text ) , foregroundColor : ColorValue . White } ; } public static gray ( text ) { return { ... Colors . _normalizeStringOrColorableSequence ( text ) , foregroundColor : ColorValue . Gray } ; } public static blackBackground ( text ) { return { ... Colors . _normalizeStringOrColorableSequence ( text ) , backgroundColor : ColorValue . Black } ; } public static redBackground ( text ) { return { ... Colors . _normalizeStringOrColorableSequence ( text ) , backgroundColor : ColorValue . Red } ; } public static greenBackground ( text ) { return { ... Colors . _normalizeStringOrColorableSequence ( text ) , backgroundColor : ColorValue . Green } ; } public static yellowBackground ( text ) { return { ... Colors . _normalizeStringOrColorableSequence ( text ) , backgroundColor : ColorValue . Yellow } ; } public static blueBackground ( text ) { return { ... Colors . _normalizeStringOrColorableSequence ( text ) , backgroundColor : ColorValue . Blue } ; } public static magentaBackground ( text ) { return { ... Colors . _normalizeStringOrColorableSequence ( text ) , backgroundColor : ColorValue . Magenta } ; } public static cyanBackground ( text ) { return { ... Colors . _normalizeStringOrColorableSequence ( text ) , backgroundColor : ColorValue . Cyan } ; } public static whiteBackground ( text ) { return { ... Colors . _normalizeStringOrColorableSequence ( text ) , backgroundColor : ColorValue . White } ; } public static grayBackground ( text ) { return { ... Colors . _normalizeStringOrColorableSequence ( text ) , backgroundColor : ColorValue . Gray } ; } public static bold ( text ) { return Colors . _applyTextAttribute ( text , TextAttribute . Bold ) ; } public static dim ( text ) { return Colors . _applyTextAttribute ( text , TextAttribute . Dim ) ; } public static underline ( text ) { return Colors . _applyTextAttribute ( text , TextAttribute . Underline ) ; } public static blink ( text ) { return Colors . _applyTextAttribute ( text , TextAttribute . Blink ) ; } public static invertColor ( text ) { return Colors . _applyTextAttribute ( text , TextAttribute . InvertColor ) ; } public static hidden ( text ) { return Colors . _applyTextAttribute ( text , TextAttribute . Hidden ) ; } /**
     * If called with a string, returns the string wrapped in a  IColorableSequence .
     * If called with a  IColorableSequence , returns the  IColorableSequence .
     *
     *  internal public static _normalizeStringOrColorableSequence ( value ) { if ( typeof value === 'string' ) { return { text : value } ; } else { return value ; } } private static _applyTextAttribute ( text , attribute ) { const sequence = Colors . _normalizeStringOrColorableSequence ( text ) ; if ( ! sequence . textAttributes ) { sequence . textAttributes = [ ] ; } sequence . textAttributes . push ( attribute ) ; return sequence ; } }