-
Notifications
You must be signed in to change notification settings - Fork 0
/
leap.min.js
1 lines (1 loc) · 5.05 KB
/
leap.min.js
1
(function(){var t=[].slice,n=function(t,n){function e(){this.constructor=t}for(var u in n)r.call(n,u)&&(t[u]=n[u]);return e.prototype=n.prototype,t.prototype=new e,t.__super__=n.prototype,t},r={}.hasOwnProperty;!function(t,n){return("undefined"!=typeof module&&null!==module?module.exports:void 0)?"undefined"!=typeof module&&null!==module?module.exports=n():void 0:("undefined"!=typeof define&&null!==define?define.amd:void 0)?define(t,n):this[t]=n()}("leap",function(){var r,e,u,o,i,c,f;return i=("undefined"!=typeof process&&null!==process?process.nextTick:void 0)||function(t){return setTimeout(t,1)},c=function(t,n){return n(null,t)},r=function(){function n(){var n;n=1<=arguments.length?t.call(arguments,0):[],this.current=this.root=new u(this._wrap_first(n)),this.then.flow=this,this.and.flow=this,this.manual_start||i(function(t){return function(){return t.yeah()}}(this))}return n.prototype.then=function(){var n;return n=1<=arguments.length?t.call(arguments,0):[],this.current=this.current.child(n),this},n.prototype.and=function(t){return this.current===this.root&&(t=this._wrap_first(t)),this.current.sibling(t),this},n.prototype.identity=function(){return this.current===this.root&&this.then(c),this.and(c)},n.prototype.rescue=function(t){return this._rescue=t,this},n.prototype._rescue=function(t){throw Error(t)},n.prototype.yeah=function(){return this.root.run(null,this._rescue)},n.prototype.back=function(t){return this.then(function(n){return t(null,n)}),this.rescue(t)},n.prototype._wrap_first=function(t){var n,r,e,u,o;if(Array.isArray(t)){for(o=[],n=function(t){return o.push(function(n,r){return t.call(r,r)})},e=0,u=t.length;u>e;e++)r=t[e],n(r);return o}return function(n,r){return t.call(r,r)}},n}(),u=function(){function t(t){this._next=this._err=null,Array.isArray(t)?this.functions=t:"function"==typeof t&&(this.functions=[t])}return t.prototype.functions=[],t.prototype.child=function(n){return this._next=new t(n)},t.prototype.sibling=function(t){return this.functions.push(t)},t.prototype.run=function(t,n){var r,e,u,o,i,c,f,s,l,h;for(i=this.functions.length,l=[],r=0,f=function(e){return function(u,o){var c;return c=function(t,o){return e.err?void 0:t?(e.err=t,n(t)):(1===i?l=o:l[u]=o,e._next&&++r===i?e._next.run(l,n):void 0)},c.next=c.cb=function(t){var n;return n=Array.prototype.slice.call(arguments),n.unshift(null),c.apply(this,n)},"undefined"!=typeof Backbone&&(c.bb={success:function(){var t;return t=Array.prototype.slice.call(arguments),t.unshift(null),c.call(this,t)},error:function(){return c.call(this,Array.prototype.slice.call(arguments))}}),o.apply(c,[t,c])}}(this),s=this.functions,h=[],u=o=0,c=s.length;c>o;u=++o)e=s[u],h.push(f(u,e));return h},t}(),f=function(){var n;return n=1<=arguments.length?t.call(arguments,0):[],function(t,n,r){r.prototype=t.prototype;var e=new r,u=t.apply(e,n);return Object(u)===u?u:e}(r,n,function(){})},e=function(t){function r(){return r.__super__.constructor.apply(this,arguments)}return n(r,t),r.prototype.manual_start=!0,r}(r),f["export"]=function(){var n;return n=1<=arguments.length?t.call(arguments,0):[],function(t,n,r){r.prototype=t.prototype;var e=new r,u=t.apply(e,n);return Object(u)===u?u:e}(e,n,function(){})},f.map=function(t,n,e){var u,o,i,c,f;if(u=new r,t&&0!==t.length){for(o=function(t){return u.and(function(){return n.call(this,t,this)})},c=0,f=t.length;f>c;c++)i=t[c],o(i);1===t.length&&u.then(function(t){return this.next([t])})}else u.and(function(){return this()}).then(function(){return this.next([])});return e&&(u.then(function(t){return e(null,t)}),u.rescue(e)),u},r.prototype.then.map=function(t){return this.flow.then(function(n,r){return f.map(n,t,r)})},r.prototype.and.map=function(t){return this.flow.and(function(n,r){return f.map(n,t,r)})},f.reduce=function(t,n,e){var u,o,i,c,f;for(u=new r(function(){return this()}),o=function(t){return u.then(function(r){return n.call(this,t,r,this)})},c=0,f=t.length;f>c;c++)i=t[c],o(i);return e&&(u.then(function(t){return e(null,t)}),u.rescue(e)),u},r.prototype.then.reduce=function(t){return this.flow.then(function(n,r){return f.reduce(n,t,r)})},r.prototype.and.reduce=function(t){return this.flow.and(function(n,r){return f.reduce(n,t,r)})},f.filter=function(t,n,r){return f.map(t,n).then(function(n){var e,u,o,i,c;for(i=[],e=u=0,o=n.length;o>u;e=++u)c=n[e],c&&i.push(t[e]);return r?r(null,i):this.next(i)})},r.prototype.then.filter=function(t){return this.flow.then(function(n,r){return f.filter(n,t,r)})},r.prototype.and.filter=function(t){return this.flow.and(function(n,r){return f.filter(n,t,r)})},f.reject=function(t,n,r){return f.map(t,n).then(function(n){var e,u,o,i,c;for(i=[],e=u=0,o=n.length;o>u;e=++u)c=n[e],c||i.push(t[e]);return r?r(null,i):this.next(i)})},r.prototype.then.reject=function(t){return this.flow.then(function(n,r){return f.reject(n,t,r)})},r.prototype.and.reject=function(t){return this.flow.and(function(n,r){return f.reject(n,t,r)})},o=function(t){return function(n){return n[t]}},f.pluck=function(t){return function(n,r){return this(null,n.map(o(t)))}},r.prototype.then.pluck=function(t){return this.flow.then(f.pluck(t))},f.I=c,f.of={faith:f},f.VERSION="0.1.3",f})}).call(this);