\href{https://semaphoreci.com/medikoo-org/type}{\texttt{ }} \href{https://ci.appveyor.com/api/project/medikoo/type}{\texttt{ }} \href{https://codecov.io/gh/medikoo/type}{\texttt{ }} \href{https://www.npmjs.com/package/type}{\texttt{ }}\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31086}{}\doxysection{type}\label{md_sfcode_node_modules_type_README_autotoc_md31086}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31087}{}\doxysubsection{Runtime validation and processing of Java\+Script types}\label{md_sfcode_node_modules_type_README_autotoc_md31087}

\begin{DoxyItemize}
\item Respects language nature and acknowledges its quirks
\item Allows coercion in restricted forms (rejects clearly invalid input, normalizes permissible type deviations)
\item No transpilation implied, written to work in all ECMAScript 3+ engines
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31088}{}\doxysubsubsection{Example usage}\label{md_sfcode_node_modules_type_README_autotoc_md31088}
Bulletproof input arguments normalization and validation\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{const ensureString        = require('type/string/ensure')}
\DoxyCodeLine{    , ensureDate          = require('type/date/ensure')}
\DoxyCodeLine{    , ensureNaturalNumber = require('type/natural-\/number/ensure')}
\DoxyCodeLine{    , isObject            = require('type/object/is');}
\DoxyCodeLine{}
\DoxyCodeLine{module.exports = (path, options = \{ min: 0 \}) \{}
\DoxyCodeLine{  path = ensureString(path, \{ errorMessage: "{}\%v is not a path"{} \});}
\DoxyCodeLine{  if (!isObject(options)) options = \{\};}
\DoxyCodeLine{  const min = ensureNaturalNumber(options.min, \{ default: 0 \})}
\DoxyCodeLine{      , max = ensureNaturalNumber(options.max, \{ isOptional: true \})}
\DoxyCodeLine{      , startTime = ensureDate(options.startTime, \{ isOptional: true \});}
\DoxyCodeLine{}
\DoxyCodeLine{  // ...logic}
\DoxyCodeLine{\}; }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31089}{}\doxysubsubsection{Installation}\label{md_sfcode_node_modules_type_README_autotoc_md31089}

\begin{DoxyCode}{0}
\DoxyCodeLine{npm install type }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31090}{}\doxysubsection{Utilities}\label{md_sfcode_node_modules_type_README_autotoc_md31090}
Serves following kind of utilities\+:

\label{md_sfcode_node_modules_type_README_autotoc_md31091}%
\Hypertarget{md_sfcode_node_modules_type_README_autotoc_md31091}%
\doxysubparagraph*{{\ttfamily $\ast$/coerce}}

Restricted coercion into primitive type. Returns coerced value or {\ttfamily null} if value is not coercible per rules.

\label{md_sfcode_node_modules_type_README_autotoc_md31092}%
\Hypertarget{md_sfcode_node_modules_type_README_autotoc_md31092}%
\doxysubparagraph*{{\ttfamily $\ast$/is}}

Object type/kind confirmation, returns either {\ttfamily true} or {\ttfamily false}.

\label{md_sfcode_node_modules_type_README_autotoc_md31093}%
\Hypertarget{md_sfcode_node_modules_type_README_autotoc_md31093}%
\doxysubparagraph*{{\ttfamily $\ast$/ensure}}

Value validation. Returns input value (in primitive cases possibly coerced) or if value doesn\textquotesingle{}t meet the constraints throws {\ttfamily Type\+Error} .

Each {\ttfamily $\ast$/ensure} utility, accepts following options (eventually passed with second argument)\+:


\begin{DoxyItemize}
\item {\ttfamily is\+Optional} -\/ Makes {\ttfamily null} or {\ttfamily undefined} accepted as valid value. In such case instead of {\ttfamily Type\+Error} being thrown, {\ttfamily null} is returned.
\item {\ttfamily default} -\/ A value to be returned if {\ttfamily null} or {\ttfamily undefined} is passed as an input value.
\item {\ttfamily error\+Message} -\/ Custom error message ({\ttfamily v} can be used as a placeholder for input value)
\end{DoxyItemize}

\DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31095}{}\doxysubsubsection{Value}\label{md_sfcode_node_modules_type_README_autotoc_md31095}
{\itshape Value}, any value that\textquotesingle{}s neither {\ttfamily null} nor {\ttfamily undefined} .\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31096}{}\doxyparagraph{$<$tt$>$value/is$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31096}
Confirms whether passed argument is a {\itshape value}


\begin{DoxyCode}{0}
\DoxyCodeLine{const isValue = require("{}type/value/is"{});}
\DoxyCodeLine{}
\DoxyCodeLine{isValue(\{\}); // true}
\DoxyCodeLine{isValue(null); // false }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31097}{}\doxyparagraph{$<$tt$>$value/ensure$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31097}
Ensures if given argument is a {\itshape value}. If it\textquotesingle{}s a value it is returned back, if not {\ttfamily Type\+Error} is thrown


\begin{DoxyCode}{0}
\DoxyCodeLine{const ensureValue = require("{}type/value/ensure"{});}
\DoxyCodeLine{}
\DoxyCodeLine{const obj = \{\};}
\DoxyCodeLine{}
\DoxyCodeLine{ensureValue(obj); // obj}
\DoxyCodeLine{ensureValue(null); // Thrown TypeError: Cannot use null }

\end{DoxyCode}


\DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31099}{}\doxysubsubsection{Object}\label{md_sfcode_node_modules_type_README_autotoc_md31099}
{\itshape Object}, any non-\/primitive value\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31100}{}\doxyparagraph{$<$tt$>$object/is$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31100}
Confirms if passed value is an object


\begin{DoxyCode}{0}
\DoxyCodeLine{const isObject = require("{}type/object/is"{});}
\DoxyCodeLine{}
\DoxyCodeLine{isObject(\{\}); // true}
\DoxyCodeLine{isObject(true); // false}
\DoxyCodeLine{isObject(null); // false }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31101}{}\doxyparagraph{$<$tt$>$object/ensure$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31101}
If given argument is an object, it is returned back. Otherwise {\ttfamily Type\+Error} is thrown.


\begin{DoxyCode}{0}
\DoxyCodeLine{const ensureObject = require("{}type/object/ensure"{});}
\DoxyCodeLine{}
\DoxyCodeLine{const obj = \{\};}
\DoxyCodeLine{}
\DoxyCodeLine{ensureObject(obj); // obj}
\DoxyCodeLine{ensureString(null); // Thrown TypeError: null is not an object }

\end{DoxyCode}


\DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31103}{}\doxysubsubsection{String}\label{md_sfcode_node_modules_type_README_autotoc_md31103}
{\itshape string} primitive\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31104}{}\doxyparagraph{$<$tt$>$string/coerce$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31104}
Restricted string coercion. Returns string presentation for every value that follows below constraints


\begin{DoxyItemize}
\item is implicitly coercible to string
\item is neither{\ttfamily null} nor {\ttfamily undefined}
\item its {\ttfamily to\+String} method is not {\ttfamily Object.\+prototype.\+to\+String}
\end{DoxyItemize}

For all other values {\ttfamily null} is returned


\begin{DoxyCode}{0}
\DoxyCodeLine{const coerceToString = require("{}type/string/coerce"{});}
\DoxyCodeLine{}
\DoxyCodeLine{coerceToString(12); // "{}12"{}}
\DoxyCodeLine{coerceToString(undefined); // null }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31105}{}\doxyparagraph{$<$tt$>$string/ensure$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31105}
If given argument is a string coercible value (via \href{\#stringcoerce}{\texttt{ {\ttfamily string/coerce}}}) returns result string. Otherwise {\ttfamily Type\+Error} is thrown.


\begin{DoxyCode}{0}
\DoxyCodeLine{const ensureString = require("{}type/string/ensure"{});}
\DoxyCodeLine{}
\DoxyCodeLine{ensureString(12); // "{}12"{}}
\DoxyCodeLine{ensureString(null); // Thrown TypeError: null is not a string }

\end{DoxyCode}


\DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31107}{}\doxysubsubsection{Number}\label{md_sfcode_node_modules_type_README_autotoc_md31107}
{\itshape number} primitive\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31108}{}\doxyparagraph{$<$tt$>$number/coerce$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31108}
Restricted number coercion. Returns number presentation for every value that follows below constraints


\begin{DoxyItemize}
\item is implicitly coercible to number
\item is neither {\ttfamily null} nor {\ttfamily undefined}
\item is not {\ttfamily NaN} and doesn\textquotesingle{}t coerce to {\ttfamily NaN}
\end{DoxyItemize}

For all other values {\ttfamily null} is returned


\begin{DoxyCode}{0}
\DoxyCodeLine{const coerceToNumber = require("{}type/number/coerce"{});}
\DoxyCodeLine{}
\DoxyCodeLine{coerceToNumber("{}12"{}); // 12}
\DoxyCodeLine{coerceToNumber(\{\}); // null}
\DoxyCodeLine{coerceToNumber(null); // null }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31109}{}\doxyparagraph{$<$tt$>$number/ensure$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31109}
If given argument is a number coercible value (via \href{\#numbercoerce}{\texttt{ {\ttfamily number/coerce}}}) returns result number. Otherwise {\ttfamily Type\+Error} is thrown.


\begin{DoxyCode}{0}
\DoxyCodeLine{const ensureNumber = require("{}type/number/ensure"{});}
\DoxyCodeLine{}
\DoxyCodeLine{ensureNumber(12); // "{}12"{}}
\DoxyCodeLine{ensureNumber(null); // Thrown TypeError: null is not a number }

\end{DoxyCode}


\DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31111}{}\doxyparagraph{Finite Number}\label{md_sfcode_node_modules_type_README_autotoc_md31111}
Finite {\itshape number} primitive

\label{md_sfcode_node_modules_type_README_autotoc_md31112}%
\Hypertarget{md_sfcode_node_modules_type_README_autotoc_md31112}%
\doxysubparagraph*{{\ttfamily finite/coerce}}

Follows \href{\#numbercoerce}{\texttt{ {\ttfamily number/coerce}}} additionally rejecting {\ttfamily Infinity} and {\ttfamily -\/Infinity} values ({\ttfamily null} is returned if given values coerces to them)


\begin{DoxyCode}{0}
\DoxyCodeLine{const coerceToFinite = require("{}type/finite/coerce"{});}
\DoxyCodeLine{}
\DoxyCodeLine{coerceToFinite("{}12"{}); // 12}
\DoxyCodeLine{coerceToFinite(Infinity); // null}
\DoxyCodeLine{coerceToFinite(null); // null }

\end{DoxyCode}


\label{md_sfcode_node_modules_type_README_autotoc_md31113}%
\Hypertarget{md_sfcode_node_modules_type_README_autotoc_md31113}%
\doxysubparagraph*{{\ttfamily finite/ensure}}

If given argument is a finite number coercible value (via \href{\#finitecoerce}{\texttt{ {\ttfamily finite/coerce}}}) returns result number. Otherwise {\ttfamily Type\+Error} is thrown.


\begin{DoxyCode}{0}
\DoxyCodeLine{const ensureFinite = require("{}type/finite/ensure"{});}
\DoxyCodeLine{}
\DoxyCodeLine{ensureFinite(12); // "{}12"{}}
\DoxyCodeLine{ensureFinite(null); // Thrown TypeError: null is not a finite number }

\end{DoxyCode}


\DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31115}{}\doxyparagraph{Integer Number}\label{md_sfcode_node_modules_type_README_autotoc_md31115}
Integer {\itshape number} primitive

\label{md_sfcode_node_modules_type_README_autotoc_md31116}%
\Hypertarget{md_sfcode_node_modules_type_README_autotoc_md31116}%
\doxysubparagraph*{{\ttfamily integer/coerce}}

Follows \href{\#finitecoerce}{\texttt{ {\ttfamily finite/coerce}}} additionally stripping decimal part from the number


\begin{DoxyCode}{0}
\DoxyCodeLine{const coerceToInteger = require("{}type/integer/coerce"{});}
\DoxyCodeLine{}
\DoxyCodeLine{coerceToInteger("{}12.95"{}); // 12}
\DoxyCodeLine{coerceToInteger(Infinity); // null}
\DoxyCodeLine{coerceToInteger(null); // null }

\end{DoxyCode}


\label{md_sfcode_node_modules_type_README_autotoc_md31117}%
\Hypertarget{md_sfcode_node_modules_type_README_autotoc_md31117}%
\doxysubparagraph*{{\ttfamily integer/ensure}}

If given argument is an integer coercible value (via \href{\#integercoerce}{\texttt{ {\ttfamily integer/coerce}}}) returns result number. Otherwise {\ttfamily Type\+Error} is thrown.


\begin{DoxyCode}{0}
\DoxyCodeLine{const ensureInteger = require("{}type/integer/ensure"{});}
\DoxyCodeLine{}
\DoxyCodeLine{ensureInteger(12.93); // "{}12"{}}
\DoxyCodeLine{ensureInteger(null); // Thrown TypeError: null is not an integer }

\end{DoxyCode}


\DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31119}{}\doxyparagraph{Safe Integer Number}\label{md_sfcode_node_modules_type_README_autotoc_md31119}
Safe integer {\itshape number} primitive

\label{md_sfcode_node_modules_type_README_autotoc_md31120}%
\Hypertarget{md_sfcode_node_modules_type_README_autotoc_md31120}%
\doxysubparagraph*{{\ttfamily safe-\/integer/coerce}}

Follows \href{\#integercoerce}{\texttt{ {\ttfamily integer/coerce}}} but returns {\ttfamily null} in place of values which are beyond {\ttfamily Number.\+MIN\+\_\+\+SAFE\+\_\+\+INTEGER} and {\ttfamily Number.\+MAX\+\_\+\+SAFE\+\_\+\+INTEGER} range.


\begin{DoxyCode}{0}
\DoxyCodeLine{const coerceToSafeInteger = require("{}type/safe-\/integer/coerce"{});}
\DoxyCodeLine{}
\DoxyCodeLine{coerceToInteger("{}12.95"{}); // 12}
\DoxyCodeLine{coerceToInteger(9007199254740992); // null}
\DoxyCodeLine{coerceToInteger(null); // null }

\end{DoxyCode}


\label{md_sfcode_node_modules_type_README_autotoc_md31121}%
\Hypertarget{md_sfcode_node_modules_type_README_autotoc_md31121}%
\doxysubparagraph*{{\ttfamily safe-\/integer/ensure}}

If given argument is a safe integer coercible value (via \href{\#safe-integercoerce}{\texttt{ {\ttfamily safe-\/integer/coerce}}}) returns result number. Otherwise {\ttfamily Type\+Error} is thrown.


\begin{DoxyCode}{0}
\DoxyCodeLine{const ensureSafeInteger = require("{}type/safe-\/integer/ensure"{});}
\DoxyCodeLine{}
\DoxyCodeLine{ensureSafeInteger(12.93); // "{}12"{}}
\DoxyCodeLine{ensureSafeInteger(9007199254740992); // Thrown TypeError: null is not a safe integer }

\end{DoxyCode}


\DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31123}{}\doxyparagraph{Natural Number}\label{md_sfcode_node_modules_type_README_autotoc_md31123}
Natural {\itshape number} primitive

\label{md_sfcode_node_modules_type_README_autotoc_md31124}%
\Hypertarget{md_sfcode_node_modules_type_README_autotoc_md31124}%
\doxysubparagraph*{{\ttfamily natural-\/number/coerce}}

Follows \href{\#integercoerce}{\texttt{ {\ttfamily integer/coerce}}} but returns {\ttfamily null} for values below {\ttfamily 0}


\begin{DoxyCode}{0}
\DoxyCodeLine{const coerceToNaturalNumber = require("{}type/natural-\/number/coerce"{});}
\DoxyCodeLine{}
\DoxyCodeLine{coerceToNaturalNumber("{}12.95"{}); // 12}
\DoxyCodeLine{coerceToNaturalNumber(-\/120); // null}
\DoxyCodeLine{coerceToNaturalNumber(null); // null }

\end{DoxyCode}


\label{md_sfcode_node_modules_type_README_autotoc_md31125}%
\Hypertarget{md_sfcode_node_modules_type_README_autotoc_md31125}%
\doxysubparagraph*{{\ttfamily natural-\/number/ensure}}

If given argument is a natural number coercible value (via \href{\#natural-numbercoerce}{\texttt{ {\ttfamily natural-\/number/coerce}}}) returns result number. Otherwise {\ttfamily Type\+Error} is thrown.


\begin{DoxyCode}{0}
\DoxyCodeLine{const ensureNaturalNumber = require("{}type/natural-\/number/ensure"{});}
\DoxyCodeLine{}
\DoxyCodeLine{ensureNaturalNumber(12.93); // "{}12"{}}
\DoxyCodeLine{ensureNaturalNumber(-\/230); // Thrown TypeError: null is not a natural number }

\end{DoxyCode}


\DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31127}{}\doxysubsubsection{Plain Object}\label{md_sfcode_node_modules_type_README_autotoc_md31127}
A {\itshape plain object}


\begin{DoxyItemize}
\item Inherits directly from {\ttfamily Object.\+prototype} or {\ttfamily null}
\item Is not a constructor\textquotesingle{}s {\ttfamily prototype} property
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31128}{}\doxyparagraph{$<$tt$>$plain-\/object/is$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31128}
Confirms if given object is a {\itshape plain object}


\begin{DoxyCode}{0}
\DoxyCodeLine{const isPlainObject = require("{}type/plain-\/object/is"{});}
\DoxyCodeLine{}
\DoxyCodeLine{isPlainObject(\{\}); // true}
\DoxyCodeLine{isPlainObject(Object.create(null)); // true}
\DoxyCodeLine{isPlainObject([]); // false }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31129}{}\doxyparagraph{$<$tt$>$plain-\/object/ensure$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31129}
If given argument is a plain object it is returned back. Otherwise {\ttfamily Type\+Error} is thrown.


\begin{DoxyCode}{0}
\DoxyCodeLine{const ensurePlainObject = require("{}type/plain-\/object/ensure"{});}
\DoxyCodeLine{}
\DoxyCodeLine{ensurePlainObject(\{\}); // \{\}}
\DoxyCodeLine{ensureArray("{}foo"{}); // Thrown TypeError: foo is not a plain object }

\end{DoxyCode}


\DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31131}{}\doxysubsubsection{Array}\label{md_sfcode_node_modules_type_README_autotoc_md31131}
{\itshape Array} instance\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31132}{}\doxyparagraph{$<$tt$>$array/is$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31132}
Confirms if given object is a native array


\begin{DoxyCode}{0}
\DoxyCodeLine{const isArray = require("{}type/array/is"{});}
\DoxyCodeLine{}
\DoxyCodeLine{isArray([]); // true}
\DoxyCodeLine{isArray(\{\}); // false}
\DoxyCodeLine{isArray("{}foo"{}); // false }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31133}{}\doxyparagraph{$<$tt$>$array/ensure$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31133}
If given argument is an array, it is returned back. Otherwise {\ttfamily Type\+Error} is thrown.


\begin{DoxyCode}{0}
\DoxyCodeLine{const ensureArray = require("{}type/array/ensure"{});}
\DoxyCodeLine{}
\DoxyCodeLine{ensureArray(["{}foo"{}]); // ["{}foo"{}]}
\DoxyCodeLine{ensureArray("{}foo"{}); // Thrown TypeError: foo is not an array }

\end{DoxyCode}


\DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31135}{}\doxyparagraph{Array Like}\label{md_sfcode_node_modules_type_README_autotoc_md31135}
{\itshape Array-\/like} value (any value with {\ttfamily length} property)\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31136}{}\doxyparagraph{$<$tt$>$array-\/like/is$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31136}
Restricted {\itshape array-\/like} confirmation. Returns true for every value that meets following contraints


\begin{DoxyItemize}
\item is an {\itshape object} (or with {\ttfamily allow\+String} option, a {\itshape string})
\item is not a {\itshape function}
\item Exposes {\ttfamily length} that meets \href{\#array-lengthcoerce}{\texttt{ {\ttfamily array-\/length}}} constraints
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{const isArrayLike = require("{}type/array-\/like/is"{});}
\DoxyCodeLine{}
\DoxyCodeLine{isArrayLike([]); // true}
\DoxyCodeLine{isArrayLike(\{\}); // false}
\DoxyCodeLine{isArrayLike(\{ length: 0 \}); // true}
\DoxyCodeLine{isArrayLike("{}foo"{}); // false}
\DoxyCodeLine{isArrayLike("{}foo"{}, \{ allowString: true \}); // true }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31137}{}\doxyparagraph{$<$tt$>$array-\/like/ensure$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31137}
If given argument is an {\itshape array-\/like}, it is returned back. Otherwise {\ttfamily Type\+Error} is thrown.


\begin{DoxyCode}{0}
\DoxyCodeLine{const ensureArrayLike = require("{}type/array-\/like/ensure"{});}
\DoxyCodeLine{}
\DoxyCodeLine{ensureArrayLike(\{ length: 0 \}); // \{ length: 0 \}}
\DoxyCodeLine{ensureArrayLike("{}foo"{}, \{ allowString: true \}); // "{}foo"{}}
\DoxyCodeLine{ensureArrayLike(\{\}); // Thrown TypeError: null is not an iterable }

\end{DoxyCode}


\DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31139}{}\doxyparagraph{Array length}\label{md_sfcode_node_modules_type_README_autotoc_md31139}
{\itshape number} primitive that conforms as valid {\itshape array length}

\label{md_sfcode_node_modules_type_README_autotoc_md31140}%
\Hypertarget{md_sfcode_node_modules_type_README_autotoc_md31140}%
\doxysubparagraph*{{\ttfamily array-\/length/coerce}}

Follows \href{\#safe-integercoerce}{\texttt{ {\ttfamily safe-\/integer/coerce}}} but returns {\ttfamily null} in place of values which are below {\ttfamily 0}


\begin{DoxyCode}{0}
\DoxyCodeLine{const coerceToArrayLength = require("{}type/safe-\/integer/coerce"{});}
\DoxyCodeLine{}
\DoxyCodeLine{coerceToArrayLength("{}12.95"{}); // 12}
\DoxyCodeLine{coerceToArrayLength(9007199254740992); // null}
\DoxyCodeLine{coerceToArrayLength(null); // null }

\end{DoxyCode}


\label{md_sfcode_node_modules_type_README_autotoc_md31141}%
\Hypertarget{md_sfcode_node_modules_type_README_autotoc_md31141}%
\doxysubparagraph*{{\ttfamily array-\/length/ensure}}

If given argument is an {\itshape array length} coercible value (via \href{\#array-lengthcoerce}{\texttt{ {\ttfamily array-\/length/coerce}}}) returns result number. Otherwise {\ttfamily Type\+Error} is thrown.


\begin{DoxyCode}{0}
\DoxyCodeLine{const ensureArrayLength = require("{}type/array-\/length/ensure"{});}
\DoxyCodeLine{}
\DoxyCodeLine{ensureArrayLength(12.93); // "{}12"{}}
\DoxyCodeLine{ensureArrayLength(9007199254740992); // Thrown TypeError: null is not a valid array length }

\end{DoxyCode}


\DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31143}{}\doxysubsubsection{Iterable}\label{md_sfcode_node_modules_type_README_autotoc_md31143}
Value which implements {\itshape iterable} protocol\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31144}{}\doxyparagraph{$<$tt$>$iterable/is$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31144}
Confirms if given object is an {\itshape iterable} and is not a {\itshape string} (unless {\ttfamily allow\+String} option is passed)


\begin{DoxyCode}{0}
\DoxyCodeLine{const isIterable = require("{}type/iterable/is"{});}
\DoxyCodeLine{}
\DoxyCodeLine{isIterable([]); // true}
\DoxyCodeLine{isIterable(\{\}); // false}
\DoxyCodeLine{isIterable("{}foo"{}); // false}
\DoxyCodeLine{isIterable("{}foo"{}, \{ allowString: true \}); // true }

\end{DoxyCode}


Supports also {\ttfamily deny\+Empty} option


\begin{DoxyCode}{0}
\DoxyCodeLine{isIterable([], \{ denyEmpty: true \}); // false}
\DoxyCodeLine{isIterable(["{}foo"{}], \{ denyEmpty: true \}); // true }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31145}{}\doxyparagraph{$<$tt$>$iterable/ensure$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31145}
If given argument is an {\itshape iterable}, it is returned back. Otherwise {\ttfamily Type\+Error} is thrown.


\begin{DoxyCode}{0}
\DoxyCodeLine{const ensureIterable = require("{}type/iterable/ensure"{});}
\DoxyCodeLine{}
\DoxyCodeLine{ensureIterable([]); // []}
\DoxyCodeLine{ensureIterable("{}foo"{}, \{ allowString: true \}); // "{}foo"{}}
\DoxyCodeLine{ensureIterable(\{\}); // Thrown TypeError: null is not expected iterable }

\end{DoxyCode}


Additionally items can be coreced with {\ttfamily coerce\+Item} option. Note that in this case\+:


\begin{DoxyItemize}
\item A newly created array with coerced values is returned
\item Validation crashes if any of the items is not coercible
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{ensureIterable(new Set(["{}foo"{}, 12])); // ["{}foo"{}, "{}12"{}]}
\DoxyCodeLine{}
\DoxyCodeLine{ensureIterable(new Set(["{}foo"{}, \{\}])); // Thrown TypeError: Set(\{ "{}foo"{}, \{\} \}) is not expected iterable }

\end{DoxyCode}


\DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31147}{}\doxysubsubsection{Date}\label{md_sfcode_node_modules_type_README_autotoc_md31147}
{\itshape Date} instance\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31148}{}\doxyparagraph{$<$tt$>$date/is$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31148}
Confirms if given object is a native date, and is not an {\itshape Invalid Date}


\begin{DoxyCode}{0}
\DoxyCodeLine{const isDate = require("{}type/date/is"{});}
\DoxyCodeLine{}
\DoxyCodeLine{isDate(new Date()); // true}
\DoxyCodeLine{isDate(new Date("{}Invalid date"{})); // false}
\DoxyCodeLine{isDate(Date.now()); // false}
\DoxyCodeLine{isDate("{}foo"{}); // false }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31149}{}\doxyparagraph{$<$tt$>$date/ensure$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31149}
If given argument is a date object, it is returned back. Otherwise {\ttfamily Type\+Error} is thrown.


\begin{DoxyCode}{0}
\DoxyCodeLine{const ensureDate = require("{}type/date/ensure"{});}
\DoxyCodeLine{}
\DoxyCodeLine{const date = new Date();}
\DoxyCodeLine{ensureDate(date); // date}
\DoxyCodeLine{ensureDate(123123); // Thrown TypeError: 123123 is not a date object }

\end{DoxyCode}


\DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31151}{}\doxysubsubsection{Time value}\label{md_sfcode_node_modules_type_README_autotoc_md31151}
{\itshape number} primitive which is a valid {\itshape time value} (as used internally in {\itshape Date} instances)\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31152}{}\doxyparagraph{$<$tt$>$time-\/value/coerce$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31152}
Follows \href{\#integercoerce}{\texttt{ {\ttfamily integer/coerce}}} but returns {\ttfamily null} in place of values which go beyond 100 000 0000 days from unix epoch


\begin{DoxyCode}{0}
\DoxyCodeLine{const coerceToTimeValue = require("{}type/time-\/value/coerce"{});}
\DoxyCodeLine{}
\DoxyCodeLine{coerceToTimeValue(12312312); // true}
\DoxyCodeLine{coerceToTimeValue(Number.MAX\_SAFE\_INTEGER); // false}
\DoxyCodeLine{coerceToTimeValue("{}foo"{}); // false }

\end{DoxyCode}


\label{md_sfcode_node_modules_type_README_autotoc_md31153}%
\Hypertarget{md_sfcode_node_modules_type_README_autotoc_md31153}%
\doxysubparagraph*{{\ttfamily time-\/value/ensure}}

If given argument is a {\itshape time value} coercible value (via \href{\#time-valuecoerce}{\texttt{ {\ttfamily time-\/value/coerce}}}) returns result number. Otherwise {\ttfamily Type\+Error} is thrown.


\begin{DoxyCode}{0}
\DoxyCodeLine{const ensureTimeValue = require("{}type/time-\/value/ensure"{});}
\DoxyCodeLine{}
\DoxyCodeLine{ensureTimeValue(12.93); // "{}12"{}}
\DoxyCodeLine{ensureTimeValue(Number.MAX\_SAFE\_INTEGER); // Thrown TypeError: null is not a natural number }

\end{DoxyCode}


\DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31155}{}\doxysubsubsection{Function}\label{md_sfcode_node_modules_type_README_autotoc_md31155}
{\itshape Function} instance\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31156}{}\doxyparagraph{$<$tt$>$function/is$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31156}
Confirms if given object is a native function


\begin{DoxyCode}{0}
\DoxyCodeLine{const isFunction = require("{}type/function/is"{});}
\DoxyCodeLine{}
\DoxyCodeLine{isFunction(function () \{\}); // true}
\DoxyCodeLine{isFunction(() => \{\}); // true}
\DoxyCodeLine{isFunction(class \{\}); // true}
\DoxyCodeLine{isFunction("{}foo"{}); // false }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31157}{}\doxyparagraph{$<$tt$>$function/ensure$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31157}
If given argument is a function object, it is returned back. Otherwise {\ttfamily Type\+Error} is thrown.


\begin{DoxyCode}{0}
\DoxyCodeLine{const ensureFunction = require("{}type/function/ensure"{});}
\DoxyCodeLine{}
\DoxyCodeLine{const fn = function () \{\};}
\DoxyCodeLine{ensureFunction(fn); // fn}
\DoxyCodeLine{ensureFunction(/foo/); // Thrown TypeError: /foo/ is not a function }

\end{DoxyCode}


\DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31159}{}\doxyparagraph{Plain Function}\label{md_sfcode_node_modules_type_README_autotoc_md31159}
A {\itshape Function} instance that is not a {\itshape Class}

\label{md_sfcode_node_modules_type_README_autotoc_md31160}%
\Hypertarget{md_sfcode_node_modules_type_README_autotoc_md31160}%
\doxysubparagraph*{{\ttfamily plain-\/function/is}}

Confirms if given object is a {\itshape plain function}


\begin{DoxyCode}{0}
\DoxyCodeLine{const isPlainFunction = require("{}type/plain-\/function/is"{});}
\DoxyCodeLine{}
\DoxyCodeLine{isPlainFunction(function () \{\}); // true}
\DoxyCodeLine{isPlainFunction(() => \{\}); // true}
\DoxyCodeLine{isPlainFunction(class \{\}); // false}
\DoxyCodeLine{isPlainFunction("{}foo"{}); // false }

\end{DoxyCode}


\label{md_sfcode_node_modules_type_README_autotoc_md31161}%
\Hypertarget{md_sfcode_node_modules_type_README_autotoc_md31161}%
\doxysubparagraph*{{\ttfamily plain-\/function/ensure}}

If given argument is a {\itshape plain function} object, it is returned back. Otherwise {\ttfamily Type\+Error} is thrown.


\begin{DoxyCode}{0}
\DoxyCodeLine{const ensurePlainFunction = require("{}type/function/ensure"{});}
\DoxyCodeLine{}
\DoxyCodeLine{const fn = function () \{\};}
\DoxyCodeLine{ensurePlainFunction(fn); // fn}
\DoxyCodeLine{ensurePlainFunction(class \{\}); // Thrown TypeError: class is not a plain function }

\end{DoxyCode}


\DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31163}{}\doxysubsubsection{Reg\+Exp}\label{md_sfcode_node_modules_type_README_autotoc_md31163}
{\itshape Reg\+Exp} instance\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31164}{}\doxyparagraph{$<$tt$>$reg-\/exp/is$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31164}
Confirms if given object is a native regular expression object


\begin{DoxyCode}{0}
\DoxyCodeLine{const isRegExp = require("{}type/reg-\/exp/is"{});}
\DoxyCodeLine{}
\DoxyCodeLine{isRegExp(/foo/);}
\DoxyCodeLine{isRegExp(\{\}); // false}
\DoxyCodeLine{isRegExp("{}foo"{}); // false }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31165}{}\doxyparagraph{$<$tt$>$reg-\/exp/ensure$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31165}
If given argument is a regular expression object, it is returned back. Otherwise {\ttfamily Type\+Error} is thrown.


\begin{DoxyCode}{0}
\DoxyCodeLine{const ensureRegExp = require("{}type/reg-\/exp/ensure"{});}
\DoxyCodeLine{}
\DoxyCodeLine{ensureRegExp(/foo/); // /foo/}
\DoxyCodeLine{ensureRegExp("{}foo"{}); // Thrown TypeError: null is not a regular expression object }

\end{DoxyCode}


\DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31167}{}\doxysubsubsection{Promise}\label{md_sfcode_node_modules_type_README_autotoc_md31167}
{\itshape Promise} instance\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31168}{}\doxyparagraph{$<$tt$>$promise/is$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31168}
Confirms if given object is a native {\itshape promise}


\begin{DoxyCode}{0}
\DoxyCodeLine{const isPromise = require("{}type/promise/is"{});}
\DoxyCodeLine{}
\DoxyCodeLine{isPromise(Promise.resolve()); // true}
\DoxyCodeLine{isPromise(\{ then: () => \{\} \}); // false}
\DoxyCodeLine{isPromise(\{\}); // false }

\end{DoxyCode}


\label{md_sfcode_node_modules_type_README_autotoc_md31169}%
\Hypertarget{md_sfcode_node_modules_type_README_autotoc_md31169}%
\doxysubparagraph*{{\ttfamily promise/ensure}}

If given argument is a promise, it is returned back. Otherwise {\ttfamily Type\+Error} is thrown.


\begin{DoxyCode}{0}
\DoxyCodeLine{const ensurePromise = require("{}type/promise/ensure"{});}
\DoxyCodeLine{}
\DoxyCodeLine{const promise = Promise.resolve();}
\DoxyCodeLine{ensurePromise(promise); // promise}
\DoxyCodeLine{eensurePromise(\{\}); // Thrown TypeError: [object Object] is not a promise }

\end{DoxyCode}


\DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31171}{}\doxyparagraph{Thenable}\label{md_sfcode_node_modules_type_README_autotoc_md31171}
{\itshape Thenable} object (an object with {\ttfamily then} method)

\label{md_sfcode_node_modules_type_README_autotoc_md31172}%
\Hypertarget{md_sfcode_node_modules_type_README_autotoc_md31172}%
\doxysubparagraph*{{\ttfamily thenable/is}}

Confirms if given object is a {\itshape thenable}


\begin{DoxyCode}{0}
\DoxyCodeLine{const isThenable = require("{}type/thenable/is"{});}
\DoxyCodeLine{}
\DoxyCodeLine{isThenable(Promise.resolve()); // true}
\DoxyCodeLine{isThenable(\{ then: () => \{\} \}); // true}
\DoxyCodeLine{isThenable(\{\}); // false }

\end{DoxyCode}


\label{md_sfcode_node_modules_type_README_autotoc_md31173}%
\Hypertarget{md_sfcode_node_modules_type_README_autotoc_md31173}%
\doxysubparagraph*{{\ttfamily thenable/ensure}}

If given argument is a {\itshape thenable} object, it is returned back. Otherwise {\ttfamily Type\+Error} is thrown.


\begin{DoxyCode}{0}
\DoxyCodeLine{const ensureThenable = require("{}type/thenable/ensure"{});}
\DoxyCodeLine{}
\DoxyCodeLine{const promise = Promise.resolve();}
\DoxyCodeLine{ensureThenable(promise); // promise}
\DoxyCodeLine{ensureThenable(\{\}); // Thrown TypeError: [object Object] is not a thenable object }

\end{DoxyCode}


\DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31175}{}\doxysubsubsection{Error}\label{md_sfcode_node_modules_type_README_autotoc_md31175}
{\itshape Error} instance\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31176}{}\doxyparagraph{$<$tt$>$error/is$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31176}
Confirms if given object is a native error object


\begin{DoxyCode}{0}
\DoxyCodeLine{const isError = require("{}type/error/is"{});}
\DoxyCodeLine{}
\DoxyCodeLine{isError(new Error()); // true}
\DoxyCodeLine{isError(\{ message: "{}Fake error"{} \}); // false }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31177}{}\doxyparagraph{$<$tt$>$error/ensure$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31177}
If given argument is an error object, it is returned back. Otherwise {\ttfamily Type\+Error} is thrown.


\begin{DoxyCode}{0}
\DoxyCodeLine{const ensureError = require("{}type/error/ensure"{});}
\DoxyCodeLine{}
\DoxyCodeLine{const someError = new Error("{}Some error"{});}
\DoxyCodeLine{ensureError(someError); // someError}
\DoxyCodeLine{ensureError(\{ message: "{}Fake error"{} \}); // Thrown TypeError: [object Object] is not an error object }

\end{DoxyCode}


\DoxyHorRuler{0}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31179}{}\doxysubsubsection{Prototype}\label{md_sfcode_node_modules_type_README_autotoc_md31179}
Some constructor\textquotesingle{}s {\ttfamily prototype} property\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31180}{}\doxyparagraph{$<$tt$>$prototype/is$<$/tt$>$}\label{md_sfcode_node_modules_type_README_autotoc_md31180}
Confirms if given object serves as a {\itshape prototype} property


\begin{DoxyCode}{0}
\DoxyCodeLine{const isPrototype = require("{}type/prototype/is"{});}
\DoxyCodeLine{}
\DoxyCodeLine{isPrototype(\{\}); // false}
\DoxyCodeLine{isPrototype(Object.prototype); // true}
\DoxyCodeLine{isPrototype(Array.prototype); // true }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_type_README_autotoc_md31181}{}\doxysubsubsection{Tests}\label{md_sfcode_node_modules_type_README_autotoc_md31181}
\begin{DoxyVerb}$ npm test
\end{DoxyVerb}
 