 \href{https://badge.fury.io/js/fastq}{\texttt{ }} \href{https://david-dm.org/mcollina/fastq}{\texttt{ }}

Fast, in memory work queue. {\ttfamily fastq} is API compatible with \href{https://github.com/caolan/async\#queueworker-concurrency}{\texttt{ {\ttfamily async.\+queue}}}

Benchmarks (1 million tasks)\+:


\begin{DoxyItemize}
\item set\+Immediate\+: 812ms
\item fastq\+: 854ms
\item async.\+queue\+: 1298ms
\item neo\+Async.\+queue\+: 1249ms
\end{DoxyItemize}

Obtained on node 12.\+16.\+1, on a dedicated server.

If you need zero-\/overhead series function call, check out \href{http://npm.im/fastseries}{\texttt{ fastseries}}. For zero-\/overhead parallel function call, check out \href{http://npm.im/fastparallel}{\texttt{ fastparallel}}.

\href{https://github.com/feross/standard}{\texttt{ }}


\begin{DoxyItemize}
\item \href{\#install}{\texttt{ Installation}}
\item \href{\#usage}{\texttt{ Usage}}
\item \href{\#api}{\texttt{ API}}
\item \href{\#license}{\texttt{ Licence \& copyright}}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_fastq_README_autotoc_md10263}{}\doxysection{Install}\label{md_sfcode_node_modules_fastq_README_autotoc_md10263}
{\ttfamily npm i fastq -\/-\/save}\hypertarget{md_sfcode_node_modules_fastq_README_autotoc_md10264}{}\doxysection{Usage}\label{md_sfcode_node_modules_fastq_README_autotoc_md10264}

\begin{DoxyCode}{0}
\DoxyCodeLine{'use strict'}
\DoxyCodeLine{}
\DoxyCodeLine{var queue = require('fastq')(worker, 1)}
\DoxyCodeLine{}
\DoxyCodeLine{queue.push(42, function (err, result) \{}
\DoxyCodeLine{  if (err) \{ throw err \}}
\DoxyCodeLine{  console.log('the result is', result)}
\DoxyCodeLine{\})}
\DoxyCodeLine{}
\DoxyCodeLine{function worker (arg, cb) \{}
\DoxyCodeLine{  cb(null, 42 * 2)}
\DoxyCodeLine{\} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_fastq_README_autotoc_md10265}{}\doxysubsection{Setting this}\label{md_sfcode_node_modules_fastq_README_autotoc_md10265}

\begin{DoxyCode}{0}
\DoxyCodeLine{'use strict'}
\DoxyCodeLine{}
\DoxyCodeLine{var that = \{ hello: 'world' \}}
\DoxyCodeLine{var queue = require('fastq')(that, worker, 1)}
\DoxyCodeLine{}
\DoxyCodeLine{queue.push(42, function (err, result) \{}
\DoxyCodeLine{  if (err) \{ throw err \}}
\DoxyCodeLine{  console.log(this)}
\DoxyCodeLine{  console.log('the result is', result)}
\DoxyCodeLine{\})}
\DoxyCodeLine{}
\DoxyCodeLine{function worker (arg, cb) \{}
\DoxyCodeLine{  console.log(this)}
\DoxyCodeLine{  cb(null, 42 * 2)}
\DoxyCodeLine{\} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_fastq_README_autotoc_md10266}{}\doxysection{API}\label{md_sfcode_node_modules_fastq_README_autotoc_md10266}

\begin{DoxyItemize}
\item \href{\#fastqueue}{\texttt{ {\ttfamily fastqueue()}}}
\item \href{\#push}{\texttt{ {\ttfamily queue\#{\bfseries{push()}}}}}
\item \href{\#unshift}{\texttt{ {\ttfamily queue\#{\bfseries{unshift()}}}}}
\item \href{\#pause}{\texttt{ {\ttfamily queue\#{\bfseries{pause()}}}}}
\item \href{\#resume}{\texttt{ {\ttfamily queue\#{\bfseries{resume()}}}}}
\item \href{\#idle}{\texttt{ {\ttfamily queue\#{\bfseries{idle()}}}}}
\item \href{\#length}{\texttt{ {\ttfamily queue\#{\bfseries{length()}}}}}
\item \href{\#getQueue}{\texttt{ {\ttfamily queue\#{\bfseries{get\+Queue()}}}}}
\item \href{\#kill}{\texttt{ {\ttfamily queue\#{\bfseries{kill()}}}}}
\item \href{\#killAndDrain}{\texttt{ {\ttfamily queue\#{\bfseries{kill\+And\+Drain()}}}}}
\item \href{\#concurrency}{\texttt{ {\ttfamily queue\#{\bfseries{concurrency}}}}}
\item \href{\#drain}{\texttt{ {\ttfamily queue\#{\bfseries{drain}}}}}
\item \href{\#empty}{\texttt{ {\ttfamily queue\#{\bfseries{empty}}}}}
\item \href{\#saturated}{\texttt{ {\ttfamily queue\#{\bfseries{saturated}}}}}
\end{DoxyItemize}

\DoxyHorRuler{0}
 \label{_fastqueue}%
 \hypertarget{md_sfcode_node_modules_fastq_README_autotoc_md10268}{}\doxysubsection{fastqueue(\mbox{[}that\mbox{]}, worker, concurrency)}\label{md_sfcode_node_modules_fastq_README_autotoc_md10268}
Creates a new queue.

Arguments\+:


\begin{DoxyItemize}
\item {\ttfamily that}, optional context of the {\ttfamily worker} function.
\item {\ttfamily worker}, worker function, it would be called with {\ttfamily that} as {\ttfamily this}, if that is specified.
\item {\ttfamily concurrency}, number of concurrent tasks that could be executed in parallel.
\end{DoxyItemize}

\DoxyHorRuler{0}
 \label{_push}%
 \hypertarget{md_sfcode_node_modules_fastq_README_autotoc_md10270}{}\doxysubsection{queue.\+push(task, done)}\label{md_sfcode_node_modules_fastq_README_autotoc_md10270}
Add a task at the end of the queue. {\ttfamily done(err, result)} will be called when the task was processed.

\DoxyHorRuler{0}
 \label{_unshift}%
 \hypertarget{md_sfcode_node_modules_fastq_README_autotoc_md10272}{}\doxysubsection{queue.\+unshift(task, done)}\label{md_sfcode_node_modules_fastq_README_autotoc_md10272}
Add a task at the beginning of the queue. {\ttfamily done(err, result)} will be called when the task was processed.

\DoxyHorRuler{0}
 \label{_pause}%
 \hypertarget{md_sfcode_node_modules_fastq_README_autotoc_md10274}{}\doxysubsection{queue.\+pause()}\label{md_sfcode_node_modules_fastq_README_autotoc_md10274}
Pause the processing of tasks. Currently worked tasks are not stopped.

\DoxyHorRuler{0}
 \label{_resume}%
 \hypertarget{md_sfcode_node_modules_fastq_README_autotoc_md10276}{}\doxysubsection{queue.\+resume()}\label{md_sfcode_node_modules_fastq_README_autotoc_md10276}
Resume the processing of tasks.

\DoxyHorRuler{0}
 \label{_idle}%
 \hypertarget{md_sfcode_node_modules_fastq_README_autotoc_md10278}{}\doxysubsection{queue.\+idle()}\label{md_sfcode_node_modules_fastq_README_autotoc_md10278}
Returns {\ttfamily false} if there are tasks being processed or waiting to be processed. {\ttfamily true} otherwise.

\DoxyHorRuler{0}
 \label{_length}%
 \hypertarget{md_sfcode_node_modules_fastq_README_autotoc_md10280}{}\doxysubsection{queue.\+length()}\label{md_sfcode_node_modules_fastq_README_autotoc_md10280}
Returns the number of tasks waiting to be processed (in the queue).

\DoxyHorRuler{0}
 \label{_getQueue}%
 \hypertarget{md_sfcode_node_modules_fastq_README_autotoc_md10282}{}\doxysubsection{queue.\+get\+Queue()}\label{md_sfcode_node_modules_fastq_README_autotoc_md10282}
Returns all the tasks be processed (in the queue). Returns empty array when there are no tasks

\DoxyHorRuler{0}
 \label{_kill}%
 \hypertarget{md_sfcode_node_modules_fastq_README_autotoc_md10284}{}\doxysubsection{queue.\+kill()}\label{md_sfcode_node_modules_fastq_README_autotoc_md10284}
Removes all tasks waiting to be processed, and reset {\ttfamily drain} to an empty function.

\DoxyHorRuler{0}
 \label{_killAndDrain}%
 \hypertarget{md_sfcode_node_modules_fastq_README_autotoc_md10286}{}\doxysubsection{queue.\+kill\+And\+Drain()}\label{md_sfcode_node_modules_fastq_README_autotoc_md10286}
Same than {\ttfamily kill} but the {\ttfamily drain} function will be called before reset to empty.

\DoxyHorRuler{0}
 \label{_concurrency}%
 \hypertarget{md_sfcode_node_modules_fastq_README_autotoc_md10288}{}\doxysubsection{queue.\+concurrency}\label{md_sfcode_node_modules_fastq_README_autotoc_md10288}
Property that returns the number of concurrent tasks that could be executed in parallel. It can be altered at runtime.

\DoxyHorRuler{0}
 \label{_drain}%
 \hypertarget{md_sfcode_node_modules_fastq_README_autotoc_md10290}{}\doxysubsection{queue.\+drain}\label{md_sfcode_node_modules_fastq_README_autotoc_md10290}
Function that will be called when the last item from the queue has been processed by a worker. It can be altered at runtime.

\DoxyHorRuler{0}
 \label{_empty}%
 \hypertarget{md_sfcode_node_modules_fastq_README_autotoc_md10292}{}\doxysubsection{queue.\+empty}\label{md_sfcode_node_modules_fastq_README_autotoc_md10292}
Function that will be called when the last item from the queue has been assigned to a worker. It can be altered at runtime.

\DoxyHorRuler{0}
 \label{_saturated}%
 \hypertarget{md_sfcode_node_modules_fastq_README_autotoc_md10294}{}\doxysubsection{queue.\+saturated}\label{md_sfcode_node_modules_fastq_README_autotoc_md10294}
Function that will be called when the queue hits the concurrency limit. It can be altered at runtime.\hypertarget{md_sfcode_node_modules_fastq_README_autotoc_md10295}{}\doxysection{License}\label{md_sfcode_node_modules_fastq_README_autotoc_md10295}
ISC 