\href{http://nodejs.org/api/stream.html\#stream_class_stream_transform_1}{\texttt{ Transform stream}} for Node.\+js that allows you to run your transforms in parallel without changing the order of the output. \begin{DoxyVerb}npm install parallel-transform
\end{DoxyVerb}
 It is easy to use


\begin{DoxyCode}{0}
\DoxyCodeLine{var transform = require('parallel-\/transform');}
\DoxyCodeLine{}
\DoxyCodeLine{var stream = transform(10, function(data, callback) \{ // 10 is the parallism level}
\DoxyCodeLine{    setTimeout(function() \{}
\DoxyCodeLine{        callback(null, data);}
\DoxyCodeLine{    \}, Math.random() * 1000);}
\DoxyCodeLine{\});}
\DoxyCodeLine{}
\DoxyCodeLine{for (var i = 0; i < 10; i++) \{}
\DoxyCodeLine{    stream.write(''+i);}
\DoxyCodeLine{\}}
\DoxyCodeLine{stream.end();}
\DoxyCodeLine{}
\DoxyCodeLine{stream.on('data', function(data) \{}
\DoxyCodeLine{    console.log(data); // prints 0,1,2,...}
\DoxyCodeLine{\});}
\DoxyCodeLine{stream.on('end', function() \{}
\DoxyCodeLine{    console.log('stream has ended');}
\DoxyCodeLine{\}); }

\end{DoxyCode}


If you run the above example you\textquotesingle{}ll notice that it runs in parallel (does not take $\sim$1 second between each print) and that the order is preserved\hypertarget{md_sfcode_node_modules_parallel_transform_README_autotoc_md20226}{}\doxysection{Stream options}\label{md_sfcode_node_modules_parallel_transform_README_autotoc_md20226}
All transforms are Node 0.\+10 streams. Per default they are created with the options {\ttfamily \{object\+Mode\+:true\}}. If you want to use your own stream options pass them as the second parameter


\begin{DoxyCode}{0}
\DoxyCodeLine{var stream = transform(10, \{objectMode:false\}, function(data, callback) \{}
\DoxyCodeLine{    // data is now a buffer}
\DoxyCodeLine{    callback(null, data);}
\DoxyCodeLine{\});}
\DoxyCodeLine{}
\DoxyCodeLine{fs.createReadStream('filename').pipe(stream).pipe(process.stdout); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_parallel_transform_README_autotoc_md20227}{}\doxysubsection{Unordered}\label{md_sfcode_node_modules_parallel_transform_README_autotoc_md20227}
Passing the option {\ttfamily \{ordered\+:false\}} will output the data as soon as it\textquotesingle{}s processed by a transform, without waiting to respect the order.\hypertarget{md_sfcode_node_modules_parallel_transform_README_autotoc_md20228}{}\doxysection{License}\label{md_sfcode_node_modules_parallel_transform_README_autotoc_md20228}
MIT 