This library is a super small wrapper over node\textquotesingle{}s assert module that has two things\+: (1) the ability to disable assertions with the environment variable NODE\+\_\+\+NDEBUG, and (2) some API wrappers for argument testing. Like `assert.\+string(my\+Arg, \textquotesingle{}my\+Arg')\`{}. As a simple example, most of my code looks like this\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{var assert = require('assert-\/plus');}
\DoxyCodeLine{}
\DoxyCodeLine{function fooAccount(options, callback) \{}
\DoxyCodeLine{    assert.object(options, 'options');}
\DoxyCodeLine{    assert.number(options.id, 'options.id');}
\DoxyCodeLine{    assert.bool(options.isManager, 'options.isManager');}
\DoxyCodeLine{    assert.string(options.name, 'options.name');}
\DoxyCodeLine{    assert.arrayOfString(options.email, 'options.email');}
\DoxyCodeLine{    assert.func(callback, 'callback');}
\DoxyCodeLine{}
\DoxyCodeLine{    // Do stuff}
\DoxyCodeLine{    callback(null, \{\});}
\DoxyCodeLine{\} }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_assert_plus_README_autotoc_md3280}{}\doxysection{API}\label{md_sfcode_node_modules_assert_plus_README_autotoc_md3280}
All methods that {\itshape aren\textquotesingle{}t} part of node\textquotesingle{}s core assert API are simply assumed to take an argument, and then a string \textquotesingle{}name\textquotesingle{} that\textquotesingle{}s not a message; {\ttfamily Assertion\+Error} will be thrown if the assertion fails with a message like\+: \begin{DoxyVerb}AssertionError: foo (string) is required
at test (/home/mark/work/foo/foo.js:3:9)
at Object.<anonymous> (/home/mark/work/foo/foo.js:15:1)
at Module._compile (module.js:446:26)
at Object..js (module.js:464:10)
at Module.load (module.js:353:31)
at Function._load (module.js:311:12)
at Array.0 (module.js:484:10)
at EventEmitter._tickCallback (node.js:190:38)
\end{DoxyVerb}
 from\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{function test(foo) \{}
\DoxyCodeLine{    assert.string(foo, 'foo');}
\DoxyCodeLine{\} }

\end{DoxyCode}


There you go. You can check that arrays are of a homogeneous type with {\ttfamily Arrayof\$\+Type}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{function test(foo) \{}
\DoxyCodeLine{    assert.arrayOfString(foo, 'foo');}
\DoxyCodeLine{\} }

\end{DoxyCode}


You can assert IFF an argument is not {\ttfamily undefined} (i.\+e., an optional arg)\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{assert.optionalString(foo, 'foo'); }

\end{DoxyCode}


Lastly, you can opt-\/out of assertion checking altogether by setting the environment variable {\ttfamily NODE\+\_\+\+NDEBUG=1}. This is pseudo-\/useful if you have lots of assertions, and don\textquotesingle{}t want to pay {\ttfamily typeof ()} taxes to v8 in production. Be advised\+: The standard functions re-\/exported from {\ttfamily assert} are also disabled in assert-\/plus if NDEBUG is specified. Using them directly from the {\ttfamily assert} module avoids this behavior.

The complete list of APIs is\+:


\begin{DoxyItemize}
\item assert.\+array
\item assert.\+bool
\item assert.\+buffer
\item assert.\+func
\item assert.\+number
\item assert.\+finite
\item assert.\+object
\item assert.\+string
\item assert.\+stream
\item assert.\+date
\item assert.\+regexp
\item assert.\+uuid
\item assert.\+array\+Of\+Array
\item assert.\+array\+Of\+Bool
\item assert.\+array\+Of\+Buffer
\item assert.\+array\+Of\+Func
\item assert.\+array\+Of\+Number
\item assert.\+array\+Of\+Finite
\item assert.\+array\+Of\+Object
\item assert.\+array\+Of\+String
\item assert.\+array\+Of\+Stream
\item assert.\+array\+Of\+Date
\item assert.\+array\+Of\+Regexp
\item assert.\+array\+Of\+Uuid
\item assert.\+optional\+Array
\item assert.\+optional\+Bool
\item assert.\+optional\+Buffer
\item assert.\+optional\+Func
\item assert.\+optional\+Number
\item assert.\+optional\+Finite
\item assert.\+optional\+Object
\item assert.\+optional\+String
\item assert.\+optional\+Stream
\item assert.\+optional\+Date
\item assert.\+optional\+Regexp
\item assert.\+optional\+Uuid
\item assert.\+optional\+Array\+Of\+Array
\item assert.\+optional\+Array\+Of\+Bool
\item assert.\+optional\+Array\+Of\+Buffer
\item assert.\+optional\+Array\+Of\+Func
\item assert.\+optional\+Array\+Of\+Number
\item assert.\+optional\+Array\+Of\+Finite
\item assert.\+optional\+Array\+Of\+Object
\item assert.\+optional\+Array\+Of\+String
\item assert.\+optional\+Array\+Of\+Stream
\item assert.\+optional\+Array\+Of\+Date
\item assert.\+optional\+Array\+Of\+Regexp
\item assert.\+optional\+Array\+Of\+Uuid
\item assert.\+Assertion\+Error
\item assert.\+fail
\item assert.\+ok
\item assert.\+equal
\item assert.\+not\+Equal
\item assert.\+deep\+Equal
\item assert.\+not\+Deep\+Equal
\item assert.\+strict\+Equal
\item assert.\+not\+Strict\+Equal
\item assert.\+throws
\item assert.\+does\+Not\+Throw
\item assert.\+if\+Error
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_assert_plus_README_autotoc_md3281}{}\doxysection{Installation}\label{md_sfcode_node_modules_assert_plus_README_autotoc_md3281}
\begin{DoxyVerb}npm install assert-plus
\end{DoxyVerb}
 \hypertarget{md_sfcode_node_modules_assert_plus_README_autotoc_md3282}{}\doxysubsection{License}\label{md_sfcode_node_modules_assert_plus_README_autotoc_md3282}
The MIT License (MIT) Copyright (c) 2012 Mark Cavage

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \char`\"{}\+Software\char`\"{}), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions\+:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED \char`\"{}\+AS IS\char`\"{}, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\hypertarget{md_sfcode_node_modules_assert_plus_README_autotoc_md3283}{}\doxysubsection{Bugs}\label{md_sfcode_node_modules_assert_plus_README_autotoc_md3283}
See \href{https://github.com/mcavage/node-assert-plus/issues}{\texttt{ https\+://github.\+com/mcavage/node-\/assert-\/plus/issues}}. 