A performant nth-\/check parser \& compiler.\hypertarget{md_sfcode_node_modules_nth_check_README_autotoc_md18745}{}\doxysubsection{About}\label{md_sfcode_node_modules_nth_check_README_autotoc_md18745}
This module can be used to parse \& compile nth-\/checks, as they are found in CSS 3\textquotesingle{}s {\ttfamily nth-\/child()} and {\ttfamily nth-\/last-\/of-\/type()}.

{\ttfamily nth-\/check} focusses on speed, providing optimized functions for different kinds of nth-\/child formulas, while still following the \href{http://www.w3.org/TR/css3-selectors/\#nth-child-pseudo}{\texttt{ spec}}.\hypertarget{md_sfcode_node_modules_nth_check_README_autotoc_md18746}{}\doxysubsection{API}\label{md_sfcode_node_modules_nth_check_README_autotoc_md18746}

\begin{DoxyCode}{0}
\DoxyCodeLine{var nthCheck = require("{}nth-\/check"{}); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_nth_check_README_autotoc_md18747}{}\doxyparagraph{$<$tt$>$nth\+Check(formula)$<$/tt$>$}\label{md_sfcode_node_modules_nth_check_README_autotoc_md18747}
First parses, then compiles the formula.\hypertarget{md_sfcode_node_modules_nth_check_README_autotoc_md18748}{}\doxyparagraph{$<$tt$>$nth\+Check.\+parse(formula)$<$/tt$>$}\label{md_sfcode_node_modules_nth_check_README_autotoc_md18748}
Parses the expression, throws a {\ttfamily Syntax\+Error} if it fails, otherwise returns an array containing two elements.

{\bfseries{Example\+:}}


\begin{DoxyCode}{0}
\DoxyCodeLine{nthCheck.parse("{}2n+3"{}) //[2, 3] }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_nth_check_README_autotoc_md18749}{}\doxyparagraph{$<$tt$>$nth\+Check.\+compile(\mbox{[}a, b\mbox{]})$<$/tt$>$}\label{md_sfcode_node_modules_nth_check_README_autotoc_md18749}
Takes an array with two elements (as returned by {\ttfamily .parse}) and returns a highly optimized function.

If the formula doesn\textquotesingle{}t match any elements, it returns \href{https://github.com/fb55/boolbase}{\texttt{ {\ttfamily boolbase}}}\textquotesingle{}s {\ttfamily false\+Func}, otherwise, a function accepting an {\itshape index} is returned, which returns whether or not a passed {\itshape index} matches the formula. (Note\+: The spec starts counting at {\ttfamily 1}, the returned function at {\ttfamily 0}).

{\bfseries{Example\+:}} 
\begin{DoxyCode}{0}
\DoxyCodeLine{var check = nthCheck.compile([2, 3]);}
\DoxyCodeLine{}
\DoxyCodeLine{check(0) //false}
\DoxyCodeLine{check(1) //false}
\DoxyCodeLine{check(2) //true}
\DoxyCodeLine{check(3) //false}
\DoxyCodeLine{check(4) //true}
\DoxyCodeLine{check(5) //false}
\DoxyCodeLine{check(6) //true }

\end{DoxyCode}


\DoxyHorRuler{0}
 License\+: BSD 