@most/core
Advanced tools
Comparing version 0.14.0 to 0.15.0
@@ -1,1 +0,1 @@ | ||
(function(t,e){typeof exports==="object"&&typeof module!=="undefined"?e(exports,require("@most/prelude"),require("@most/scheduler"),require("@most/disposable")):typeof define==="function"&&define.amd?define(["exports","@most/prelude","@most/scheduler","@most/disposable"],e):e(t.mostCore=t.mostCore||{},t.mostPrelude,t.mostScheduler,t.mostDisposable)})(this,function(t,e,r,n){"use strict";function i(t){setTimeout(s,0,t)}function s(t){throw t}var o=function(t,e,r){return new p(t,e,r)};var u=function(t,e){return o(a,t,e)};var c=function(t){return o(f,undefined,t)};var h=function(t,e){return o(v,t,e)};var p=function t(e,r,n){this._run=e;this.value=r;this.sink=n;this.active=true};p.prototype.dispose=function t(){this.active=false};p.prototype.run=function t(e){if(!this.active){return}var t=this._run;t(e,this.value,this.sink)};p.prototype.error=function t(e,r){if(!this.active){return i(r)}this.sink.error(e,r)};var a=function(t,e,r){return r.event(t,e)};var f=function(t,e,r){return r.end(t)};var v=function(t,e,r){return r.error(t,e)};var l=function(){return d};var y=function t(){};y.prototype.run=function t(e,n){return r.asap(c(e),n)};var d=new y;var _=function(){return w};var k=function t(){};k.prototype.run=function t(){return n.disposeNone()};var w=new k;var m=function(t,e){return new b(t,e)};var b=function t(e,r){this.time=e;this.value=r};b.prototype.run=function t(e,n){return r.delay(this.time,o(g,this.value,e),n)};function g(t,e,r){r.event(t,e);r.end(t)}var x=function(t){return m(0,t)};var O=function(t){return new j(t)};var j=function t(e){this.period=e};j.prototype.run=function t(e,n){return r.periodic(this.period,u(undefined,e),n)};var I=function(t){return new A(t)};var A=function t(e){this.run=e};var E=function t(e){this.sink=e};E.prototype.event=function t(e,r){return this.sink.event(e,r)};E.prototype.end=function t(e){return this.sink.end(e)};E.prototype.error=function t(e,r){return this.sink.error(e,r)};var T=function(t,e){return C(q,t,e)};var C=function(t,e,r){return e.length===0||r===l()?l():new D(t,e,r)};var q=function(t,e){return t};var D=function t(e,r,n){this.f=e;this.values=r;this.source=n};D.prototype.run=function t(e,r){return this.source.run(new B(this.f,this.values,e),r)};var B=function(t){function e(e,r,n){t.call(this,n);this.f=e;this.values=r;this.index=0}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){var n=this.f;this.sink.event(e,n(this.values[this.index],r));this.index+=1;if(this.index>=this.values.length){this.sink.end(e)}};return e}(E);var P=function t(){this.disposable=undefined;this.disposed=false};P.prototype.setDisposable=function t(e){if(this.disposable!==void 0){throw new Error("setDisposable called more than once")}this.disposable=e;if(this.disposed){e.dispose()}};P.prototype.dispose=function t(){if(this.disposed){return}this.disposed=true;if(this.disposable!==void 0){this.disposable.dispose()}};var V=e.curry2(function(t,e){return new Promise(function(r,n){return M(t,e,r,n)})});function M(t,e,r,n){var i=new P;var s=new N(r,n,i);i.setDisposable(t.run(s,e))}var N=function t(e,r,n){this._end=e;this._error=r;this._disposable=n;this.active=true};N.prototype.event=function t(e,r){};N.prototype.end=function t(e){if(!this.active){return}this._dispose(this._error,this._end,undefined)};N.prototype.error=function t(e,r){this._dispose(this._error,this._error,r)};N.prototype._dispose=function t(e,r,n){this.active=false;R(e,r,n,this._disposable)};function R(t,e,r,n){try{n.dispose()}catch(e){t(e);return}e(r)}var S=function(t,e,r){return r.run(t,e)};var W=function t(e,r){this.sink=r;this.offset=e};W.prototype.event=function t(e,r){this.sink.event(e+this.offset,r)};W.prototype.error=function t(e,r){this.sink.error(e+this.offset,r)};W.prototype.end=function t(e){this.sink.end(e+this.offset)};var z=function(t,e){return new L(t,e)};var L=function t(e,r){this.origin=e;this.source=r};L.prototype.run=function t(e,n){return this.source.run(F(this.origin,e),r.schedulerRelativeTo(this.origin,n))};var F=function(t,e){return e instanceof W?new W(t+e.offset,e.sink):new W(t,e)};var G=function(t,e,r){return new H(t,e,r)};var H=function t(e,r,n){this.step=e;this.seed=r;this.source=n};H.prototype.run=function t(e,r){return this.source.run(new J(this.step,this.seed,e),r)};var J=function(t){function e(e,r,n){t.call(this,n);this.step=e;this.seed=r}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){var n=this.step(this.seed,r);this.seed=n.seed;this.sink.event(e,n.value)};return e}(E);var K=function(t,e,r){return new Q(t,e,r)};var Q=function t(e,r,n){this.source=n;this.f=e;this.value=r};Q.prototype.run=function t(e,i){var s=r.asap(u(this.value,e),i);var o=this.source.run(new U(this.f,this.value,e),i);return n.disposeBoth(s,o)};var U=function(t){function e(e,r,n){t.call(this,n);this.f=e;this.value=r}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){var n=this.f;this.value=n(this.value,r);this.sink.event(e,this.value)};return e}(E);var X=function(t,e){return new Y(t,e)};var Y=function t(e,r){this.f=e;this.source=r};Y.prototype.run=function t(e,r){return new Z(this.f,this.source,e,r)};var Z=function(t){function e(e,r,i,s){t.call(this,i);this.f=e;this.scheduler=s;this.active=true;this.disposable=n.disposeOnce(r.run(this,s))}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(!this.active){return}this.sink.event(e,r)};e.prototype.end=function t(e){if(!this.active){return}n.tryDispose(e,this.disposable,this.sink);this._startNext(e,this.sink)};e.prototype._startNext=function t(e,r){try{this.disposable=this._continue(this.f,e,r)}catch(t){r.error(e,t)}};e.prototype._continue=function t(e,r,n){return S(n,this.scheduler,z(r,e()))};e.prototype.dispose=function t(){this.active=false;return this.disposable.dispose()};return e}(E);var $=function(t,e){return X(function(){return e},x(t))};var tt=function t(e,r){this.p=e;this.source=r};tt.prototype.run=function t(e,r){return this.source.run(new et(this.p,e),r)};tt.create=function t(e,r){if(r instanceof tt){return new tt(rt(r.p,e),r.source)}return new tt(e,r)};var et=function(t){function e(e,r){t.call(this,r);this.p=e}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){var n=this.p;n(r)&&this.sink.event(e,r)};return e}(E);var rt=function(t,e){return function(r){return t(r)&&e(r)}};var nt=function t(e,r,n){this.p=e;this.f=r;this.source=n};nt.prototype.run=function t(e,r){return this.source.run(new it(this.p,this.f,e),r)};var it=function(t){function e(e,r,n){t.call(this,n);this.p=e;this.f=r}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){var n=this.f;var i=this.p;i(r)&&this.sink.event(e,n(r))};return e}(E);var st=function t(e,r){this.f=e;this.source=r};st.prototype.run=function t(e,r){return this.source.run(new ot(this.f,e),r)};st.create=function t(r,n){if(n instanceof st){return new st(e.compose(r,n.f),n.source)}if(n instanceof tt){return new nt(n.p,r,n.source)}return new st(r,n)};var ot=function(t){function e(e,r){t.call(this,r);this.f=e}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){var n=this.f;this.sink.event(e,n(r))};return e}(E);var ut=function(t,e){return st.create(t,e)};var ct=function(t,e){return ut(function(){return t},e)};var ht=function(t,e){return new pt(t,e)};var pt=function t(e,r){this.source=r;this.f=e};pt.prototype.run=function t(e,r){return this.source.run(new at(this.f,e),r)};var at=function(t){function e(e,r){t.call(this,r);this.f=e}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){var n=this.f;n(r);this.sink.event(e,r)};return e}(E);var ft=function(t){function e(e,r){t.call(this,r);this.index=e;this.active=true;this.value=undefined}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(!this.active){return}this.value=r;this.sink.event(e,this)};e.prototype.end=function t(e){if(!this.active){return}this.active=false;this.sink.event(e,this)};return e}(E);function vt(t,e){switch(e.length){case 0:return t();case 1:return t(e[0]);case 2:return t(e[0],e[1]);case 3:return t(e[0],e[1],e[2]);case 4:return t(e[0],e[1],e[2],e[3]);case 5:return t(e[0],e[1],e[2],e[3],e[4]);default:return t.apply(void 0,e)}}function lt(t,e,r){return yt(t,[e,r])}var yt=function(t,e){return e.length===0?l():e.length===1?ut(t,e[0]):new dt(t,e)};var dt=function t(e,r){this.f=e;this.sources=r};dt.prototype.run=function t(e,r){var i=this;var s=this.sources.length;var o=new Array(s);var u=new Array(s);var c=new _t(o,u,e,this.f);for(var h=void 0,p=0;p<s;++p){h=u[p]=new ft(p,c);o[p]=i.sources[p].run(h,r)}return n.disposeAll(o)};var _t=function(t){function e(e,r,n,i){t.call(this,n);this.disposables=e;this.sinks=r;this.f=i;var s=r.length;this.awaiting=s;this.values=new Array(s);this.hasValue=new Array(s).fill(false);this.activeCount=r.length}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(!r.active){this._dispose(e,r.index);return}var n=r.index;var i=this._updateReady(n);this.values[n]=r.value;if(i===0){this.sink.event(e,vt(this.f,this.values))}};e.prototype._updateReady=function t(e){if(this.awaiting>0){if(!this.hasValue[e]){this.hasValue[e]=true;this.awaiting-=1}}return this.awaiting};e.prototype._dispose=function t(e,r){n.tryDispose(e,this.disposables[r],this.sink);if(--this.activeCount===0){this.sink.end(e)}};return e}(E);function kt(t,r){return lt(e.apply,t,r)}var wt=function t(){this.head=null;this.length=0};wt.prototype.add=function t(e){if(this.head!==null){this.head.prev=e;e.next=this.head}this.head=e;++this.length};wt.prototype.remove=function t(e){--this.length;if(e===this.head){this.head=this.head.next}if(e.next!==null){e.next.prev=e.prev;e.next=null}if(e.prev!==null){e.prev.next=e.next;e.prev=null}};wt.prototype.isEmpty=function t(){return this.length===0};wt.prototype.dispose=function t(){if(this.isEmpty()){return Promise.resolve()}var e=[];var r=this.head;this.head=null;this.length=0;while(r!==null){e.push(r.dispose());r=r.next}return Promise.all(e)};var mt=function(t,r){return bt(e.id,t,r)};var bt=function(t,e,r){return new gt(t,e,r)};var gt=function t(e,r,n){this.f=e;this.concurrency=r;this.source=n};gt.prototype.run=function t(e,r){return new xt(this.f,this.concurrency,this.source,e,r)};var xt=function t(e,r,i,s,o){this.f=e;this.concurrency=r;this.sink=s;this.scheduler=o;this.pending=[];this.current=new wt;this.disposable=n.disposeOnce(i.run(this,o));this.active=true};xt.prototype.event=function t(e,r){this._addInner(e,r)};xt.prototype._addInner=function t(e,r){if(this.current.length<this.concurrency){this._startInner(e,r)}else{this.pending.push(r)}};xt.prototype._startInner=function t(e,r){try{this._initInner(e,r)}catch(t){this.error(e,t)}};xt.prototype._initInner=function t(e,r){var n=new jt(e,this,this.sink);n.disposable=Ot(this.f,e,r,n,this.scheduler);this.current.add(n)};xt.prototype.end=function t(e){this.active=false;n.tryDispose(e,this.disposable,this.sink);this._checkEnd(e)};xt.prototype.error=function t(e,r){this.active=false;this.sink.error(e,r)};xt.prototype.dispose=function t(){this.active=false;this.pending.length=0;this.disposable.dispose();this.current.dispose()};xt.prototype._endInner=function t(e,r){this.current.remove(r);n.tryDispose(e,r,this);if(this.pending.length===0){this._checkEnd(e)}else{this._startInner(e,this.pending.shift())}};xt.prototype._checkEnd=function t(e){if(!this.active&&this.current.isEmpty()){this.sink.end(e)}};var Ot=function(t,e,n,i,s){return t(n).run(i,r.schedulerRelativeTo(e,s))};var jt=function t(e,r,n){this.prev=this.next=null;this.time=e;this.outer=r;this.sink=n;this.disposable=void 0};jt.prototype.event=function t(e,r){this.sink.event(e+this.time,r)};jt.prototype.end=function t(e){this.outer._endInner(e+this.time,this)};jt.prototype.error=function t(e,r){this.outer.error(e+this.time,r)};jt.prototype.dispose=function t(){return this.disposable.dispose()};var It=function(t,e){return bt(t,Infinity,e)};var At=function(t){return mt(Infinity,t)};var Et=function(t,e){return bt(t,1,e)};function Tt(t,e){return Ct([t,e])}var Ct=function(t){return t.length===0?l():t.length===1?t[0]:qt(t)};var qt=function(t){return new Bt(e.reduce(Dt,[],t))};var Dt=function(t,e){return t.concat(e instanceof Bt?e.sources:e)};var Bt=function t(e){this.sources=e};Bt.prototype.run=function t(e,r){var i=this;var s=this.sources.length;var o=new Array(s);var u=new Array(s);var c=new Pt(o,u,e);for(var h=void 0,p=0;p<s;++p){h=u[p]=new ft(p,c);o[p]=i.sources[p].run(h,r)}return n.disposeAll(o)};var Pt=function(t){function e(e,r,n){t.call(this,n);this.disposables=e;this.activeCount=r.length}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(!r.active){this._dispose(e,r.index);return}this.sink.event(e,r.value)};e.prototype._dispose=function t(e,r){n.tryDispose(e,this.disposables[r],this.sink);if(--this.activeCount===0){this.sink.end(e)}};return e}(E);var Vt=function(t,e,r){return new Mt(t,e,r)};var Mt=function t(e,r,n){this.source=n;this.sampler=r;this.f=e};Mt.prototype.run=function t(e,r){var i=new Nt(this.f,this.source,e);var s=this.source.run(i.hold,r);var o=this.sampler.run(i,r);return n.disposeBoth(o,s)};var Nt=function(t){function e(e,r,n){t.call(this,n);this.source=r;this.f=e;this.hold=new Rt(this)}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(this.hold.hasValue){var n=this.f;this.sink.event(e,n(r,this.hold.value))}};return e}(E);var Rt=function(t){function e(e){t.call(this,e);this.hasValue=false}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){this.value=r;this.hasValue=true};e.prototype.end=function t(){};return e}(E);var St=function t(e){if(e===void 0)e=32;this._capacity=e;this._length=0;this._head=0};St.prototype.push=function t(e){var r=this._length;this._checkCapacity(r+1);var n=this._head+r&this._capacity-1;this[n]=e;this._length=r+1};St.prototype.shift=function t(){var e=this._head;var r=this[e];this[e]=void 0;this._head=e+1&this._capacity-1;this._length--;return r};St.prototype.isEmpty=function t(){return this._length===0};St.prototype.length=function t(){return this._length};St.prototype._checkCapacity=function t(e){if(this._capacity<e){this._ensureCapacity(this._capacity<<1)}};St.prototype._ensureCapacity=function t(e){var r=this._capacity;this._capacity=e;var n=this._head+this._length;if(n>r){Wt(this,0,this,r,n&r-1)}};function Wt(t,e,r,n,i){for(var s=0;s<i;++s){r[s+n]=t[s+e];t[s+e]=void 0}}function zt(t,e,r){return Lt(t,[e,r])}var Lt=function(t,e){return e.length===0?l():e.length===1?ut(t,e[0]):new Ft(t,e)};var Ft=function t(e,r){this.f=e;this.sources=r};Ft.prototype.run=function t(e,r){var i=this;var s=this.sources.length;var o=new Array(s);var u=new Array(s);var c=new Array(s);var h=new Gt(this.f,c,u,e);for(var p=void 0,a=0;a<s;++a){c[a]=new St;p=u[a]=new ft(a,h);o[a]=i.sources[a].run(p,r)}return n.disposeAll(o)};var Gt=function(t){function e(e,r,n,i){t.call(this,i);this.f=e;this.sinks=n;this.buffers=r}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(!r.active){this._dispose(e,r.index);return}var n=this.buffers;var i=n[r.index];i.push(r.value);if(i.length()===1){if(!Qt(this.buffers)){return}Ht(this.f,e,n,this.sink);if(Kt(this.buffers,this.sinks)){this.sink.end(e)}}};e.prototype._dispose=function t(e,r){var n=this.buffers[r];if(n.isEmpty()){this.sink.end(e)}};return e}(E);var Ht=function(t,r,n,i){return i.event(r,vt(t,e.map(Jt,n)))};var Jt=function(t){return t.shift()};function Kt(t,e){for(var r=0,n=t.length;r<n;++r){if(t[r].isEmpty()&&!e[r].active){return true}}return false}function Qt(t){for(var e=0,r=t.length;e<r;++e){if(t[e].isEmpty()){return false}}return true}var Ut=function(t){return new Xt(t)};var Xt=function t(e){this.source=e};Xt.prototype.run=function t(e,r){var i=new Yt(e,r);return n.disposeBoth(i,this.source.run(i,r))};var Yt=function t(e,r){this.sink=e;this.scheduler=r;this.current=null;this.ended=false};Yt.prototype.event=function t(e,r){this._disposeCurrent(e);this.current=new Zt(r,e,Infinity,this,this.sink,this.scheduler)};Yt.prototype.end=function t(e){this.ended=true;this._checkEnd(e)};Yt.prototype.error=function t(e,r){this.ended=true;this.sink.error(e,r)};Yt.prototype.dispose=function t(){return this._disposeCurrent(r.currentTime(this.scheduler))};Yt.prototype._disposeCurrent=function t(e){if(this.current!==null){return this.current._dispose(e)}};Yt.prototype._disposeInner=function t(e,r){r._dispose(e);if(r===this.current){this.current=null}};Yt.prototype._checkEnd=function t(e){if(this.ended&&this.current===null){this.sink.end(e)}};Yt.prototype._endInner=function t(e,r){this._disposeInner(e,r);this._checkEnd(e)};Yt.prototype._errorInner=function t(e,r,n){this._disposeInner(e,n);this.sink.error(e,r)};var Zt=function t(e,n,i,s,o,u){this.min=n;this.max=i;this.outer=s;this.sink=o;this.disposable=e.run(this,r.schedulerRelativeTo(n,u))};Zt.prototype.event=function t(e,r){var n=Math.max(0,e+this.min);if(n<this.max){this.sink.event(n,r)}};Zt.prototype.end=function t(e){this.outer._endInner(e+this.min,this)};Zt.prototype.error=function t(e,r){this.outer._errorInner(e+this.min,r,this)};Zt.prototype._dispose=function t(e){n.tryDispose(e+this.min,this.disposable,this.sink)};var $t=function(t,e){return tt.create(t,e)};var te=function(t){return ee(ie,t)};var ee=function(t,e){return new re(t,e)};var re=function t(e,r){this.equals=e;this.source=r};re.prototype.run=function t(e,r){return this.source.run(new ne(this.equals,e),r)};var ne=function(t){function e(e,r){t.call(this,r);this.equals=e;this.value=void 0;this.init=true}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(this.init){this.init=false;this.value=r;this.sink.event(e,r)}else if(!this.equals(this.value,r)){this.value=r;this.sink.event(e,r)}};return e}(E);function ie(t,e){return t===e}var se=function(t,e){return ue(0,t,e)};var oe=function(t,e){return ue(t,Infinity,e)};var ue=function(t,e,r){return e<=t?l():ce(t,e,r)};var ce=function(t,e,r){return r instanceof st?he(t,e,r):r instanceof ae?pe(t,e,r):new ae(t,e,r)};var he=function(t,e,r){return st.create(r.f,ce(t,e,r.source))};function pe(t,e,r){var n=t+r.min;var i=Math.min(e+r.min,r.max);return new ae(n,i,r.source)}var ae=function t(e,r,n){this.source=n;this.min=e;this.max=r};ae.prototype.run=function t(e,r){var n=new P;var i=new fe(this.min,this.max-this.min,e,n);n.setDisposable(this.source.run(i,r));return n};var fe=function(t){function e(e,r,n,i){t.call(this,n);this.skip=e;this.take=r;this.disposable=i}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(this.skip>0){this.skip-=1;return}if(this.take===0){return}this.take-=1;this.sink.event(e,r);if(this.take===0){this.disposable.dispose();this.sink.end(e)}};return e}(E);var ve=function(t,e){return new le(t,e)};var le=function t(e,r){this.p=e;this.source=r};le.prototype.run=function t(e,r){var n=new P;var i=new ye(this.p,e,n);n.setDisposable(this.source.run(i,r));return n};var ye=function(t){function e(e,r,n){t.call(this,r);this.p=e;this.active=true;this.disposable=n}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(!this.active){return}var n=this.p;this.active=n(r);if(this.active){this.sink.event(e,r)}else{this.disposable.dispose();this.sink.end(e)}};return e}(E);var de=function(t,e){return new _e(t,e)};var _e=function t(e,r){this.p=e;this.source=r};_e.prototype.run=function t(e,r){return this.source.run(new ke(this.p,e),r)};var ke=function(t){function e(e,r){t.call(this,r);this.p=e;this.skipping=true}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(this.skipping){var n=this.p;this.skipping=n(r);if(this.skipping){return}}this.sink.event(e,r)};return e}(E);var we=function(t,e){return new me(t,e)};var me=function t(e,r){this.p=e;this.source=r};me.prototype.run=function t(e,r){return this.source.run(new be(this.p,e),r)};var be=function(t){function e(e,r){t.call(this,r);this.p=e;this.skipping=false}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(this.skipping){return}var n=this.p;this.skipping=n(r);this.sink.event(e,r);if(this.skipping){this.sink.end(e)}};return e}(E);var ge=function(t,e){return new je(t,e)};var xe=function(t,e){return new Ie(t,e)};var Oe=function(t,e){return ge(At(t),xe(t,e))};var je=function t(e,r){this.maxSignal=e;this.source=r};je.prototype.run=function t(e,r){var i=new Ae(-Infinity,e);var s=new Ce(this.maxSignal,e,r);var o=this.source.run(new Ee(i,s,e),r);return n.disposeAll([i,s,o])};var Ie=function t(e,r){this.minSignal=e;this.source=r};Ie.prototype.run=function t(e,r){var i=new Te(this.minSignal,e,r);var s=new Ae(Infinity,e);var o=this.source.run(new Ee(i,s,e),r);return n.disposeAll([i,s,o])};var Ae=function(t){function e(e,r){t.call(this,r);this.value=e}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(){};e.prototype.end=function t(){};e.prototype.dispose=function t(){};return e}(E);var Ee=function(t){function e(e,r,n){t.call(this,n);this.min=e;this.max=r}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(e>=this.min.value&&e<this.max.value){this.sink.event(e,r)}};return e}(E);var Te=function(t){function e(e,r,n){t.call(this,r);this.value=Infinity;this.disposable=e.run(this,n)}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e){if(e<this.value){this.value=e}};e.prototype.end=function t(){};e.prototype.dispose=function t(){return this.disposable.dispose()};return e}(E);var Ce=function(t){function e(e,r,n){t.call(this,r);this.value=Infinity;this.disposable=e.run(this,n)}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(e<this.value){this.value=e;this.sink.end(e)}};e.prototype.end=function t(){};e.prototype.dispose=function t(){return this.disposable.dispose()};return e}(E);var qe=function(t,e){return t<=0?e:new De(t,e)};var De=function t(e,r){this.dt=e;this.source=r};De.prototype.run=function t(e,r){var i=new Be(this.dt,e,r);return n.disposeBoth(i,this.source.run(i,r))};var Be=function(t){function e(e,r,n){t.call(this,r);this.dt=e;this.scheduler=n}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.dispose=function t(){var e=this;r.cancelAllTasks(function(t){return t.sink===e.sink},this.scheduler)};e.prototype.event=function t(e,n){r.delay(this.dt,u(n,this.sink),this.scheduler)};e.prototype.end=function t(e){r.delay(this.dt,c(this.sink),this.scheduler)};return e}(E);var Pe=function(t,e){return e instanceof st?Ve(t,e):e instanceof Ne?Me(t,e):new Ne(t,e)};var Ve=function(t,e){return st.create(e.f,Pe(t,e.source))};var Me=function(t,e){return new Ne(Math.max(t,e.period),e.source)};var Ne=function t(e,r){this.period=e;this.source=r};Ne.prototype.run=function t(e,r){return this.source.run(new Re(this.period,e),r)};var Re=function(t){function e(e,r){t.call(this,r);this.time=0;this.period=e}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(e>=this.time){this.time=e+this.period;this.sink.event(e,r)}};return e}(E);var Se=function(t,e){return new We(t,e)};var We=function t(e,r){this.dt=e;this.source=r};We.prototype.run=function t(e,r){return new ze(this.dt,this.source,e,r)};var ze=function t(e,r,n,i){this.dt=e;this.sink=n;this.scheduler=i;this.value=void 0;this.timer=null;this.disposable=r.run(this,i)};ze.prototype.event=function t(e,n){this._clearTimer();this.value=n;this.timer=r.delay(this.dt,u(n,this.sink),this.scheduler)};ze.prototype.end=function t(e){if(this._clearTimer()){this.sink.event(e,this.value);this.value=undefined}this.sink.end(e)};ze.prototype.error=function t(e,r){this._clearTimer();this.sink.error(e,r)};ze.prototype.dispose=function t(){this._clearTimer();this.disposable.dispose()};ze.prototype._clearTimer=function t(){if(this.timer===null){return false}this.timer.dispose();this.timer=null;return true};var Le=function(t){return new Ge(t)};var Fe=e.compose(Le,x);var Ge=function t(e){this.source=e};Ge.prototype.run=function t(e,r){return this.source.run(new He(e,r),r)};var He=function t(e,n){var i=this;this.sink=e;this.scheduler=n;this.queue=Promise.resolve();this._eventBound=function(t){return i.sink.event(r.currentTime(i.scheduler),t)};this._endBound=function(){return i.sink.end(r.currentTime(i.scheduler))};this._errorBound=function(t){return i.sink.error(r.currentTime(i.scheduler),t)}};He.prototype.event=function t(e,r){var n=this;this.queue=this.queue.then(function(){return n._event(r)}).catch(this._errorBound)};He.prototype.end=function t(e){this.queue=this.queue.then(this._endBound).catch(this._errorBound)};He.prototype.error=function t(e,r){var n=this;this.queue=this.queue.then(function(){return n._errorBound(r)}).catch(i)};He.prototype._event=function t(e){return e.then(this._eventBound)};var Je=function t(e){this.sink=e;this.active=true};Je.prototype.event=function t(e,r){if(!this.active){return}this.sink.event(e,r)};Je.prototype.end=function t(e,r){if(!this.active){return}this.disable();this.sink.end(e,r)};Je.prototype.error=function t(e,r){this.disable();this.sink.error(e,r)};Je.prototype.disable=function t(){this.active=false;return this.sink};function Ke(t,e,r){try{r.event(t,e)}catch(e){r.error(t,e)}}function Qe(t,e){try{e.end(t)}catch(r){e.error(t,r)}}var Ue=function(t,e){return new Ze(t,e)};var Xe=function(t){return new Ye(t)};var Ye=function t(e){this.value=e};Ye.prototype.run=function t(e,n){return r.asap(h(this.value,e),n)};var Ze=function t(e,r){this.f=e;this.source=r};Ze.prototype.run=function t(e,r){return new $e(this.f,this.source,e,r)};var $e=function t(e,r,n,i){this.f=e;this.sink=new Je(n);this.scheduler=i;this.disposable=r.run(this,i)};$e.prototype.event=function t(e,r){Ke(e,r,this.sink)};$e.prototype.end=function t(e){Qe(e,this.sink)};$e.prototype.error=function t(e,r){var i=this.sink.disable();n.tryDispose(e,this.disposable,this.sink);this._startNext(e,r,i)};$e.prototype._startNext=function t(e,r,n){try{this.disposable=this._continue(this.f,e,r,n)}catch(t){n.error(e,t)}};$e.prototype._continue=function t(e,r,n,i){return S(i,this.scheduler,z(r,e(n)))};$e.prototype.dispose=function t(){return this.disposable.dispose()};var tr=function(t){return t instanceof er?t:new er(t)};var er=function t(e){this.source=new rr(e)};er.prototype.run=function t(e,r){return this.source.run(e,r)};var rr=function t(e){this.source=e;this.sinks=[];this.disposable=n.disposeNone()};rr.prototype.run=function t(e,r){var i=this.add(e);if(i===1){this.disposable=this.source.run(this,r)}return n.disposeOnce(new nr(this,e))};rr.prototype.dispose=function t(){var e=this.disposable;this.disposable=n.disposeNone();return e.dispose()};rr.prototype.add=function t(r){this.sinks=e.append(r,this.sinks);return this.sinks.length};rr.prototype.remove=function t(r){var n=e.findIndex(r,this.sinks);if(n>=0){this.sinks=e.remove(n,this.sinks)}return this.sinks.length};rr.prototype.event=function t(e,r){var n=this.sinks;if(n.length===1){return n[0].event(e,r)}for(var i=0;i<n.length;++i){Ke(e,r,n[i])}};rr.prototype.end=function t(e){var r=this.sinks;for(var n=0;n<r.length;++n){Qe(e,r[n])}};rr.prototype.error=function t(e,r){var n=this.sinks;for(var i=0;i<n.length;++i){n[i].error(e,r)}};var nr=function t(e,r){this.source=e;this.sink=r};nr.prototype.dispose=function t(){if(this.source.remove(this.sink)===0){this.source.dispose()}};var ir=e.curry3(C);var sr=e.curry2(T);var or=e.curry2(V);var ur=e.curry3(S);var cr=e.curry2(z);var hr=e.curry3(G);var pr=e.curry3(K);var ar=e.curry2($);var fr=e.curry2(ut);var vr=e.curry2(ct);var lr=e.curry2(ht);var yr=e.curry2(kt);var dr=e.curry2(It);var _r=e.curry2(X);var kr=e.curry2(Et);var wr=e.curry2(mt);var mr=e.curry3(bt);var br=e.curry2(Tt);var gr=e.curry3(lt);var xr=e.curry2(yt);var Or=e.curry3(Vt);var jr=e.curry3(zt);var Ir=e.curry2(Lt);var Ar=e.curry2($t);var Er=e.curry2(ee);var Tr=e.curry2(se);var Cr=e.curry2(oe);var qr=e.curry3(ue);var Dr=e.curry2(ve);var Br=e.curry2(de);var Pr=e.curry2(we);var Vr=e.curry2(ge);var Mr=e.curry2(xe);var Nr=e.curry2(Oe);var Rr=e.curry2(qe);var Sr=e.curry2(Pe);var Wr=e.curry2(Se);var zr=e.curry2(Ue);var Lr=e.curry3(o);var Fr=e.curry2(u);var Gr=e.curry2(h);t.zipArrayValues=ir;t.withArrayValues=sr;t.runEffects=or;t.run=ur;t.withLocalTime=cr;t.loop=hr;t.scan=pr;t.startWith=ar;t.map=fr;t.constant=vr;t.tap=lr;t.ap=yr;t.chain=dr;t.join=At;t.continueWith=_r;t.concatMap=kr;t.mergeConcurrently=wr;t.mergeMapConcurrently=mr;t.merge=br;t.mergeArray=Ct;t.combine=gr;t.combineArray=xr;t.sample=Or;t.zip=jr;t.zipArray=Ir;t.filter=Ar;t.skipRepeats=te;t.skipRepeatsWith=Er;t.take=Tr;t.skip=Cr;t.slice=qr;t.takeWhile=Dr;t.skipWhile=Br;t.skipAfter=Pr;t.until=Vr;t.since=Mr;t.during=Nr;t.delay=Rr;t.throttle=Sr;t.debounce=Wr;t.recoverWith=zr;t.throwError=Xe;t.propagateTask=Lr;t.propagateEventTask=Fr;t.propagateErrorTask=Gr;t.propagateEndTask=c;t.empty=l;t.never=_;t.now=x;t.at=m;t.periodic=O;t.newStream=I;t.switchLatest=Ut;t.fromPromise=Fe;t.awaitPromises=Le;t.multicast=tr;t.MulticastSource=rr;Object.defineProperty(t,"__esModule",{value:true})}); | ||
(function(t,e){typeof exports==="object"&&typeof module!=="undefined"?e(exports,require("@most/prelude"),require("@most/scheduler"),require("@most/disposable")):typeof define==="function"&&define.amd?define(["exports","@most/prelude","@most/scheduler","@most/disposable"],e):e(t.mostCore=t.mostCore||{},t.mostPrelude,t.mostScheduler,t.mostDisposable)})(this,function(t,e,r,n){"use strict";function i(t){setTimeout(s,0,t)}function s(t){throw t}var o=function(t,e,r){return new p(t,e,r)};var u=function(t,e){return o(a,t,e)};var c=function(t){return o(f,undefined,t)};var h=function(t,e){return o(v,t,e)};var p=function t(e,r,n){this._run=e;this.value=r;this.sink=n;this.active=true};p.prototype.dispose=function t(){this.active=false};p.prototype.run=function t(e){if(!this.active){return}var t=this._run;t(e,this.value,this.sink)};p.prototype.error=function t(e,r){if(!this.active){return i(r)}this.sink.error(e,r)};var a=function(t,e,r){return r.event(t,e)};var f=function(t,e,r){return r.end(t)};var v=function(t,e,r){return r.error(t,e)};var y=function(){return _};var l=function(t){return t===_};var d=function t(){};d.prototype.run=function t(e,n){return r.asap(c(e),n)};var _=new d;var k=function(){return m};var w=function t(){};w.prototype.run=function t(){return n.disposeNone()};var m=new w;var b=function(t,e){return new g(t,e)};var g=function t(e,r){this.time=e;this.value=r};g.prototype.run=function t(e,n){return r.delay(this.time,o(x,this.value,e),n)};function x(t,e,r){r.event(t,e);r.end(t)}var O=function(t){return b(0,t)};var j=function(t){return new I(t)};var I=function t(e){this.period=e};I.prototype.run=function t(e,n){return r.periodic(this.period,u(undefined,e),n)};var A=function(t){return new E(t)};var E=function t(e){this.run=e};var T=function t(e){this.sink=e};T.prototype.event=function t(e,r){return this.sink.event(e,r)};T.prototype.end=function t(e){return this.sink.end(e)};T.prototype.error=function t(e,r){return this.sink.error(e,r)};var C=function t(e,r){this.p=e;this.source=r};C.prototype.run=function t(e,r){return this.source.run(new q(this.p,e),r)};C.create=function t(e,r){if(r instanceof C){return new C(D(r.p,e),r.source)}return new C(e,r)};var q=function(t){function e(e,r){t.call(this,r);this.p=e}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){var n=this.p;n(r)&&this.sink.event(e,r)};return e}(T);var D=function(t,e){return function(r){return t(r)&&e(r)}};var B=function t(e,r,n){this.p=e;this.f=r;this.source=n};B.prototype.run=function t(e,r){return this.source.run(new P(this.p,this.f,e),r)};var P=function(t){function e(e,r,n){t.call(this,n);this.p=e;this.f=r}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){var n=this.f;var i=this.p;i(r)&&this.sink.event(e,n(r))};return e}(T);var M=function t(e,r){this.f=e;this.source=r};M.prototype.run=function t(e,r){return this.source.run(new N(this.f,e),r)};M.create=function t(r,n){if(n instanceof M){return new M(e.compose(r,n.f),n.source)}if(n instanceof C){return new B(n.p,r,n.source)}return new M(r,n)};var N=function(t){function e(e,r){t.call(this,r);this.f=e}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){var n=this.f;this.sink.event(e,n(r))};return e}(T);var R=function t(){this.disposable=undefined;this.disposed=false};R.prototype.setDisposable=function t(e){if(this.disposable!==void 0){throw new Error("setDisposable called more than once")}this.disposable=e;if(this.disposed){e.dispose()}};R.prototype.dispose=function t(){if(this.disposed){return}this.disposed=true;if(this.disposable!==void 0){this.disposable.dispose()}};var S=function(t,e){return W(0,t,e)};var V=function(t,e){return W(t,Infinity,e)};var W=function(t,e,r){return e<=t||l(r)?y():z(t,e,r)};var z=function(t,e,r){return r instanceof M?L(t,e,r):r instanceof G?F(t,e,r):new G(t,e,r)};var L=function(t,e,r){return M.create(r.f,W(t,e,r.source))};function F(t,e,r){var n=t+r.min;var i=Math.min(e+r.min,r.max);return W(n,i,r.source)}var G=function t(e,r,n){this.source=n;this.min=e;this.max=r};G.prototype.run=function t(e,r){var n=new R;var i=new H(this.min,this.max-this.min,e,n);n.setDisposable(this.source.run(i,r));return n};var H=function(t){function e(e,r,n,i){t.call(this,n);this.skip=e;this.take=r;this.disposable=i}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(this.skip>0){this.skip-=1;return}if(this.take===0){return}this.take-=1;this.sink.event(e,r);if(this.take===0){this.disposable.dispose();this.sink.end(e)}};return e}(T);var J=function(t,e){return new K(t,e)};var K=function t(e,r){this.p=e;this.source=r};K.prototype.run=function t(e,r){var n=new R;var i=new Q(this.p,e,n);n.setDisposable(this.source.run(i,r));return n};var Q=function(t){function e(e,r,n){t.call(this,r);this.p=e;this.active=true;this.disposable=n}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(!this.active){return}var n=this.p;this.active=n(r);if(this.active){this.sink.event(e,r)}else{this.disposable.dispose();this.sink.end(e)}};return e}(T);var U=function(t,e){return new X(t,e)};var X=function t(e,r){this.p=e;this.source=r};X.prototype.run=function t(e,r){return this.source.run(new Y(this.p,e),r)};var Y=function(t){function e(e,r){t.call(this,r);this.p=e;this.skipping=true}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(this.skipping){var n=this.p;this.skipping=n(r);if(this.skipping){return}}this.sink.event(e,r)};return e}(T);var Z=function(t,e){return new $(t,e)};var $=function t(e,r){this.p=e;this.source=r};$.prototype.run=function t(e,r){return this.source.run(new tt(this.p,e),r)};var tt=function(t){function e(e,r){t.call(this,r);this.p=e;this.skipping=false}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(this.skipping){return}var n=this.p;this.skipping=n(r);this.sink.event(e,r);if(this.skipping){this.sink.end(e)}};return e}(T);var et=function(t,e){return rt(nt,t,e)};var rt=function(t,e,r){return l(r)||e.length===0?y():new it(t,e,S(e.length,r))};var nt=function(t,e){return t};var it=function t(e,r,n){this.f=e;this.items=r;this.source=n};it.prototype.run=function t(e,r){return this.source.run(new st(this.f,this.items,e),r)};var st=function(t){function e(e,r,n){t.call(this,n);this.f=e;this.items=r;this.index=0}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){var n=this.f;this.sink.event(e,n(this.items[this.index],r));this.index+=1};return e}(T);var ot=e.curry2(function(t,e){return new Promise(function(r,n){return ut(t,e,r,n)})});function ut(t,e,r,n){var i=new R;var s=new ct(r,n,i);i.setDisposable(t.run(s,e))}var ct=function t(e,r,n){this._end=e;this._error=r;this._disposable=n;this.active=true};ct.prototype.event=function t(e,r){};ct.prototype.end=function t(e){if(!this.active){return}this._dispose(this._error,this._end,undefined)};ct.prototype.error=function t(e,r){this._dispose(this._error,this._error,r)};ct.prototype._dispose=function t(e,r,n){this.active=false;ht(e,r,n,this._disposable)};function ht(t,e,r,n){try{n.dispose()}catch(e){t(e);return}e(r)}var pt=function(t,e,r){return r.run(t,e)};var at=function t(e,r){this.sink=r;this.offset=e};at.prototype.event=function t(e,r){this.sink.event(e+this.offset,r)};at.prototype.error=function t(e,r){this.sink.error(e+this.offset,r)};at.prototype.end=function t(e){this.sink.end(e+this.offset)};var ft=function(t,e){return new vt(t,e)};var vt=function t(e,r){this.origin=e;this.source=r};vt.prototype.run=function t(e,n){return this.source.run(yt(this.origin,e),r.schedulerRelativeTo(this.origin,n))};var yt=function(t,e){return e instanceof at?new at(t+e.offset,e.sink):new at(t,e)};var lt=function(t,e,r){return new dt(t,e,r)};var dt=function t(e,r,n){this.step=e;this.seed=r;this.source=n};dt.prototype.run=function t(e,r){return this.source.run(new _t(this.step,this.seed,e),r)};var _t=function(t){function e(e,r,n){t.call(this,n);this.step=e;this.seed=r}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){var n=this.step(this.seed,r);this.seed=n.seed;this.sink.event(e,n.value)};return e}(T);var kt=function(t,e,r){return new wt(t,e,r)};var wt=function t(e,r,n){this.source=n;this.f=e;this.value=r};wt.prototype.run=function t(e,i){var s=r.asap(u(this.value,e),i);var o=this.source.run(new mt(this.f,this.value,e),i);return n.disposeBoth(s,o)};var mt=function(t){function e(e,r,n){t.call(this,n);this.f=e;this.value=r}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){var n=this.f;this.value=n(this.value,r);this.sink.event(e,this.value)};return e}(T);var bt=function(t,e){return new gt(t,e)};var gt=function t(e,r){this.f=e;this.source=r};gt.prototype.run=function t(e,r){return new xt(this.f,this.source,e,r)};var xt=function(t){function e(e,r,i,s){t.call(this,i);this.f=e;this.scheduler=s;this.active=true;this.disposable=n.disposeOnce(r.run(this,s))}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(!this.active){return}this.sink.event(e,r)};e.prototype.end=function t(e){if(!this.active){return}n.tryDispose(e,this.disposable,this.sink);this._startNext(e,this.sink)};e.prototype._startNext=function t(e,r){try{this.disposable=this._continue(this.f,e,r)}catch(t){r.error(e,t)}};e.prototype._continue=function t(e,r,n){return pt(n,this.scheduler,ft(r,e()))};e.prototype.dispose=function t(){this.active=false;return this.disposable.dispose()};return e}(T);var Ot=function(t,e){return bt(function(){return e},O(t))};var jt=function(t,e){return M.create(t,e)};var It=function(t,e){return jt(function(){return t},e)};var At=function(t,e){return new Et(t,e)};var Et=function t(e,r){this.source=r;this.f=e};Et.prototype.run=function t(e,r){return this.source.run(new Tt(this.f,e),r)};var Tt=function(t){function e(e,r){t.call(this,r);this.f=e}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){var n=this.f;n(r);this.sink.event(e,r)};return e}(T);var Ct=function(t){function e(e,r){t.call(this,r);this.index=e;this.active=true;this.value=undefined}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(!this.active){return}this.value=r;this.sink.event(e,this)};e.prototype.end=function t(e){if(!this.active){return}this.active=false;this.sink.event(e,this)};return e}(T);function qt(t,e){switch(e.length){case 0:return t();case 1:return t(e[0]);case 2:return t(e[0],e[1]);case 3:return t(e[0],e[1],e[2]);case 4:return t(e[0],e[1],e[2],e[3]);case 5:return t(e[0],e[1],e[2],e[3],e[4]);default:return t.apply(void 0,e)}}function Dt(t,e,r){return Bt(t,[e,r])}var Bt=function(t,e){return e.length===0?y():e.length===1?jt(t,e[0]):new Pt(t,e)};var Pt=function t(e,r){this.f=e;this.sources=r};Pt.prototype.run=function t(e,r){var i=this;var s=this.sources.length;var o=new Array(s);var u=new Array(s);var c=new Mt(o,u,e,this.f);for(var h=void 0,p=0;p<s;++p){h=u[p]=new Ct(p,c);o[p]=i.sources[p].run(h,r)}return n.disposeAll(o)};var Mt=function(t){function e(e,r,n,i){t.call(this,n);this.disposables=e;this.sinks=r;this.f=i;var s=r.length;this.awaiting=s;this.values=new Array(s);this.hasValue=new Array(s).fill(false);this.activeCount=r.length}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(!r.active){this._dispose(e,r.index);return}var n=r.index;var i=this._updateReady(n);this.values[n]=r.value;if(i===0){this.sink.event(e,qt(this.f,this.values))}};e.prototype._updateReady=function t(e){if(this.awaiting>0){if(!this.hasValue[e]){this.hasValue[e]=true;this.awaiting-=1}}return this.awaiting};e.prototype._dispose=function t(e,r){n.tryDispose(e,this.disposables[r],this.sink);if(--this.activeCount===0){this.sink.end(e)}};return e}(T);function Nt(t,r){return Dt(e.apply,t,r)}var Rt=function t(){this.head=null;this.length=0};Rt.prototype.add=function t(e){if(this.head!==null){this.head.prev=e;e.next=this.head}this.head=e;++this.length};Rt.prototype.remove=function t(e){--this.length;if(e===this.head){this.head=this.head.next}if(e.next!==null){e.next.prev=e.prev;e.next=null}if(e.prev!==null){e.prev.next=e.next;e.prev=null}};Rt.prototype.isEmpty=function t(){return this.length===0};Rt.prototype.dispose=function t(){if(this.isEmpty()){return Promise.resolve()}var e=[];var r=this.head;this.head=null;this.length=0;while(r!==null){e.push(r.dispose());r=r.next}return Promise.all(e)};var St=function(t,r){return Vt(e.id,t,r)};var Vt=function(t,e,r){return new Wt(t,e,r)};var Wt=function t(e,r,n){this.f=e;this.concurrency=r;this.source=n};Wt.prototype.run=function t(e,r){return new zt(this.f,this.concurrency,this.source,e,r)};var zt=function t(e,r,i,s,o){this.f=e;this.concurrency=r;this.sink=s;this.scheduler=o;this.pending=[];this.current=new Rt;this.disposable=n.disposeOnce(i.run(this,o));this.active=true};zt.prototype.event=function t(e,r){this._addInner(e,r)};zt.prototype._addInner=function t(e,r){if(this.current.length<this.concurrency){this._startInner(e,r)}else{this.pending.push(r)}};zt.prototype._startInner=function t(e,r){try{this._initInner(e,r)}catch(t){this.error(e,t)}};zt.prototype._initInner=function t(e,r){var n=new Ft(e,this,this.sink);n.disposable=Lt(this.f,e,r,n,this.scheduler);this.current.add(n)};zt.prototype.end=function t(e){this.active=false;n.tryDispose(e,this.disposable,this.sink);this._checkEnd(e)};zt.prototype.error=function t(e,r){this.active=false;this.sink.error(e,r)};zt.prototype.dispose=function t(){this.active=false;this.pending.length=0;this.disposable.dispose();this.current.dispose()};zt.prototype._endInner=function t(e,r){this.current.remove(r);n.tryDispose(e,r,this);if(this.pending.length===0){this._checkEnd(e)}else{this._startInner(e,this.pending.shift())}};zt.prototype._checkEnd=function t(e){if(!this.active&&this.current.isEmpty()){this.sink.end(e)}};var Lt=function(t,e,n,i,s){return t(n).run(i,r.schedulerRelativeTo(e,s))};var Ft=function t(e,r,n){this.prev=this.next=null;this.time=e;this.outer=r;this.sink=n;this.disposable=void 0};Ft.prototype.event=function t(e,r){this.sink.event(e+this.time,r)};Ft.prototype.end=function t(e){this.outer._endInner(e+this.time,this)};Ft.prototype.error=function t(e,r){this.outer.error(e+this.time,r)};Ft.prototype.dispose=function t(){return this.disposable.dispose()};var Gt=function(t,e){return Vt(t,Infinity,e)};var Ht=function(t){return St(Infinity,t)};var Jt=function(t,e){return Vt(t,1,e)};function Kt(t,e){return Qt([t,e])}var Qt=function(t){return t.length===0?y():t.length===1?t[0]:Ut(t)};var Ut=function(t){return new Yt(e.reduce(Xt,[],t))};var Xt=function(t,e){return t.concat(e instanceof Yt?e.sources:e)};var Yt=function t(e){this.sources=e};Yt.prototype.run=function t(e,r){var i=this;var s=this.sources.length;var o=new Array(s);var u=new Array(s);var c=new Zt(o,u,e);for(var h=void 0,p=0;p<s;++p){h=u[p]=new Ct(p,c);o[p]=i.sources[p].run(h,r)}return n.disposeAll(o)};var Zt=function(t){function e(e,r,n){t.call(this,n);this.disposables=e;this.activeCount=r.length}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(!r.active){this._dispose(e,r.index);return}this.sink.event(e,r.value)};e.prototype._dispose=function t(e,r){n.tryDispose(e,this.disposables[r],this.sink);if(--this.activeCount===0){this.sink.end(e)}};return e}(T);var $t=function(t,e){return te(function(t,e){return e},t,e)};var te=function(t,e,r){return new ee(t,e,r)};var ee=function t(e,r,n){this.f=e;this.values=r;this.sampler=n};ee.prototype.run=function t(e,r){var i=new re(this.f,e);var s=this.values.run(i.latest,r);var o=this.sampler.run(i,r);return n.disposeBoth(o,s)};var re=function(t){function e(e,r){t.call(this,r);this.f=e;this.latest=new ne(this)}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(this.latest.hasValue){var n=this.f;this.sink.event(e,n(this.latest.value,r))}};return e}(T);var ne=function(t){function e(e){t.call(this,e);this.hasValue=false}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){this.value=r;this.hasValue=true};e.prototype.end=function t(){};return e}(T);var ie=function t(e){if(e===void 0)e=32;this._capacity=e;this._length=0;this._head=0};ie.prototype.push=function t(e){var r=this._length;this._checkCapacity(r+1);var n=this._head+r&this._capacity-1;this[n]=e;this._length=r+1};ie.prototype.shift=function t(){var e=this._head;var r=this[e];this[e]=void 0;this._head=e+1&this._capacity-1;this._length--;return r};ie.prototype.isEmpty=function t(){return this._length===0};ie.prototype.length=function t(){return this._length};ie.prototype._checkCapacity=function t(e){if(this._capacity<e){this._ensureCapacity(this._capacity<<1)}};ie.prototype._ensureCapacity=function t(e){var r=this._capacity;this._capacity=e;var n=this._head+this._length;if(n>r){se(this,0,this,r,n&r-1)}};function se(t,e,r,n,i){for(var s=0;s<i;++s){r[s+n]=t[s+e];t[s+e]=void 0}}function oe(t,e,r){return ue(t,[e,r])}var ue=function(t,e){return e.length===0?y():e.length===1?jt(t,e[0]):new ce(t,e)};var ce=function t(e,r){this.f=e;this.sources=r};ce.prototype.run=function t(e,r){var i=this;var s=this.sources.length;var o=new Array(s);var u=new Array(s);var c=new Array(s);var h=new he(this.f,c,u,e);for(var p=void 0,a=0;a<s;++a){c[a]=new ie;p=u[a]=new Ct(a,h);o[a]=i.sources[a].run(p,r)}return n.disposeAll(o)};var he=function(t){function e(e,r,n,i){t.call(this,i);this.f=e;this.sinks=n;this.buffers=r}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(!r.active){this._dispose(e,r.index);return}var n=this.buffers;var i=n[r.index];i.push(r.value);if(i.length()===1){if(!ve(this.buffers)){return}pe(this.f,e,n,this.sink);if(fe(this.buffers,this.sinks)){this.sink.end(e)}}};e.prototype._dispose=function t(e,r){var n=this.buffers[r];if(n.isEmpty()){this.sink.end(e)}};return e}(T);var pe=function(t,r,n,i){return i.event(r,qt(t,e.map(ae,n)))};var ae=function(t){return t.shift()};function fe(t,e){for(var r=0,n=t.length;r<n;++r){if(t[r].isEmpty()&&!e[r].active){return true}}return false}function ve(t){for(var e=0,r=t.length;e<r;++e){if(t[e].isEmpty()){return false}}return true}var ye=function(t){return new le(t)};var le=function t(e){this.source=e};le.prototype.run=function t(e,r){var i=new de(e,r);return n.disposeBoth(i,this.source.run(i,r))};var de=function t(e,r){this.sink=e;this.scheduler=r;this.current=null;this.ended=false};de.prototype.event=function t(e,r){this._disposeCurrent(e);this.current=new _e(r,e,Infinity,this,this.sink,this.scheduler)};de.prototype.end=function t(e){this.ended=true;this._checkEnd(e)};de.prototype.error=function t(e,r){this.ended=true;this.sink.error(e,r)};de.prototype.dispose=function t(){return this._disposeCurrent(r.currentTime(this.scheduler))};de.prototype._disposeCurrent=function t(e){if(this.current!==null){return this.current._dispose(e)}};de.prototype._disposeInner=function t(e,r){r._dispose(e);if(r===this.current){this.current=null}};de.prototype._checkEnd=function t(e){if(this.ended&&this.current===null){this.sink.end(e)}};de.prototype._endInner=function t(e,r){this._disposeInner(e,r);this._checkEnd(e)};de.prototype._errorInner=function t(e,r,n){this._disposeInner(e,n);this.sink.error(e,r)};var _e=function t(e,n,i,s,o,u){this.min=n;this.max=i;this.outer=s;this.sink=o;this.disposable=e.run(this,r.schedulerRelativeTo(n,u))};_e.prototype.event=function t(e,r){var n=Math.max(0,e+this.min);if(n<this.max){this.sink.event(n,r)}};_e.prototype.end=function t(e){this.outer._endInner(e+this.min,this)};_e.prototype.error=function t(e,r){this.outer._errorInner(e+this.min,r,this)};_e.prototype._dispose=function t(e){n.tryDispose(e+this.min,this.disposable,this.sink)};var ke=function(t,e){return C.create(t,e)};var we=function(t){return me(xe,t)};var me=function(t,e){return new be(t,e)};var be=function t(e,r){this.equals=e;this.source=r};be.prototype.run=function t(e,r){return this.source.run(new ge(this.equals,e),r)};var ge=function(t){function e(e,r){t.call(this,r);this.equals=e;this.value=void 0;this.init=true}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(this.init){this.init=false;this.value=r;this.sink.event(e,r)}else if(!this.equals(this.value,r)){this.value=r;this.sink.event(e,r)}};return e}(T);function xe(t,e){return t===e}var Oe=function(t,e){return new Ae(t,e)};var je=function(t,e){return new Ee(t,e)};var Ie=function(t,e){return Oe(Ht(t),je(t,e))};var Ae=function t(e,r){this.maxSignal=e;this.source=r};Ae.prototype.run=function t(e,r){var i=new Te(-Infinity,e);var s=new De(this.maxSignal,e,r);var o=this.source.run(new Ce(i,s,e),r);return n.disposeAll([i,s,o])};var Ee=function t(e,r){this.minSignal=e;this.source=r};Ee.prototype.run=function t(e,r){var i=new qe(this.minSignal,e,r);var s=new Te(Infinity,e);var o=this.source.run(new Ce(i,s,e),r);return n.disposeAll([i,s,o])};var Te=function(t){function e(e,r){t.call(this,r);this.value=e}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(){};e.prototype.end=function t(){};e.prototype.dispose=function t(){};return e}(T);var Ce=function(t){function e(e,r,n){t.call(this,n);this.min=e;this.max=r}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(e>=this.min.value&&e<this.max.value){this.sink.event(e,r)}};return e}(T);var qe=function(t){function e(e,r,n){t.call(this,r);this.value=Infinity;this.disposable=e.run(this,n)}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e){if(e<this.value){this.value=e}};e.prototype.end=function t(){};e.prototype.dispose=function t(){return this.disposable.dispose()};return e}(T);var De=function(t){function e(e,r,n){t.call(this,r);this.value=Infinity;this.disposable=e.run(this,n)}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(e<this.value){this.value=e;this.sink.end(e)}};e.prototype.end=function t(){};e.prototype.dispose=function t(){return this.disposable.dispose()};return e}(T);var Be=function(t,e){return t<=0?e:new Pe(t,e)};var Pe=function t(e,r){this.dt=e;this.source=r};Pe.prototype.run=function t(e,r){var i=new Me(this.dt,e,r);return n.disposeBoth(i,this.source.run(i,r))};var Me=function(t){function e(e,r,n){t.call(this,r);this.dt=e;this.scheduler=n}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.dispose=function t(){var e=this;r.cancelAllTasks(function(t){return t.sink===e.sink},this.scheduler)};e.prototype.event=function t(e,n){r.delay(this.dt,u(n,this.sink),this.scheduler)};e.prototype.end=function t(e){r.delay(this.dt,c(this.sink),this.scheduler)};return e}(T);var Ne=function(t,e){return e instanceof M?Re(t,e):e instanceof Ve?Se(t,e):new Ve(t,e)};var Re=function(t,e){return M.create(e.f,Ne(t,e.source))};var Se=function(t,e){return new Ve(Math.max(t,e.period),e.source)};var Ve=function t(e,r){this.period=e;this.source=r};Ve.prototype.run=function t(e,r){return this.source.run(new We(this.period,e),r)};var We=function(t){function e(e,r){t.call(this,r);this.time=0;this.period=e}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.event=function t(e,r){if(e>=this.time){this.time=e+this.period;this.sink.event(e,r)}};return e}(T);var ze=function(t,e){return new Le(t,e)};var Le=function t(e,r){this.dt=e;this.source=r};Le.prototype.run=function t(e,r){return new Fe(this.dt,this.source,e,r)};var Fe=function t(e,r,n,i){this.dt=e;this.sink=n;this.scheduler=i;this.value=void 0;this.timer=null;this.disposable=r.run(this,i)};Fe.prototype.event=function t(e,n){this._clearTimer();this.value=n;this.timer=r.delay(this.dt,u(n,this.sink),this.scheduler)};Fe.prototype.end=function t(e){if(this._clearTimer()){this.sink.event(e,this.value);this.value=undefined}this.sink.end(e)};Fe.prototype.error=function t(e,r){this._clearTimer();this.sink.error(e,r)};Fe.prototype.dispose=function t(){this._clearTimer();this.disposable.dispose()};Fe.prototype._clearTimer=function t(){if(this.timer===null){return false}this.timer.dispose();this.timer=null;return true};var Ge=function(t){return new Je(t)};var He=e.compose(Ge,O);var Je=function t(e){this.source=e};Je.prototype.run=function t(e,r){return this.source.run(new Ke(e,r),r)};var Ke=function t(e,n){var i=this;this.sink=e;this.scheduler=n;this.queue=Promise.resolve();this._eventBound=function(t){return i.sink.event(r.currentTime(i.scheduler),t)};this._endBound=function(){return i.sink.end(r.currentTime(i.scheduler))};this._errorBound=function(t){return i.sink.error(r.currentTime(i.scheduler),t)}};Ke.prototype.event=function t(e,r){var n=this;this.queue=this.queue.then(function(){return n._event(r)}).catch(this._errorBound)};Ke.prototype.end=function t(e){this.queue=this.queue.then(this._endBound).catch(this._errorBound)};Ke.prototype.error=function t(e,r){var n=this;this.queue=this.queue.then(function(){return n._errorBound(r)}).catch(i)};Ke.prototype._event=function t(e){return e.then(this._eventBound)};var Qe=function t(e){this.sink=e;this.active=true};Qe.prototype.event=function t(e,r){if(!this.active){return}this.sink.event(e,r)};Qe.prototype.end=function t(e,r){if(!this.active){return}this.disable();this.sink.end(e,r)};Qe.prototype.error=function t(e,r){this.disable();this.sink.error(e,r)};Qe.prototype.disable=function t(){this.active=false;return this.sink};function Ue(t,e,r){try{r.event(t,e)}catch(e){r.error(t,e)}}function Xe(t,e){try{e.end(t)}catch(r){e.error(t,r)}}var Ye=function(t,e){return new tr(t,e)};var Ze=function(t){return new $e(t)};var $e=function t(e){this.value=e};$e.prototype.run=function t(e,n){return r.asap(h(this.value,e),n)};var tr=function t(e,r){this.f=e;this.source=r};tr.prototype.run=function t(e,r){return new er(this.f,this.source,e,r)};var er=function t(e,r,n,i){this.f=e;this.sink=new Qe(n);this.scheduler=i;this.disposable=r.run(this,i)};er.prototype.event=function t(e,r){Ue(e,r,this.sink)};er.prototype.end=function t(e){Xe(e,this.sink)};er.prototype.error=function t(e,r){var i=this.sink.disable();n.tryDispose(e,this.disposable,this.sink);this._startNext(e,r,i)};er.prototype._startNext=function t(e,r,n){try{this.disposable=this._continue(this.f,e,r,n)}catch(t){n.error(e,t)}};er.prototype._continue=function t(e,r,n,i){return pt(i,this.scheduler,ft(r,e(n)))};er.prototype.dispose=function t(){return this.disposable.dispose()};var rr=function(t){return t instanceof nr?t:new nr(t)};var nr=function t(e){this.source=new ir(e)};nr.prototype.run=function t(e,r){return this.source.run(e,r)};var ir=function t(e){this.source=e;this.sinks=[];this.disposable=n.disposeNone()};ir.prototype.run=function t(e,r){var i=this.add(e);if(i===1){this.disposable=this.source.run(this,r)}return n.disposeOnce(new sr(this,e))};ir.prototype.dispose=function t(){var e=this.disposable;this.disposable=n.disposeNone();return e.dispose()};ir.prototype.add=function t(r){this.sinks=e.append(r,this.sinks);return this.sinks.length};ir.prototype.remove=function t(r){var n=e.findIndex(r,this.sinks);if(n>=0){this.sinks=e.remove(n,this.sinks)}return this.sinks.length};ir.prototype.event=function t(e,r){var n=this.sinks;if(n.length===1){return n[0].event(e,r)}for(var i=0;i<n.length;++i){Ue(e,r,n[i])}};ir.prototype.end=function t(e){var r=this.sinks;for(var n=0;n<r.length;++n){Xe(e,r[n])}};ir.prototype.error=function t(e,r){var n=this.sinks;for(var i=0;i<n.length;++i){n[i].error(e,r)}};var sr=function t(e,r){this.source=e;this.sink=r};sr.prototype.dispose=function t(){if(this.source.remove(this.sink)===0){this.source.dispose()}};var or=e.curry3(rt);var ur=e.curry2(et);var cr=e.curry2(ot);var hr=e.curry3(pt);var pr=e.curry2(ft);var ar=e.curry3(lt);var fr=e.curry3(kt);var vr=e.curry2(Ot);var yr=e.curry2(jt);var lr=e.curry2(It);var dr=e.curry2(At);var _r=e.curry2(Nt);var kr=e.curry2(Gt);var wr=e.curry2(bt);var mr=e.curry2(Jt);var br=e.curry2(St);var gr=e.curry3(Vt);var xr=e.curry2(Kt);var Or=e.curry3(Dt);var jr=e.curry2(Bt);var Ir=e.curry2($t);var Ar=e.curry3(te);var Er=e.curry3(oe);var Tr=e.curry2(ue);var Cr=e.curry2(ke);var qr=e.curry2(me);var Dr=e.curry2(S);var Br=e.curry2(V);var Pr=e.curry3(W);var Mr=e.curry2(J);var Nr=e.curry2(U);var Rr=e.curry2(Z);var Sr=e.curry2(Oe);var Vr=e.curry2(je);var Wr=e.curry2(Ie);var zr=e.curry2(Be);var Lr=e.curry2(Ne);var Fr=e.curry2(ze);var Gr=e.curry2(Ye);var Hr=e.curry3(o);var Jr=e.curry2(u);var Kr=e.curry2(h);t.zipItems=or;t.withItems=ur;t.runEffects=cr;t.run=hr;t.withLocalTime=pr;t.loop=ar;t.scan=fr;t.startWith=vr;t.map=yr;t.constant=lr;t.tap=dr;t.ap=_r;t.chain=kr;t.join=Ht;t.continueWith=wr;t.concatMap=mr;t.mergeConcurrently=br;t.mergeMapConcurrently=gr;t.merge=xr;t.mergeArray=Qt;t.combine=Or;t.combineArray=jr;t.sample=Ir;t.snapshot=Ar;t.zip=Er;t.zipArray=Tr;t.filter=Cr;t.skipRepeats=we;t.skipRepeatsWith=qr;t.take=Dr;t.skip=Br;t.slice=Pr;t.takeWhile=Mr;t.skipWhile=Nr;t.skipAfter=Rr;t.until=Sr;t.since=Vr;t.during=Wr;t.delay=zr;t.throttle=Lr;t.debounce=Fr;t.recoverWith=Gr;t.throwError=Ze;t.propagateTask=Hr;t.propagateEventTask=Jr;t.propagateErrorTask=Kr;t.propagateEndTask=c;t.empty=y;t.never=k;t.now=O;t.at=b;t.periodic=j;t.newStream=A;t.switchLatest=ye;t.fromPromise=He;t.awaitPromises=Ge;t.multicast=rr;t.MulticastSource=ir;Object.defineProperty(t,"__esModule",{value:true})}); |
{ | ||
"name": "@most/core", | ||
"version": "0.14.0", | ||
"version": "0.15.0", | ||
"description": "Reactive programming with lean, functions-only, curried, tree-shakeable API", | ||
@@ -5,0 +5,0 @@ "typings": "type-definitions/most.d.ts", |
@@ -19,5 +19,5 @@ export * from './runEffects'; | ||
export * from './combinator/promises'; | ||
export * from './combinator/sample'; | ||
export * from './combinator/scan'; | ||
export * from './combinator/slice'; | ||
export * from './combinator/snapshot'; | ||
export * from './combinator/startWith'; | ||
@@ -27,5 +27,5 @@ export * from './combinator/switch'; | ||
export * from './combinator/transform'; | ||
export * from './combinator/withLocalTime'; | ||
export * from './combinator/zip'; | ||
export * from './combinator/withArrayValues'; | ||
export * from './combinator/withLocalTime'; | ||
export * from './combinator/zipItems'; | ||
@@ -32,0 +32,0 @@ export * from './source/never'; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
470161
4263