\href{http://promises-aplus.github.com/promises-spec}{\texttt{  }} \href{https://travis-ci.org/calvinmetcalf/lie}{\texttt{ }}

lie is a small, performant promise library implementing the \href{http://promises-aplus.github.com/promises-spec/}{\texttt{ Promises/\+A+ spec}} (Version 1.\+1).

Originally a fork of \href{https://github.com/RubenVerborgh}{\texttt{ Ruben Verborgh}}\textquotesingle{}s \href{https://github.com/RubenVerborgh/promiscuous}{\texttt{ promiscuous}}, with version 2.\+6 it became a fork of \href{https://github.com/cburgmer/ayepromise}{\texttt{ ayepromise}} by \href{https://github.com/cburgmer}{\texttt{ Chris Burgmer}}.


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

\end{DoxyCode}



\begin{DoxyCode}{0}
\DoxyCodeLine{var Promise = require('lie');}
\DoxyCodeLine{// or use the pollyfill}
\DoxyCodeLine{require('lie/polyfill'); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_lie_README_autotoc_md16104}{}\doxysection{Usage}\label{md_sfcode_node_modules_lie_README_autotoc_md16104}
Either use it with \href{http://browserify.org/}{\texttt{ browserify}} (recommended) or grab one of the files from the dist folder\+:


\begin{DoxyItemize}
\item lie.\+js/lie.min.\+js exposes \textquotesingle{}Promise\textquotesingle{} either as a UMD module or from the global scope, depending on if a CJS or AMD loader is available.
\item lie.\+polyfill.\+js/lie.polyfill.\+min.\+js adds \textquotesingle{}Promise\textquotesingle{} to the global scope only if it\textquotesingle{}s not already defined (not a UMD).
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_lie_README_autotoc_md16105}{}\doxysection{API}\label{md_sfcode_node_modules_lie_README_autotoc_md16105}
Implements the standard ES6 api\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{new Promise(function(resolve, reject)\{}
\DoxyCodeLine{    doSomething(function(err, result) \{}
\DoxyCodeLine{        if (err) \{}
\DoxyCodeLine{            reject(err);}
\DoxyCodeLine{        \} else \{}
\DoxyCodeLine{            resolve(result);}
\DoxyCodeLine{        \}}
\DoxyCodeLine{    \});}
\DoxyCodeLine{\}).then(function (value) \{}
\DoxyCodeLine{    //on success}
\DoxyCodeLine{\}, function (reason) \{}
\DoxyCodeLine{    //on error}
\DoxyCodeLine{\}).catch(function (reason) \{}
\DoxyCodeLine{    //shortcut for error handling}
\DoxyCodeLine{\});}
\DoxyCodeLine{}
\DoxyCodeLine{Promise.all([}
\DoxyCodeLine{    //array of promises or values}
\DoxyCodeLine{]).then(function ([/* array of results */]));}
\DoxyCodeLine{}
\DoxyCodeLine{Promise.race([}
\DoxyCodeLine{    //array of promises or values}
\DoxyCodeLine{]);}
\DoxyCodeLine{// either resolves or rejects depending on the first value to do so }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_lie_README_autotoc_md16106}{}\doxysection{Unhandled Rejections}\label{md_sfcode_node_modules_lie_README_autotoc_md16106}
In Node.\+js, lie emits an {\ttfamily unhandled\+Rejection} event when a rejected promise isn\textquotesingle{}t caught, in line with \href{https://iojs.org/api/process.html\#process_event_unhandledrejection}{\texttt{ how io.\+js does it}}. This allows it to act as a promise shim in both Node.\+js and the browser. 