\href{https://travis-ci.org/Marak/colors.js}{\texttt{ }} \href{https://www.npmjs.org/package/colors}{\texttt{ }} \href{https://david-dm.org/Marak/colors.js}{\texttt{ }} \href{https://david-dm.org/Marak/colors.js\#info=devDependencies}{\texttt{ }}

Please check out the roadmap for upcoming features and releases. Please open Issues to provide feedback, and check the {\ttfamily develop} branch for the latest bleeding-\/edge updates.\hypertarget{md_sfcode_node_modules_colors_README_autotoc_md5824}{}\doxysection{get color and style in your node.\+js console}\label{md_sfcode_node_modules_colors_README_autotoc_md5824}
\hypertarget{md_sfcode_node_modules_colors_README_autotoc_md5825}{}\doxysection{Installation}\label{md_sfcode_node_modules_colors_README_autotoc_md5825}
\begin{DoxyVerb}npm install colors
\end{DoxyVerb}
 \hypertarget{md_sfcode_node_modules_colors_README_autotoc_md5826}{}\doxysection{colors and styles!}\label{md_sfcode_node_modules_colors_README_autotoc_md5826}
\hypertarget{md_sfcode_node_modules_colors_README_autotoc_md5827}{}\doxysubsection{text colors}\label{md_sfcode_node_modules_colors_README_autotoc_md5827}

\begin{DoxyItemize}
\item black
\item red
\item green
\item yellow
\item blue
\item magenta
\item cyan
\item white
\item gray
\item grey
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_colors_README_autotoc_md5828}{}\doxysubsection{bright text colors}\label{md_sfcode_node_modules_colors_README_autotoc_md5828}

\begin{DoxyItemize}
\item bright\+Red
\item bright\+Green
\item bright\+Yellow
\item bright\+Blue
\item bright\+Magenta
\item bright\+Cyan
\item bright\+White
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_colors_README_autotoc_md5829}{}\doxysubsection{background colors}\label{md_sfcode_node_modules_colors_README_autotoc_md5829}

\begin{DoxyItemize}
\item bg\+Black
\item bg\+Red
\item bg\+Green
\item bg\+Yellow
\item bg\+Blue
\item bg\+Magenta
\item bg\+Cyan
\item bg\+White
\item bg\+Gray
\item bg\+Grey
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_colors_README_autotoc_md5830}{}\doxysubsection{bright background colors}\label{md_sfcode_node_modules_colors_README_autotoc_md5830}

\begin{DoxyItemize}
\item bg\+Bright\+Red
\item bg\+Bright\+Green
\item bg\+Bright\+Yellow
\item bg\+Bright\+Blue
\item bg\+Bright\+Magenta
\item bg\+Bright\+Cyan
\item bg\+Bright\+White
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_colors_README_autotoc_md5831}{}\doxysubsection{styles}\label{md_sfcode_node_modules_colors_README_autotoc_md5831}

\begin{DoxyItemize}
\item reset
\item bold
\item dim
\item italic
\item underline
\item inverse
\item hidden
\item strikethrough
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_colors_README_autotoc_md5832}{}\doxysubsection{extras}\label{md_sfcode_node_modules_colors_README_autotoc_md5832}

\begin{DoxyItemize}
\item rainbow
\item zebra
\item america
\item trap
\item random
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_colors_README_autotoc_md5833}{}\doxysection{Usage}\label{md_sfcode_node_modules_colors_README_autotoc_md5833}
By popular demand, {\ttfamily colors} now ships with two types of usages!

The super nifty way


\begin{DoxyCode}{0}
\DoxyCodeLine{var colors = require('colors');}
\DoxyCodeLine{}
\DoxyCodeLine{console.log('hello'.green); // outputs green text}
\DoxyCodeLine{console.log('i like cake and pies'.underline.red) // outputs red underlined text}
\DoxyCodeLine{console.log('inverse the color'.inverse); // inverses the color}
\DoxyCodeLine{console.log('OMG Rainbows!'.rainbow); // rainbow}
\DoxyCodeLine{console.log('Run the trap'.trap); // Drops the bass}

\end{DoxyCode}


or a slightly less nifty way which doesn\textquotesingle{}t extend {\ttfamily String.\+prototype}


\begin{DoxyCode}{0}
\DoxyCodeLine{var colors = require('colors/safe');}
\DoxyCodeLine{}
\DoxyCodeLine{console.log(colors.green('hello')); // outputs green text}
\DoxyCodeLine{console.log(colors.red.underline('i like cake and pies')) // outputs red underlined text}
\DoxyCodeLine{console.log(colors.inverse('inverse the color')); // inverses the color}
\DoxyCodeLine{console.log(colors.rainbow('OMG Rainbows!')); // rainbow}
\DoxyCodeLine{console.log(colors.trap('Run the trap')); // Drops the bass}

\end{DoxyCode}


I prefer the first way. Some people seem to be afraid of extending {\ttfamily String.\+prototype} and prefer the second way.

If you are writing good code you will never have an issue with the first approach. If you really don\textquotesingle{}t want to touch {\ttfamily String.\+prototype}, the second usage will not touch {\ttfamily String} native object.\hypertarget{md_sfcode_node_modules_colors_README_autotoc_md5834}{}\doxysection{Enabling/\+Disabling Colors}\label{md_sfcode_node_modules_colors_README_autotoc_md5834}
The package will auto-\/detect whether your terminal can use colors and enable/disable accordingly. When colors are disabled, the color functions do nothing. You can override this with a command-\/line flag\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{node myapp.js -\/-\/no-\/color}
\DoxyCodeLine{node myapp.js -\/-\/color=false}
\DoxyCodeLine{}
\DoxyCodeLine{node myapp.js -\/-\/color}
\DoxyCodeLine{node myapp.js -\/-\/color=true}
\DoxyCodeLine{node myapp.js -\/-\/color=always}
\DoxyCodeLine{}
\DoxyCodeLine{FORCE\_COLOR=1 node myapp.js }

\end{DoxyCode}


Or in code\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{var colors = require('colors');}
\DoxyCodeLine{colors.enable();}
\DoxyCodeLine{colors.disable(); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_colors_README_autotoc_md5835}{}\doxysection{Console.\+log $<$a href=\char`\"{}http\+://nodejs.\+org/docs/latest/api/console.\+html\#console\+\_\+console\+\_\+log\+\_\+data\char`\"{}$>$string substitution$<$/a$>$}\label{md_sfcode_node_modules_colors_README_autotoc_md5835}

\begin{DoxyCode}{0}
\DoxyCodeLine{var name = 'Marak';}
\DoxyCodeLine{console.log(colors.green('Hello \%s'), name);}
\DoxyCodeLine{// outputs -\/> 'Hello Marak' }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_colors_README_autotoc_md5836}{}\doxysection{Custom themes}\label{md_sfcode_node_modules_colors_README_autotoc_md5836}
\hypertarget{md_sfcode_node_modules_colors_README_autotoc_md5837}{}\doxysubsection{Using standard API}\label{md_sfcode_node_modules_colors_README_autotoc_md5837}

\begin{DoxyCode}{0}
\DoxyCodeLine{var colors = require('colors');}
\DoxyCodeLine{}
\DoxyCodeLine{colors.setTheme(\{}
\DoxyCodeLine{  silly: 'rainbow',}
\DoxyCodeLine{  input: 'grey',}
\DoxyCodeLine{  verbose: 'cyan',}
\DoxyCodeLine{  prompt: 'grey',}
\DoxyCodeLine{  info: 'green',}
\DoxyCodeLine{  data: 'grey',}
\DoxyCodeLine{  help: 'cyan',}
\DoxyCodeLine{  warn: 'yellow',}
\DoxyCodeLine{  debug: 'blue',}
\DoxyCodeLine{  error: 'red'}
\DoxyCodeLine{\});}
\DoxyCodeLine{}
\DoxyCodeLine{// outputs red text}
\DoxyCodeLine{console.log("{}this is an error"{}.error);}
\DoxyCodeLine{}
\DoxyCodeLine{// outputs yellow text}
\DoxyCodeLine{console.log("{}this is a warning"{}.warn); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_colors_README_autotoc_md5838}{}\doxysubsection{Using string safe API}\label{md_sfcode_node_modules_colors_README_autotoc_md5838}

\begin{DoxyCode}{0}
\DoxyCodeLine{var colors = require('colors/safe');}
\DoxyCodeLine{}
\DoxyCodeLine{// set single property}
\DoxyCodeLine{var error = colors.red;}
\DoxyCodeLine{error('this is red');}
\DoxyCodeLine{}
\DoxyCodeLine{// set theme}
\DoxyCodeLine{colors.setTheme(\{}
\DoxyCodeLine{  silly: 'rainbow',}
\DoxyCodeLine{  input: 'grey',}
\DoxyCodeLine{  verbose: 'cyan',}
\DoxyCodeLine{  prompt: 'grey',}
\DoxyCodeLine{  info: 'green',}
\DoxyCodeLine{  data: 'grey',}
\DoxyCodeLine{  help: 'cyan',}
\DoxyCodeLine{  warn: 'yellow',}
\DoxyCodeLine{  debug: 'blue',}
\DoxyCodeLine{  error: 'red'}
\DoxyCodeLine{\});}
\DoxyCodeLine{}
\DoxyCodeLine{// outputs red text}
\DoxyCodeLine{console.log(colors.error("{}this is an error"{}));}
\DoxyCodeLine{}
\DoxyCodeLine{// outputs yellow text}
\DoxyCodeLine{console.log(colors.warn("{}this is a warning"{}));}

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_colors_README_autotoc_md5839}{}\doxysubsection{Combining Colors}\label{md_sfcode_node_modules_colors_README_autotoc_md5839}

\begin{DoxyCode}{0}
\DoxyCodeLine{var colors = require('colors');}
\DoxyCodeLine{}
\DoxyCodeLine{colors.setTheme(\{}
\DoxyCodeLine{  custom: ['red', 'underline']}
\DoxyCodeLine{\});}
\DoxyCodeLine{}
\DoxyCodeLine{console.log('test'.custom); }

\end{DoxyCode}


{\itshape Protip\+: There is a secret undocumented style in {\ttfamily colors}. If you find the style you can summon him.} 