diff --git a/dist/most.min.js b/dist/most.min.js index 0deb9d1d..f557e750 100644 --- a/dist/most.min.js +++ b/dist/most.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.most={})}(this,function(t){"use strict";function e(t){this.source=t}function n(t,e){var n=e.length,i=new Array(n+1);i[0]=t;for(var r=0;r= 0");var n=e.length;return 0===t||0===n?e:t>=n?[]:o(t,e,n-t)}function o(t,e,n){for(var i=new Array(n),r=0;r= 0");for(var i=n.length,r=new Array(i),o=0;o= 0");var n=e.length;return 0===n||t>=n?e:1===n?[]:c(t,e,n-1)}function c(t,e,n){var i,r=new Array(n);for(i=0;i=0&&o.active&&(o.time=o.time+o.period,ft(o,n)))}return n}function ft(t,e){var n=e.length;if(0!==n){var i=dt(t.time,e);i>=n?e.push(lt(t.time,[t])):t.time===e[i].time?e[i].events.push(t):e.splice(i,0,lt(t.time,[t]))}else e.push(lt(t.time,[t]))}function at(t,e){e.events=f(t,e.events)}function dt(t,e){for(var n,i,r=0,o=e.length;r=0&&e=0)return this.tasks[e].events.splice(n,1),!0}return!1},pt.prototype.removeAll=function(t){for(var e=this,n=0,i=this.tasks.length;n1){for(var o=new Array(r),s=0;s0&&(this.hasValue[t]||(this.hasValue[t]=!0,this.awaiting-=1)),this.awaiting},Re.prototype.end=function(t,e){w(t,this.disposables[e.index],this.sink),0==--this.activeCount&&this.sink.end(t,e.value)},Le.prototype.run=function(t,e){var n=this.transducer(new Ne(t));return this.source.run(new Ce(Se(n),t),e)},Ce.prototype.event=function(t,e){var n=this.xf.step(t,e);return this.xf.isReduced(n)?this.sink.end(t,this.xf.getResult(n)):n},Ce.prototype.end=function(t,e){return this.xf.result(e)},Ce.prototype.error=function(t,e){return this.sink.error(t,e)},Ne.prototype["@@transducer/init"]=Ne.prototype.init=function(){},Ne.prototype["@@transducer/step"]=Ne.prototype.step=function(t,e){return isNaN(t)||(this.time=Math.max(t,this.time)),this.sink.event(this.time,e)},Ne.prototype["@@transducer/result"]=Ne.prototype.result=function(t){return this.sink.end(this.time,t)},qe.prototype.step=function(t,e){return this.tx["@@transducer/step"](t,e)},qe.prototype.result=function(t){return this.tx["@@transducer/result"](t)},qe.prototype.isReduced=function(t){return null!=t&&t["@@transducer/reduced"]},qe.prototype.getResult=function(t){return t["@@transducer/value"]},Be.prototype.step=function(t,e){return this.tx.step(t,e)},Be.prototype.result=function(t){return this.tx.result(t)},Be.prototype.isReduced=function(t){return null!=t&&t.__transducers_reduced__},Be.prototype.getResult=function(t){return t.value},je.prototype.add=function(t){null!==this.head&&(this.head.prev=t,t.next=this.head),this.head=t,++this.length},je.prototype.remove=function(t){--this.length,t===this.head&&(this.head=this.head.next),null!==t.next&&(t.next.prev=t.prev,t.next=null),null!==t.prev&&(t.prev.next=t.next,t.prev=null)},je.prototype.isEmpty=function(){return 0===this.length},je.prototype.dispose=function(){if(this.isEmpty())return Promise.resolve();var t=[],e=this.head;for(this.head=null,this.length=0;null!==e;)t.push(e.dispose()),e=e.next;return Promise.all(t)},Ue.prototype.run=function(t,e){return new ze(this.f,this.concurrency,this.source,t,e)},ze.prototype.event=function(t,e){this._addInner(t,e)},ze.prototype._addInner=function(t,e){this.current.lengthe&&pn(this,0,this,e,n&e-1)};var Oi=u,Fi=s;an.prototype.run=function(t,e){for(var n,i=this,r=this.sources.length,o=new Array(r),s=new Array(r),u=new Array(r),h=new dn(this.f,u,s,t),p=0;p0?this.skip-=1:0!==this.take&&(this.take-=1,this.sink.event(t,e),0===this.take&&(this.disposable.dispose(),this.sink.end(t,e)))},Bn.prototype.run=function(t,e){var n=x(),i=new jn(this.p,t,n);return n.setDisposable(this.source.run(i,e)),n},jn.prototype.end=Ct.prototype.end,jn.prototype.error=Ct.prototype.error,jn.prototype.event=function(t,e){if(this.active){var n=this.p;this.active=n(e),this.active?this.sink.event(t,e):(this.disposable.dispose(),this.sink.end(t,e))}},Vn.prototype.run=function(t,e){return this.source.run(new Un(this.p,t),e)},Un.prototype.end=Ct.prototype.end,Un.prototype.error=Ct.prototype.error,Un.prototype.event=function(t,e){if(this.skipping){var n=this.p;if(this.skipping=n(e),this.skipping)return}this.sink.event(t,e)},On.prototype.run=function(t,e){return this.source.run(new Fn(this.p,t),e)},Fn.prototype.event=function(t,e){if(!this.skipping){var n=this.p;this.skipping=n(e),this.sink.event(t,e),this.skipping&&this.sink.end(t,e)}},Fn.prototype.end=Ct.prototype.end,Fn.prototype.error=Ct.prototype.error,Kn.prototype.run=function(t,e){var n=new Xn(-1/0,t),i=new $n(this.maxSignal,t,e);return _([n,i,this.source.run(new Yn(n,i,t),e)])},Qn.prototype.run=function(t,e){var n=new Zn(this.minSignal,t,e),i=new Xn(1/0,t);return _([n,i,this.source.run(new Yn(n,i,t),e)])},Xn.prototype.error=Ct.prototype.error,Xn.prototype.event=ti,Xn.prototype.end=ti,Xn.prototype.dispose=ti,Yn.prototype.event=function(t,e){t>=this.min.value&&t=this.time&&(this.time=t+this.period,this.sink.event(t,e))},ai.prototype.end=Ct.prototype.end,ai.prototype.error=Ct.prototype.error,li.prototype.run=function(t,e){return new yi(this.dt,this.source,t,e)},yi.prototype.event=function(t,e){this._clearTimer(),this.value=e,this.timer=this.scheduler.delay(this.dt,M.event(e,this.sink))},yi.prototype.end=function(t,e){this._clearTimer()&&(this.sink.event(t,this.value),this.value=void 0),this.sink.end(t,e)},yi.prototype.error=function(t,e){this._clearTimer(),this.sink.error(t,e)},yi.prototype.dispose=function(){return this._clearTimer(),this.disposable.dispose()},yi.prototype._clearTimer=function(){return null!==this.timer&&(this.timer.dispose(),this.timer=null,!0)},wi.prototype.run=function(t,e){return this.source.run(new ki(t,e),e)},ki.prototype.event=function(t,e){var n=this;this.queue=this.queue.then(function(){return n._event(e)}).catch(this._errorBound)},ki.prototype.end=function(t,e){var n=this;this.queue=this.queue.then(function(){return n._end(e)}).catch(this._errorBound)},ki.prototype.error=function(t,e){var n=this;this.queue=this.queue.then(function(){return n._errorBound(e)}).catch(T)},ki.prototype._event=function(t){return t.then(this._eventBound)},ki.prototype._end=function(t){return Promise.resolve(t).then(this._endBound)},mi.prototype.event=function(t,e){this.active&&this.sink.event(t,e)},mi.prototype.end=function(t,e){this.active&&(this.disable(),this.sink.end(t,e))},mi.prototype.error=function(t,e){this.disable(),this.sink.error(t,e)},mi.prototype.disable=function(){return this.active=!1,this.sink};var Gi=_i;bi.prototype.run=function(t,e){return e.asap(new M(gi,this.value,t))},xi.prototype.run=function(t,e){return new Ei(this.f,this.source,t,e)},Ei.prototype.event=function(t,e){K(t,e,this.sink)},Ei.prototype.end=function(t,e){Q(t,e,this.sink)},Ei.prototype.error=function(t,e){var n=this.sink.disable();w(t,this.disposable,this.sink),this._startNext(t,e,n)},Ei.prototype._startNext=function(t,e,n){try{this.disposable=this._continue(this.f,e,n)}catch(e){n.error(t,e)}},Ei.prototype._continue=function(t,e,n){return t(e).source.run(n,this.scheduler)},Ei.prototype.dispose=function(){return this.disposable.dispose()};var Hi=function(t,e){this.source=t,this.sink=e,this.disposed=!1};Hi.prototype.dispose=function(){if(!this.disposed)return this.disposed=!0,0===this.source.remove(this.sink)&&this.source._dispose()};var Ji=function(t){return t.dispose()},Ki={dispose:function(){}},Qi=function(t){this.source=t,this.sinks=[],this._disposable=Ki};Qi.prototype.run=function(t,e){return 1===this.add(t)&&(this._disposable=this.source.run(this,e)),new Hi(this,t)},Qi.prototype._dispose=function(){var t=this._disposable;return this._disposable=Ki,Promise.resolve(t).then(Ji)},Qi.prototype.add=function(t){return this.sinks=i(t,this.sinks),this.sinks.length},Qi.prototype.remove=function(t){var e=a(t,this.sinks);return e>=0&&(this.sinks=p(e,this.sinks)),this.sinks.length},Qi.prototype.event=function(t,e){var n=this.sinks;if(1===n.length)return n[0].event(t,e);for(var i=0;i= 0");var n=e.length;return 0===t||0===n?e:t>=n?[]:o(t,e,n-t)}function o(t,e,n){for(var i=new Array(n),r=0;r= 0");for(var i=n.length,r=new Array(i),o=0;o= 0");var n=e.length;return 0===n||t>=n?e:1===n?[]:c(t,e,n-1)}function c(t,e,n){var i,r=new Array(n);for(i=0;i=0&&o.active&&(o.time=o.time+o.period,ft(o,n)))}return n}function ft(t,e){var n=e.length;if(0!==n){var i=dt(t.time,e);i>=n?e.push(lt(t.time,[t])):t.time===e[i].time?e[i].events.push(t):e.splice(i,0,lt(t.time,[t]))}else e.push(lt(t.time,[t]))}function at(t,e){e.events=f(t,e.events)}function dt(t,e){for(var n,i,r=0,o=e.length;r=0&&e=0)return this.tasks[e].events.splice(n,1),!0}return!1},pt.prototype.removeAll=function(t){for(var e=this,n=0,i=this.tasks.length;n1){for(var o=new Array(r),s=0;s0&&(this.hasValue[t]||(this.hasValue[t]=!0,this.awaiting-=1)),this.awaiting},Re.prototype.end=function(t,e){w(t,this.disposables[e.index],this.sink),0==--this.activeCount&&this.sink.end(t,e.value)},Le.prototype.run=function(t,e){var n=this.transducer(new Ne(t));return this.source.run(new Ce(Se(n),t),e)},Ce.prototype.event=function(t,e){var n=this.xf.step(t,e);return this.xf.isReduced(n)?this.sink.end(t,this.xf.getResult(n)):n},Ce.prototype.end=function(t,e){return this.xf.result(e)},Ce.prototype.error=function(t,e){return this.sink.error(t,e)},Ne.prototype["@@transducer/init"]=Ne.prototype.init=function(){},Ne.prototype["@@transducer/step"]=Ne.prototype.step=function(t,e){return isNaN(t)||(this.time=Math.max(t,this.time)),this.sink.event(this.time,e)},Ne.prototype["@@transducer/result"]=Ne.prototype.result=function(t){return this.sink.end(this.time,t)},qe.prototype.step=function(t,e){return this.tx["@@transducer/step"](t,e)},qe.prototype.result=function(t){return this.tx["@@transducer/result"](t)},qe.prototype.isReduced=function(t){return null!=t&&t["@@transducer/reduced"]},qe.prototype.getResult=function(t){return t["@@transducer/value"]},Be.prototype.step=function(t,e){return this.tx.step(t,e)},Be.prototype.result=function(t){return this.tx.result(t)},Be.prototype.isReduced=function(t){return null!=t&&t.__transducers_reduced__},Be.prototype.getResult=function(t){return t.value},je.prototype.add=function(t){null!==this.head&&(this.head.prev=t,t.next=this.head),this.head=t,++this.length},je.prototype.remove=function(t){--this.length,t===this.head&&(this.head=this.head.next),null!==t.next&&(t.next.prev=t.prev,t.next=null),null!==t.prev&&(t.prev.next=t.next,t.prev=null)},je.prototype.isEmpty=function(){return 0===this.length},je.prototype.dispose=function(){if(this.isEmpty())return Promise.resolve();var t=[],e=this.head;for(this.head=null,this.length=0;null!==e;)t.push(e.dispose()),e=e.next;return Promise.all(t)},Ue.prototype.run=function(t,e){return new ze(this.f,this.concurrency,this.source,t,e)},ze.prototype.event=function(t,e){this._addInner(t,e)},ze.prototype._addInner=function(t,e){this.current.lengthe&&pn(this,0,this,e,n&e-1)};var Oi=u,Fi=s;an.prototype.run=function(t,e){for(var n,i=this,r=this.sources.length,o=new Array(r),s=new Array(r),u=new Array(r),h=new dn(this.f,u,s,t),p=0;p0?this.skip-=1:0!==this.take&&(this.take-=1,this.sink.event(t,e),0===this.take&&(this.disposable.dispose(),this.sink.end(t,e)))},Bn.prototype.run=function(t,e){var n=x(),i=new jn(this.p,t,n);return n.setDisposable(this.source.run(i,e)),n},jn.prototype.end=Ct.prototype.end,jn.prototype.error=Ct.prototype.error,jn.prototype.event=function(t,e){if(this.active){var n=this.p;this.active=n(e),this.active?this.sink.event(t,e):(this.disposable.dispose(),this.sink.end(t,e))}},Vn.prototype.run=function(t,e){return this.source.run(new Un(this.p,t),e)},Un.prototype.end=Ct.prototype.end,Un.prototype.error=Ct.prototype.error,Un.prototype.event=function(t,e){if(this.skipping){var n=this.p;if(this.skipping=n(e),this.skipping)return}this.sink.event(t,e)},On.prototype.run=function(t,e){return this.source.run(new Fn(this.p,t),e)},Fn.prototype.event=function(t,e){if(!this.skipping){var n=this.p;this.skipping=n(e),this.sink.event(t,e),this.skipping&&this.sink.end(t,e)}},Fn.prototype.end=Ct.prototype.end,Fn.prototype.error=Ct.prototype.error,Kn.prototype.run=function(t,e){var n=new Xn(-1/0,t),i=new $n(this.maxSignal,t,e);return _([n,i,this.source.run(new Yn(n,i,t),e)])},Qn.prototype.run=function(t,e){var n=new Zn(this.minSignal,t,e),i=new Xn(1/0,t);return _([n,i,this.source.run(new Yn(n,i,t),e)])},Xn.prototype.error=Ct.prototype.error,Xn.prototype.event=ti,Xn.prototype.end=ti,Xn.prototype.dispose=ti,Yn.prototype.event=function(t,e){t>=this.min.value&&t=this.time&&(this.time=t+this.period,this.sink.event(t,e))},ai.prototype.end=Ct.prototype.end,ai.prototype.error=Ct.prototype.error,li.prototype.run=function(t,e){return new yi(this.dt,this.source,t,e)},yi.prototype.event=function(t,e){this._clearTimer(),this.value=e,this.timer=this.scheduler.delay(this.dt,M.event(e,this.sink))},yi.prototype.end=function(t,e){this._clearTimer()&&(this.sink.event(t,this.value),this.value=void 0),this.sink.end(t,e)},yi.prototype.error=function(t,e){this._clearTimer(),this.sink.error(t,e)},yi.prototype.dispose=function(){return this._clearTimer(),this.disposable.dispose()},yi.prototype._clearTimer=function(){return null!==this.timer&&(this.timer.dispose(),this.timer=null,!0)},wi.prototype.run=function(t,e){return this.source.run(new ki(t,e),e)},ki.prototype.event=function(t,e){var n=this;this.queue=this.queue.then(function(){return n._event(e)}).catch(this._errorBound)},ki.prototype.end=function(t,e){var n=this;this.queue=this.queue.then(function(){return n._end(e)}).catch(this._errorBound)},ki.prototype.error=function(t,e){var n=this;this.queue=this.queue.then(function(){return n._errorBound(e)}).catch(T)},ki.prototype._event=function(t){return t.then(this._eventBound)},ki.prototype._end=function(t){return Promise.resolve(t).then(this._endBound)},mi.prototype.event=function(t,e){this.active&&this.sink.event(t,e)},mi.prototype.end=function(t,e){this.active&&(this.disable(),this.sink.end(t,e))},mi.prototype.error=function(t,e){this.disable(),this.sink.error(t,e)},mi.prototype.disable=function(){return this.active=!1,this.sink};var Gi=_i;bi.prototype.run=function(t,e){return e.asap(new M(gi,this.value,t))},xi.prototype.run=function(t,e){return new Ei(this.f,this.source,t,e)},Ei.prototype.event=function(t,e){K(t,e,this.sink)},Ei.prototype.end=function(t,e){Q(t,e,this.sink)},Ei.prototype.error=function(t,e){var n=this.sink.disable();w(t,this.disposable,this.sink),this._startNext(t,e,n)},Ei.prototype._startNext=function(t,e,n){try{this.disposable=this._continue(this.f,e,n)}catch(e){n.error(t,e)}},Ei.prototype._continue=function(t,e,n){return t(e).source.run(n,this.scheduler)},Ei.prototype.dispose=function(){return this.disposable.dispose()};var Hi=function(t,e){this.source=t,this.sink=e,this.disposed=!1};Hi.prototype.dispose=function(){if(!this.disposed)return this.disposed=!0,0===this.source.remove(this.sink)&&this.source._dispose()};var Ji=function(t){return t.dispose()},Ki={dispose:function(){}},Qi=function(t){this.source=t,this.sinks=[],this._disposable=Ki};Qi.prototype.run=function(t,e){return 1===this.add(t)&&(this._disposable=this.source.run(this,e)),new Hi(this,t)},Qi.prototype._dispose=function(){var t=this._disposable;return this._disposable=Ki,Promise.resolve(t).then(Ji)},Qi.prototype.add=function(t){return this.sinks=i(t,this.sinks),this.sinks.length},Qi.prototype.remove=function(t){var e=a(t,this.sinks);return e>=0&&(this.sinks=p(e,this.sinks)),this.sinks.length},Qi.prototype.event=function(t,e){var n=this.sinks;if(1===n.length)return n[0].event(t,e);for(var i=0;i