A write stream constructor that supports a flush function that is called before {\ttfamily finish} is emitted


\begin{DoxyCode}{0}
\DoxyCodeLine{npm install flush-\/write-\/stream }

\end{DoxyCode}


\href{http://travis-ci.org/mafintosh/flush-write-stream}{\texttt{ }}\hypertarget{md_sfcode_node_modules_flush_write_stream_README_autotoc_md10810}{}\doxysection{Usage}\label{md_sfcode_node_modules_flush_write_stream_README_autotoc_md10810}

\begin{DoxyCode}{0}
\DoxyCodeLine{var writer = require('flush-\/write-\/stream')}
\DoxyCodeLine{}
\DoxyCodeLine{var ws = writer(write, flush)}
\DoxyCodeLine{}
\DoxyCodeLine{ws.on('finish', function () \{}
\DoxyCodeLine{  console.log('finished')}
\DoxyCodeLine{\})}
\DoxyCodeLine{}
\DoxyCodeLine{ws.write('hello')}
\DoxyCodeLine{ws.write('world')}
\DoxyCodeLine{ws.end()}
\DoxyCodeLine{}
\DoxyCodeLine{function write (data, enc, cb) \{}
\DoxyCodeLine{  // i am your normal .\_write method}
\DoxyCodeLine{  console.log('writing', data.toString())}
\DoxyCodeLine{  cb()}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{function flush (cb) \{}
\DoxyCodeLine{  // i am called before finish is emitted}
\DoxyCodeLine{  setTimeout(cb, 1000) // wait 1 sec}
\DoxyCodeLine{\} }

\end{DoxyCode}


If you run the above it will produce the following output


\begin{DoxyCode}{0}
\DoxyCodeLine{writing hello}
\DoxyCodeLine{writing world}
\DoxyCodeLine{(nothing happens for 1 sec)}
\DoxyCodeLine{finished }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_flush_write_stream_README_autotoc_md10811}{}\doxysection{API}\label{md_sfcode_node_modules_flush_write_stream_README_autotoc_md10811}
\hypertarget{md_sfcode_node_modules_flush_write_stream_README_autotoc_md10812}{}\doxysubsubsection{$<$tt$>$var ws = writer(\mbox{[}options\mbox{]}, write, \mbox{[}flush\mbox{]})$<$/tt$>$}\label{md_sfcode_node_modules_flush_write_stream_README_autotoc_md10812}
Create a new writable stream. Options are forwarded to the stream constructor.\hypertarget{md_sfcode_node_modules_flush_write_stream_README_autotoc_md10813}{}\doxysubsubsection{$<$tt$>$var ws = writer.\+obj(\mbox{[}options\mbox{]}, write, \mbox{[}flush\mbox{]})$<$/tt$>$}\label{md_sfcode_node_modules_flush_write_stream_README_autotoc_md10813}
Same as the above except {\ttfamily object\+Mode} is set to {\ttfamily true} per default.\hypertarget{md_sfcode_node_modules_flush_write_stream_README_autotoc_md10814}{}\doxysection{License}\label{md_sfcode_node_modules_flush_write_stream_README_autotoc_md10814}
MIT 