\href{https://npmjs.org/package/range-parser}{\texttt{ }} \href{https://npmjs.org/package/range-parser}{\texttt{ }} \href{https://nodejs.org/en/download}{\texttt{ }} \href{https://travis-ci.org/jshttp/range-parser}{\texttt{ }} \href{https://coveralls.io/r/jshttp/range-parser?branch=master}{\texttt{ }}

Range header field parser.\hypertarget{md_sfcode_node_modules_range_parser_README_autotoc_md23770}{}\doxysection{Installation}\label{md_sfcode_node_modules_range_parser_README_autotoc_md23770}
This is a \href{https://nodejs.org/en/}{\texttt{ Node.\+js}} module available through the \href{https://www.npmjs.com/}{\texttt{ npm registry}}. Installation is done using the \href{https://docs.npmjs.com/getting-started/installing-npm-packages-locally}{\texttt{ {\ttfamily npm install} command}}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\$ npm install range-\/parser }

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

\begin{DoxyCode}{0}
\DoxyCodeLine{var parseRange = require('range-\/parser') }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_range_parser_README_autotoc_md23772}{}\doxysubsection{parse\+Range(size, header, options)}\label{md_sfcode_node_modules_range_parser_README_autotoc_md23772}
Parse the given {\ttfamily header} string where {\ttfamily size} is the maximum size of the resource. An array of ranges will be returned or negative numbers indicating an error parsing.


\begin{DoxyItemize}
\item {\ttfamily -\/2} signals a malformed header string
\item {\ttfamily -\/1} signals an unsatisfiable range
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{// parse header from request}
\DoxyCodeLine{var range = parseRange(size, req.headers.range)}
\DoxyCodeLine{}
\DoxyCodeLine{// the type of the range}
\DoxyCodeLine{if (range.type === 'bytes') \{}
\DoxyCodeLine{  // the ranges}
\DoxyCodeLine{  range.forEach(function (r) \{}
\DoxyCodeLine{    // do something with r.start and r.end}
\DoxyCodeLine{  \})}
\DoxyCodeLine{\} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_range_parser_README_autotoc_md23773}{}\doxysubsubsection{Options}\label{md_sfcode_node_modules_range_parser_README_autotoc_md23773}
These properties are accepted in the options object.\hypertarget{md_sfcode_node_modules_range_parser_README_autotoc_md23774}{}\doxyparagraph{combine}\label{md_sfcode_node_modules_range_parser_README_autotoc_md23774}
Specifies if overlapping \& adjacent ranges should be combined, defaults to {\ttfamily false}. When {\ttfamily true}, ranges will be combined and returned as if they were specified that way in the header.


\begin{DoxyCode}{0}
\DoxyCodeLine{parseRange(100, 'bytes=50-\/55,0-\/10,5-\/10,56-\/60', \{ combine: true \})}
\DoxyCodeLine{// => [}
\DoxyCodeLine{//      \{ start: 0,  end: 10 \},}
\DoxyCodeLine{//      \{ start: 50, end: 60 \}}
\DoxyCodeLine{//    ] }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_range_parser_README_autotoc_md23775}{}\doxysection{License}\label{md_sfcode_node_modules_range_parser_README_autotoc_md23775}
\mbox{[}MIT\mbox{]}(LICENSE) 