TrinetraLabs/Placebo_AI
0
1# lie2<a href="http://promises-aplus.github.com/promises-spec">3 <img src="http://promises-aplus.github.com/promises-spec/assets/logo-small.png"4 alt="Promises/A+ logo" title="Promises/A+ 1.1 compliant" align="right" />5</a> [](https://travis-ci.org/calvinmetcalf/lie)6 7lie is a small, performant promise library implementing the [Promises/A+ spec](http://promises-aplus.github.com/promises-spec/) (Version 1.1).8 9Originally a fork of [Ruben Verborgh](https://github.com/RubenVerborgh)'s [promiscuous](https://github.com/RubenVerborgh/promiscuous), with version 2.6 it became a fork of [ayepromise](https://github.com/cburgmer/ayepromise) by [Chris Burgmer](https://github.com/cburgmer).10 11```bash12npm install lie13 14```15 16```javascript17var Promise = require('lie');18// or use the pollyfill19require('lie/polyfill');20```21 22## Usage23 24Either use it with [browserify](http://browserify.org/) (recommended) or grab one of the files from the dist folder:25 26- lie.js/lie.min.js exposes 'Promise' either as a UMD module or from the global scope, depending on if a CJS or AMD loader is available.27- lie.polyfill.js/lie.polyfill.min.js adds 'Promise' to the global scope only if it's not already defined (not a UMD).28 29## API30 31Implements the standard ES6 api:32 33```js34new Promise(function(resolve, reject){35 doSomething(function(err, result) {36 if (err) {37 reject(err);38 } else {39 resolve(result);40 }41 });42}).then(function (value) {43 //on success44}, function (reason) {45 //on error46}).catch(function (reason) {47 //shortcut for error handling48});49 50Promise.all([51 //array of promises or values52]).then(function ([/* array of results */]));53 54Promise.race([55 //array of promises or values56]);57// either resolves or rejects depending on the first value to do so58```59 60## Unhandled Rejections61 62In Node.js, lie emits an `unhandledRejection` event when a rejected promise isn't caught, in line with [how io.js does it](https://iojs.org/api/process.html#process_event_unhandledrejection). This allows it to act as a promise shim in both Node.js and the browser.63 