\begin{quote}
Color your terminal using pure idiomatic Java\+Script. \end{quote}
Colorette is a Node.\+js library for embellishing your CLI tools with colors and styles using \href{https://en.wikipedia.org/wiki/ANSI_escape_code}{\texttt{ ANSI escape codes}}.


\begin{DoxyItemize}
\item $\sim$1.5x faster than alternatives (\href{\#run-the-benchmarks}{\texttt{ run the benchmarks}}).
\item No wonky prototype-\/based method chains.
\item Automatic color support detection.
\item $\sim$80 LOC and no dependencies.
\item \href{https://no-color.org}{\texttt{ {\ttfamily NO\+\_\+\+COLOR}}} friendly.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_colorette_README_autotoc_md5816}{}\doxysection{Quickstart}\label{md_sfcode_node_modules_colorette_README_autotoc_md5816}

\begin{DoxyCode}{0}
\DoxyCodeLine{npm i colorette }

\end{DoxyCode}


Import the \href{\#styles}{\texttt{ styles}} you need. \href{\#supported-styles}{\texttt{ Here}}\textquotesingle{}s the list of styles you can use.


\begin{DoxyCode}{0}
\DoxyCodeLine{import \{ red, blue, bold \} from "{}colorette"{} }

\end{DoxyCode}


Wrap your strings in one or more styles to produce the finish you\textquotesingle{}re looking for.


\begin{DoxyCode}{0}
\DoxyCodeLine{console.log(bold(blue("{}Engage!"{}))) }

\end{DoxyCode}


Mix it with \href{https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals}{\texttt{ template literals}} to interpolate variables, expressions and create multi-\/line strings easily.


\begin{DoxyCode}{0}
\DoxyCodeLine{console.log(`}
\DoxyCodeLine{  Beets are \$\{red("{}red"{})\},}
\DoxyCodeLine{  Plums are \$\{blue("{}blue"{})\},}
\DoxyCodeLine{  \$\{bold("{}Colorette!"{})\}.}
\DoxyCodeLine{`) }

\end{DoxyCode}


Using {\ttfamily console.\+log}\textquotesingle{}s \href{https://nodejs.org/api/console.html\#console_console_log_data_args}{\texttt{ string substitution}} can be useful too.


\begin{DoxyCode}{0}
\DoxyCodeLine{console.log(bold("{}Total: \$\%f"{}), 1.99) }

\end{DoxyCode}


You can also nest styles without breaking existing escape codes.


\begin{DoxyCode}{0}
\DoxyCodeLine{console.log(red(`Red Shirt \$\{blue("{}Blue Shirt"{})\} Red Shirt`)) }

\end{DoxyCode}


Feeling adventurous? Try the \href{https://github.com/tc39/proposal-pipeline-operator}{\texttt{ pipeline operator}}.


\begin{DoxyCode}{0}
\DoxyCodeLine{console.log("{}Make it so!"{} |> bold |> blue) }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_colorette_README_autotoc_md5817}{}\doxysection{Supported styles}\label{md_sfcode_node_modules_colorette_README_autotoc_md5817}
Colorette supports the standard and bright color variations out-\/of-\/the-\/box. See \href{https://github.com/jorgebucaran/colorette/issues/27}{\texttt{ this issue}} if you were looking for True\+Color support.

\tabulinesep=1mm
\begin{longtabu}spread 0pt [c]{*{5}{|X[-1]}|}
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ Colors   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ Background Colors   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ Bright Colors   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ Bright Background Colors   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ Modifiers    }\\\cline{1-5}
\endfirsthead
\hline
\endfoot
\hline
\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ Colors   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ Background Colors   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ Bright Colors   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ Bright Background Colors   }&\PBS\centering \cellcolor{\tableheadbgcolor}\textbf{ Modifiers    }\\\cline{1-5}
\endhead
black   &bg\+Black   &black\+Bright   &bg\+Black\+Bright   &dim    \\\cline{1-5}
red   &bg\+Red   &red\+Bright   &bg\+Red\+Bright   &{\bfseries{bold}}    \\\cline{1-5}
green   &bg\+Green   &green\+Bright   &bg\+Green\+Bright   &hidden    \\\cline{1-5}
yellow   &bg\+Yellow   &yellow\+Bright   &bg\+Yellow\+Bright   &{\itshape italic}    \\\cline{1-5}
blue   &bg\+Blue   &blue\+Bright   &bg\+Blue\+Bright   &underline    \\\cline{1-5}
magenta   &bg\+Magenta   &magenta\+Bright   &bg\+Magenta\+Bright   &\sout{strikethrough}    \\\cline{1-5}
cyan   &bg\+Cyan   &cyan\+Bright   &bg\+Cyan\+Bright   &reset    \\\cline{1-5}
white   &bg\+White   &white\+Bright   &bg\+White\+Bright   &\\\cline{1-5}
gray   &&&&\\\cline{1-5}
\end{longtabu}
\hypertarget{md_sfcode_node_modules_colorette_README_autotoc_md5818}{}\doxysection{API}\label{md_sfcode_node_modules_colorette_README_autotoc_md5818}
\hypertarget{md_sfcode_node_modules_colorette_README_autotoc_md5819}{}\doxysubsection{$<$code$>$$<$i$>$style$<$/i$>$(string)$<$/code$>$}\label{md_sfcode_node_modules_colorette_README_autotoc_md5819}
Returns a string wrapped in the corresponding ANSI escape codes.


\begin{DoxyCode}{0}
\DoxyCodeLine{red("{}Red Alert"{}) //=> \(\backslash\)u001b[31mRed Alert\(\backslash\)u001b[39m }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_colorette_README_autotoc_md5820}{}\doxysubsection{$<$tt$>$options.\+enabled$<$/tt$>$}\label{md_sfcode_node_modules_colorette_README_autotoc_md5820}
Color will be enabled if your terminal supports it, {\ttfamily FORCE\+\_\+\+COLOR} is defined in \href{https://nodejs.org/dist/latest-v8.x/docs/api/process.html\#process_process_env}{\texttt{ {\ttfamily process.\+env}}} and if {\ttfamily NO\+\_\+\+COLOR} isn\textquotesingle{}t, but you can always override it if you want.


\begin{DoxyCode}{0}
\DoxyCodeLine{import \{ options \} from "{}colorette"{}}
\DoxyCodeLine{}
\DoxyCodeLine{options.enabled = false }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_colorette_README_autotoc_md5821}{}\doxysection{Run the benchmarks}\label{md_sfcode_node_modules_colorette_README_autotoc_md5821}

\begin{DoxyCode}{0}
\DoxyCodeLine{npm i -\/C bench \&\& node bench }

\end{DoxyCode}



\begin{DoxyPre}
colorette × 759,429 ops/sec
chalk × 524,034 ops/sec
kleur × 490,347 ops/sec
colors × 255,661 ops/sec
ansi-\/colors × 317,605 ops/sec
\end{DoxyPre}


\#\hypertarget{md_sfcode_node_modules_colorette_README_autotoc_md5822}{}\doxysection{License}\label{md_sfcode_node_modules_colorette_README_autotoc_md5822}
\mbox{\hyperlink{md_sfcode_node_modules_colorette_LICENSE}{MIT}} 