Get stdout window width, with four fallbacks, {\ttfamily tty}, {\ttfamily output.\+columns}, a custom environment variable and then a default.

\href{http://badge.fury.io/js/cli-width}{\texttt{ }} \href{https://travis-ci.org/knownasilya/cli-width}{\texttt{ }} \href{https://coveralls.io/github/knownasilya/cli-width?branch=master}{\texttt{ }}

Tested against Node\+JS v10+\hypertarget{md_sfcode_node_modules_cli_width_README_autotoc_md5206}{}\doxysection{Usage}\label{md_sfcode_node_modules_cli_width_README_autotoc_md5206}

\begin{DoxyCode}{0}
\DoxyCodeLine{npm install -\/-\/save cli-\/width }

\end{DoxyCode}



\begin{DoxyCode}{0}
\DoxyCodeLine{"{}use strict"{};}
\DoxyCodeLine{}
\DoxyCodeLine{const cliWidth = require("{}cli-\/width"{});}
\DoxyCodeLine{}
\DoxyCodeLine{cliWidth(); // maybe 204 :) }

\end{DoxyCode}


You can also set the {\ttfamily CLI\+\_\+\+WIDTH} environment variable.

If none of the methods are supported, and the environment variable isn\textquotesingle{}t set, the default width value is going to be {\ttfamily 0}, that can be changed using the configurable {\ttfamily options}.\hypertarget{md_sfcode_node_modules_cli_width_README_autotoc_md5207}{}\doxysection{API}\label{md_sfcode_node_modules_cli_width_README_autotoc_md5207}
\hypertarget{md_sfcode_node_modules_cli_width_README_autotoc_md5208}{}\doxysubsection{cli\+Width(\mbox{[}options\mbox{]})}\label{md_sfcode_node_modules_cli_width_README_autotoc_md5208}
{\ttfamily cli\+Width} can be configured using an {\ttfamily options} parameter, the possible properties are\+:


\begin{DoxyItemize}
\item {\bfseries{default\+Width}}$<$number$>$ Defines a default value to be used if none of the methods are available, defaults to {\ttfamily 0}
\item {\bfseries{output}}$<$object$>$ A stream to be used to read width values from, defaults to {\ttfamily process.\+stdout}
\item {\bfseries{tty}}$<$object$>$ TTY module to try to read width from as a fallback, defaults to `require(\textquotesingle{}tty')\`{}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_cli_width_README_autotoc_md5209}{}\doxysubsection{Examples}\label{md_sfcode_node_modules_cli_width_README_autotoc_md5209}
Defining both a default width value and a stream output to try to read from\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{const cliWidth = require("{}cli-\/width"{});}
\DoxyCodeLine{const ttys = require("{}ttys"{});}
\DoxyCodeLine{}
\DoxyCodeLine{cliWidth(\{}
\DoxyCodeLine{  defaultWidth: 80,}
\DoxyCodeLine{  output: ttys.output,}
\DoxyCodeLine{\}); }

\end{DoxyCode}


Defines a different tty module to read width from\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{const cliWidth = require("{}cli-\/width"{});}
\DoxyCodeLine{const ttys = require("{}ttys"{});}
\DoxyCodeLine{}
\DoxyCodeLine{cliWidth(\{}
\DoxyCodeLine{  tty: ttys,}
\DoxyCodeLine{\}); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_cli_width_README_autotoc_md5210}{}\doxysection{Tests}\label{md_sfcode_node_modules_cli_width_README_autotoc_md5210}

\begin{DoxyCode}{0}
\DoxyCodeLine{npm install}
\DoxyCodeLine{npm test }

\end{DoxyCode}


Coverage can be generated with {\ttfamily npm run coverage}. 