\href{https://travis-ci.org/ljharb/es-to-primitive}{\texttt{ }} \href{https://david-dm.org/ljharb/es-to-primitive}{\texttt{ }} \href{https://david-dm.org/ljharb/es-to-primitive\#info=devDependencies}{\texttt{ }} \mbox{[}\mbox{]}\mbox{[}license-\/url\mbox{]} \href{http://npm-stat.com/charts.html?package=es-to-primitive}{\texttt{ }}

\href{https://npmjs.org/package/es-to-primitive}{\texttt{ }}

ECMAScript “\+To\+Primitive” algorithm. Provides ES5 and ES2015 versions. When different versions of the spec conflict, the default export will be the latest version of the abstract operation. Alternative versions will also be available under an {\ttfamily es5}/{\ttfamily es2015} exported property if you require a specific version.\hypertarget{md_sfcode_node_modules_es_to_primitive_README_autotoc_md8825}{}\doxysection{Example}\label{md_sfcode_node_modules_es_to_primitive_README_autotoc_md8825}

\begin{DoxyCode}{0}
\DoxyCodeLine{var toPrimitive = require('es-\/to-\/primitive');}
\DoxyCodeLine{var assert = require('assert');}
\DoxyCodeLine{}
\DoxyCodeLine{assert(toPrimitive(function () \{\}) === String(function () \{\}));}
\DoxyCodeLine{}
\DoxyCodeLine{var date = new Date();}
\DoxyCodeLine{assert(toPrimitive(date) === String(date));}
\DoxyCodeLine{}
\DoxyCodeLine{assert(toPrimitive(\{ valueOf: function () \{ return 3; \} \}) === 3);}
\DoxyCodeLine{}
\DoxyCodeLine{assert(toPrimitive(['a', 'b', 3]) === String(['a', 'b', 3]));}
\DoxyCodeLine{}
\DoxyCodeLine{var sym = Symbol();}
\DoxyCodeLine{assert(toPrimitive(Object(sym)) === sym); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_es_to_primitive_README_autotoc_md8826}{}\doxysection{Tests}\label{md_sfcode_node_modules_es_to_primitive_README_autotoc_md8826}
Simply clone the repo, {\ttfamily npm install}, and run {\ttfamily npm test} 