liar
Version:
A modular collection of tools for asynchronous programing via promises
1 lines • 11.2 kB
JavaScript
!function(a){"object"==typeof exports?module.exports=a():"function"==typeof define&&define.amd?define(a):"undefined"!=typeof window?window.liar=a():"undefined"!=typeof global?global.liar=a():"undefined"!=typeof self&&(self.liar=a())}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b){var c=a("lie");c.use=a("lie-use"),c.resolve=a("lie-resolve"),c.reject=a("lie-reject"),c.all=a("lie-all"),c.race=a("lie-race"),c.cast=a("lie-cast"),c.some=a("lie-some"),c.map=a("lie-map"),c.denodify=a("lie-denodify"),c.apply=a("lie-apply"),c.lfold=a("lie-lfold"),c.rfold=a("lie-rfold"),c.fold=a("lie-fold"),c.zip=a("lie-zip"),c.zipwith=a("lie-zipwith"),c.filter=a("lie-filter"),c.every=a("lie-every"),c.any=a("lie-any"),b.exports=c},{lie:36,"lie-all":3,"lie-any":6,"lie-apply":8,"lie-cast":10,"lie-denodify":11,"lie-every":12,"lie-filter":13,"lie-fold":14,"lie-lfold":16,"lie-map":18,"lie-race":20,"lie-reject":22,"lie-resolve":23,"lie-rfold":24,"lie-some":26,"lie-use":29,"lie-zip":30,"lie-zipwith":33}],2:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){if(a.source===window&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var b=c.shift();b()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],3:[function(a,b){function c(a){return d(function(b,c){var d=a.length;d||b([]);var h=0,i=[],j=function(a){return function(c){i[a]=c,++h===d&&b(i)}};g(f(a,e),function(a,b){a.then(j(b),function(a){c(a)})})})}var d=a("lie"),e=a("lie-cast"),f=a("lie-quickmap"),g=a("lie-quickeach");b.exports=c},{lie:36,"lie-cast":10,"lie-quickeach":4,"lie-quickmap":5}],4:[function(a,b){function c(a,b){var c=a.length;if(c)for(var d=-1;++d<c;)b(a[d],d)}b.exports=c},{}],5:[function(a,b){function c(a,b){var c=a.length;if(!c)return[];var d=-1,e=new Array(c);if("function"==typeof b)for(;++d<c;)e[d]=b(a[d],d);else for(;++d<c;)e[d]=a[d];return e}b.exports=c},{}],6:[function(a,b){function c(a,b){var c="function"==typeof b;return f(function(f,h){e(d(a,function(a){var d=g(a);return c&&(d=d.then(b)),d.then(function(a){return a?(f(!0),void 0):!1})})).then(function(){f(!1)},h)})}var d=a("lie-quickmap"),e=a("lie-all"),f=a("lie"),g=a("lie-cast");b.exports=c},{lie:36,"lie-all":3,"lie-cast":10,"lie-quickmap":7}],7:[function(a,b){b.exports=a(5)},{}],8:[function(a,b){function c(){var a=d(arguments),b=a.shift();return 0===a.length?f(b()):1===a.length?f(a[0]).then(b):e(a).then(function(a){return b.apply(null,a)})}var d=a("lie-quickmap"),e=a("lie-all"),f=a("lie-cast");b.exports=c},{"lie-all":3,"lie-cast":10,"lie-quickmap":9}],9:[function(a,b){b.exports=a(5)},{}],10:[function(a,b){function c(a){return a&&"function"==typeof a.then?a:d(a)}var d=a("lie-resolve");b.exports=c},{"lie-resolve":23}],11:[function(a,b){function c(a){return function(){var b=Array.prototype.concat.apply([],arguments);return d(function(c,d){b.push(function(a,b){a?d(a):c(b)}),a.apply(void 0,b)})}}var d=a("lie");b.exports=c},{lie:36}],12:[function(a,b){function c(a,b){var c="function"==typeof b,f=Math.random().toString();return d(a,function(a){var d=e(a);return c&&(d=d.then(b)),d.then(function(a){if(!a)throw f})}).then(function(){return!0},function(a){if(a===f)return!1;throw a})}var d=a("lie-map"),e=a("lie-cast");b.exports=c},{"lie-cast":10,"lie-map":18}],13:[function(a,b){function c(a,b){return d(a,b).then(function(b){return e(function(a,b){return b?a:b},a,b)}).then(function(a){return a.filter(function(a){return a})})}var d=a("lie-map"),e=a("lie-zipwith");b.exports=c},{"lie-map":18,"lie-zipwith":33}],14:[function(a,b){function c(a,b,c){return d(a).then(function(a){var d=c;return f(a,function(a){d="undefined"==typeof d?a:e(b,d,a)}),d})}var d=a("lie-some"),e=a("lie-apply"),f=a("lie-quickeach");b.exports=c},{"lie-apply":8,"lie-quickeach":15,"lie-some":26}],15:[function(a,b){b.exports=a(4)},{}],16:[function(a,b){function c(a,b,c){var f=c;return e(a,function(a){f="undefined"==typeof f?a:d(b,f,a)}),f}var d=a("lie-apply"),e=a("lie-quickeach");b.exports=c},{"lie-apply":8,"lie-quickeach":17}],17:[function(a,b){b.exports=a(4)},{}],18:[function(a,b){function c(a,b){return d(a,function(a){return e(f(a,function(a,c){return g(a).then(function(a){return b(a,c)})}))})}var d=a("lie-use"),e=a("lie-all"),f=a("lie-quickmap"),g=a("lie-cast");b.exports=c},{"lie-all":3,"lie-cast":10,"lie-quickmap":19,"lie-use":29}],19:[function(a,b){b.exports=a(5)},{}],20:[function(a,b){function c(a){return d(function(b,c){e(a,function(a){a.then(b,c)})})}var d=a("lie"),e=a("lie-quickeach");b.exports=c},{lie:36,"lie-quickeach":21}],21:[function(a,b){b.exports=a(4)},{}],22:[function(a,b){function c(a){return d(function(b,c){c(a)})}var d=a("lie");b.exports=c},{lie:36}],23:[function(a,b){function c(a){return d(function(b){b(a)})}var d=a("lie");b.exports=c},{lie:36}],24:[function(a,b){function c(a,b,c){var f=c,g=a.length-1;return e(a,function(c,e){var h=a[g-e];f="undefined"==typeof f?h:d(b,f,h)}),f}var d=a("lie-apply"),e=a("lie-quickeach");b.exports=c},{"lie-apply":8,"lie-quickeach":25}],25:[function(a,b){b.exports=a(4)},{}],26:[function(a,b){function c(a){return d(function(b,c){function d(){j.length===h?c(j):i.length+j.length===h&&b(i)}var h=a.length,i=[],j=[];g(f(a,e),function(a){a.then(function(a){i.push(a),d()},function(a){j.push(a),d()})})})}var d=a("lie"),e=a("lie-cast"),f=a("lie-quickmap"),g=a("lie-quickeach");b.exports=c},{lie:36,"lie-cast":10,"lie-quickeach":27,"lie-quickmap":28}],27:[function(a,b){b.exports=a(4)},{}],28:[function(a,b){b.exports=a(5)},{}],29:[function(a,b){function c(a,b){return"function"==typeof a.then?a.then(b):b(a)}b.exports=c},{}],30:[function(a,b){function c(){if(1===arguments.length)return d(arguments[0],function(a){return[a]});var a=e(arguments),b=a[0].length,c=0;return f(a,function(a,d){var e=a.length;b>e&&(c=d,b=e)}),d(a[c],function(b,c){return d(a,function(a){return a[c]})})}var d=a("lie-map"),e=a("lie-quickmap"),f=a("lie-quickeach");b.exports=c},{"lie-map":18,"lie-quickeach":31,"lie-quickmap":32}],31:[function(a,b){b.exports=a(4)},{}],32:[function(a,b){b.exports=a(5)},{}],33:[function(a,b){function c(){if(2===arguments.length)return d(arguments[1],arguments[0]);var a=e(arguments),b=a.shift(),c=a[0].length,g=0;return f(a,function(a,b){var d=a.length;c>d&&(g=b,c=d)}),d(a[g],function(c,e){return d(a,function(a){return a[e]}).then(function(a){return b.apply(null,a)})})}var d=a("lie-map"),e=a("lie-quickmap"),f=a("lie-quickeach");b.exports=c},{"lie-map":18,"lie-quickeach":34,"lie-quickmap":35}],34:[function(a,b){b.exports=a(4)},{}],35:[function(a,b){b.exports=a(5)},{}],36:[function(a,b){function Promise(a){function b(a,b){return Promise(function(c,d){"function"==typeof a?g.push({resolve:c,reject:d,callback:a}):g.push({next:c,callback:!1}),"function"==typeof b?h.push({resolve:c,reject:d,callback:b}):h.push({next:d,callback:!1})})}function f(a,b){if(!i){i=c(this,b,a?0:1);for(var f=a?g:h,j=f.length,k=-1;++k<j;)f[k].callback?e(d,f[k].callback,b,f[k].resolve,f[k].reject):f[k].next&&f[k].next(b)}}if(!(this instanceof Promise))return new Promise(a);var g=[],h=[],i=!1;this.then=function(a,c){return i?i(a,c):b(a,c)};var j=f.bind(this,!0),k=f.bind(this,!1);try{a(function(a){a&&"function"==typeof a.then?a.then(j,k):j(a)},k)}catch(l){k(l)}}function c(a,b,c){return function(){var f=arguments[c];return"function"!=typeof f?a:Promise(function(a,c){e(d,f,b,a,c)})}}function d(a,b,c,d){try{var e=a(b);e&&"function"==typeof e.then?e.then(c,d):c(e)}catch(f){d(f)}}var e=a("immediate");b.exports=Promise},{immediate:38}],37:[function(a,b){var c="undefined"!=typeof self?self:"undefined"!=typeof window?window:{};b.exports="object"==typeof c&&c?c:this},{}],38:[function(a,b){"use strict";function c(){var a,b=0,c=f;for(f=[];a=c[b++];)a()}var d,e=[a("./nextTick"),a("./mutation"),a("./realSetImmediate"),a("./postMessage"),a("./messageChannel"),a("./stateChange"),a("./timeout")],f=[];e.some(function(a){var b=a.test();return b&&(d=a.install(c)),b});var g=function(a){var b,e;return arguments.length>1&&"function"==typeof a&&(e=Array.prototype.slice.call(arguments,1),e.unshift(void 0),a=a.bind.apply(a,e)),1===(b=f.push(a))&&d(c),b};g.clear=function(a){return a<=f.length&&(f[a-1]=function(){}),this},b.exports=g},{"./messageChannel":39,"./mutation":40,"./nextTick":41,"./postMessage":42,"./realSetImmediate":43,"./stateChange":44,"./timeout":45}],39:[function(a,b,c){"use strict";var d=a("./global");c.test=function(){return!!d.MessageChannel},c.install=function(a){var b=new d.MessageChannel;return b.port1.onmessage=a,function(){b.port2.postMessage(0)}}},{"./global":37}],40:[function(a,b,c){"use strict";var d=a("./global"),e=d.MutationObserver||d.WebKitMutationObserver;c.test=function(){return e},c.install=function(a){var b=new e(a),c=d.document.createElement("div");return b.observe(c,{attributes:!0}),d.addEventListener("unload",function(){b.disconnect(),b=null},!1),function(){c.setAttribute("drainQueue","drainQueue")}}},{"./global":37}],41:[function(a,b,c){var d=a("__browserify_process");c.test=function(){return"object"==typeof d&&"[object process]"===Object.prototype.toString.call(d)},c.install=function(){return d.nextTick}},{__browserify_process:2}],42:[function(a,b,c){"use strict";var d=a("./global");c.test=function(){if(!d.postMessage||d.importScripts)return!1;var a=!0,b=d.onmessage;return d.onmessage=function(){a=!1},d.postMessage("","*"),d.onmessage=b,a},c.install=function(a){function b(b){b.source===d&&b.data===c&&a()}var c="com.calvinmetcalf.setImmediate"+Math.random();return d.addEventListener?d.addEventListener("message",b,!1):d.attachEvent("onmessage",b),function(){d.postMessage(c,"*")}}},{"./global":37}],43:[function(a,b,c){"use strict";var d=a("./global");c.test=function(){return d.setImmediate},c.install=function(a){return d.setTimeout.bind(d,a,0)}},{"./global":37}],44:[function(a,b,c){"use strict";var d=a("./global");c.test=function(){return"document"in d&&"onreadystatechange"in d.document.createElement("script")},c.install=function(a){return function(){var b=d.document.createElement("script");return b.onreadystatechange=function(){a(),b.onreadystatechange=null,b.parentNode.removeChild(b),b=null},d.document.documentElement.appendChild(b),a}}},{"./global":37}],45:[function(a,b,c){"use strict";c.test=function(){return!0},c.install=function(a){return function(){setTimeout(a,0)}}},{}]},{},[1])(1)});