-
Notifications
You must be signed in to change notification settings - Fork 84
/
flyd.min.js
1 lines (1 loc) · 5.89 KB
/
flyd.min.js
1
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):n.flyd=t()}(this,function(){"use strict";var n=function(n,t){switch(n){case 0:return function(){return t.apply(this,arguments)};case 1:return function(n){return t.apply(this,arguments)};case 2:return function(n,e){return t.apply(this,arguments)};case 3:return function(n,e,r){return t.apply(this,arguments)};case 4:return function(n,e,r,u){return t.apply(this,arguments)};case 5:return function(n,e,r,u,a){return t.apply(this,arguments)};case 6:return function(n,e,r,u,a,i){return t.apply(this,arguments)};case 7:return function(n,e,r,u,a,i,s){return t.apply(this,arguments)};case 8:return function(n,e,r,u,a,i,s,o){return t.apply(this,arguments)};case 9:return function(n,e,r,u,a,i,s,o,d){return t.apply(this,arguments)};case 10:return function(n,e,r,u,a,i,s,o,d,f){return t.apply(this,arguments)};default:throw new Error("First argument to _arity must be a non-negative integer no greater than ten")}};var t=function(n){return null!=n&&"object"==typeof n&&!0===n["@@functional/placeholder"]};var e=function(n){return function e(r){return 0===arguments.length||t(r)?e:n.apply(this,arguments)}};var r=function e(r,u,a){return function(){for(var i=[],s=0,o=r,d=0;d<u.length||s<arguments.length;){var f;d<u.length&&(!t(u[d])||s>=arguments.length)?f=u[d]:(f=arguments[s],s+=1),i[d]=f,t(f)||(o-=1),d+=1}return o<=0?a.apply(this,i):n(o,e(r,i,a))}},u=function(n){return function r(u,a){switch(arguments.length){case 0:return r;case 1:return t(u)?r:e(function(t){return n(u,t)});default:return t(u)&&t(a)?r:t(u)?e(function(t){return n(t,a)}):t(a)?e(function(t){return n(u,t)}):n(u,a)}}}(function(t,u){return 1===t?e(u):n(t,r(t,[],u))});function a(){return!0}var i,s=[],o=[],d=-1,f=!1,c=!1;var p={};function l(n,t){var e,r,u,i,s=w([],a);for(u=[],i=[],e=0;e<t.length;++e)void 0!==t[e]&&(u.push(t[e]),void 0!==t[e].end&&i.push(t[e].end));return(r=w(u,n)).depsChanged=[],r.fnArgs=r.deps.concat([r,r.depsChanged]),r.end=s,s.listeners.push(r),S(i,s),s.deps=i,A(r),r}function h(n,t){return l(function(t,e){e(n(t.val))},[t])}function v(n){return h(n,this)}function g(n){return n(this)}function y(n){return m(n,this)}function m(n,t){var e=p.stream(1),r=p.on(function(){var n=e()-1;e(n),n<=0&&e.end(!0)});r(t.end);var u=p.stream(),a=p.combine(function(t,a){u.end(!0);var i=n(t());e(e()+1),r(i.end),u=h(a,i)},[t]);return p.endsOn(e.end,a),a}function C(n,t){return l(function(n,t,e){e(n.val(t.val))},[t,n])}function U(n){return C(n,this)}function V(n){return C(this,n)}function M(){return"stream("+this.val+")"}function b(){function n(t){return 0===arguments.length?n.val:(function n(t,e){e.val=t;e.hasVal=!0;void 0===i?(c=!0,function(n){var t,e,r,u=n.listeners;for(t=0;t<u.length;++t)(r=u[t]).end===n?N(r):(void 0!==r.depsChanged&&r.depsChanged.push(n),r.shouldUpdate=!0,O(r));for(;d>=0;--d)!0===(e=o[d]).shouldUpdate&&A(e),e.queued=!1}(e),s.length>0&&x(),c=!1):i===e?function(n,t){var e,r;for(e=0;e<t.length;++e)(r=t[e]).end!==n?(void 0!==r.depsChanged&&r.depsChanged.push(n),r.shouldUpdate=!0):N(r)}(e,e.listeners):q(function(e){n(t,e)},e)}(t,n),n)}return n.hasVal=!1,n.val=void 0,n.updaters=[],n.listeners=[],n.queued=!1,n.end=void 0,n.ap=U,n["fantasy-land/map"]=n.map=v,n["fantasy-land/ap"]=V,n["fantasy-land/of"]=n.of=p.stream,n["fantasy-land/chain"]=n.chain=y,n.pipe=g,n.constructor=p.stream,n.toJSON=function(){return n.val},n.toString=M,n}function w(n,t){var e=b();return e.fn=t,e.deps=n,e.depsMet=!1,e.depsChanged=n.length>0?[]:void 0,e.shouldUpdate=!1,S(n,e),e}function A(n){var t;if((!(t=n).end||!0!==t.end.val)&&function(n){return!0===n.depsMet||function(n){return n.depsMet=n.deps.every(function(n){return n.hasVal}),n.depsMet}(n)}(n))if(void 0===i){i=n,n.depsChanged&&(n.fnArgs[n.fnArgs.length-1]=n.depsChanged);var e=n.fn.apply(n.fn,n.fnArgs);void 0!==e&&n(e),i=void 0,void 0!==n.depsChanged&&(n.depsChanged=[]),n.shouldUpdate=!1,!1===(f||c)&&x(),function(n){return n.listeners.some(function(n){return n.shouldUpdate})}(n)&&(c?n.listeners.forEach(function(n){n.shouldUpdate&&q(A,n)}):n(n.val))}else q(A,n)}function O(n){var t,e=n.listeners;if(!1===n.queued){for(n.queued=!0,t=0;t<e.length;++t)O(e[t]);o[++d]=n}}function q(n,t){s.push(t),t.updaters.push(n),t.shouldUpdate=!0}function x(){for(f=!0;s.length>0;){var n=s.shift(),t=n.updaters.shift();t&&n.shouldUpdate&&t(n)}f=!1}function S(n,t){for(var e=0;e<n.length;++e)n[e].listeners.push(t)}function j(n,t){t[t.indexOf(n)]=t[t.length-1],t.length--}function E(n){for(var t=0;t<n.deps.length;++t)j(n,n.deps[t].listeners);n.deps.length=0}function N(n){void 0!==n.deps&&E(n),void 0!==n.end&&E(n.end)}function P(){}return p.stream=function(n){var t=w([],a),e=b();return e.end=t,e.fnArgs=[],t.listeners.push(e),arguments.length>0&&e(n),e},p.stream["fantasy-land/of"]=p.stream.of=p.stream,p.combine=u(2,l),p.isStream=function(n){return!!((t=n)&&t.constructor&&t.call&&t.apply)&&"hasVal"in n;var t},p.immediate=function(n){return!1===n.depsMet&&(n.depsMet=!0,A(n)),n},p.endsOn=function(n,t){return E(t.end),n.listeners.push(t.end),t.end.deps.push(n),t},p.map=u(2,h),p.chain=u(2,m),p.ap=u(2,C),p.on=u(2,function(n,t){return l(function(t){n(t.val)},[t])}),p.scan=u(3,function(n,t,e){var r=l(function(e,r){r(t=n(t,e.val))},[e]);return r.hasVal||r(t),r}),p.merge=u(2,function(n,t){var e=p.immediate(l(function(n,t,e,r){r[0]?e(r[0]()):n.hasVal?e(n.val):t.hasVal&&e(t.val)},[n,t]));return p.endsOn(l(function(){return!0},[n.end,t.end]),e),e}),p.transduce=u(2,function(n,t){return n=n(new P),l(function(t,e){var r=n["@@transducer/step"](void 0,t.val);return r&&!0===r["@@transducer/reduced"]?(e.end(!0),r["@@transducer/value"]):r},[t])}),p.curryN=u,p.fromPromise=function(n){var t=p.stream();return n.then(function(n){t(n),t.end(!0)}),t},p.flattenPromise=function(n){return l(function(n,t){n().then(t)},[n])},P.prototype["@@transducer/init"]=function(){},P.prototype["@@transducer/result"]=function(){},P.prototype["@@transducer/step"]=function(n,t){return t},p});