123 |
- /* Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.*/
- (function(a){function b(a){return a&&a.Object===Object?a:null}var c={"function":!0,object:!0},d=c[typeof exports]&&exports&&!exports.nodeType?exports:null,e=c[typeof module]&&module&&!module.nodeType?module:null,f=b(d&&e&&"object"==typeof global&&global),g=b(c[typeof self]&&self),h=b(c[typeof window]&&window),i=(e&&e.exports===d?d:null,b(c[typeof this]&&this)),j=f||h!==(i&&i.window)&&h||g||i||Function("return this")();"function"==typeof define&&define.amd?define(["./rx"],function(b,c){return a(j,c,b)}):"object"==typeof module&&module&&module.exports===d?module.exports=a(j,module.exports,require("./rx")):j.Rx=a(j,{},j.Rx)}).call(this,function(a,b,c,d){function e(a){return function(){try{return a.apply(this,arguments)}catch(b){return M.e=b,M}}}function f(a,b){return new O(a,b)}function g(a,b,c){return new t(function(d){var e=a,f=G(b);return c.scheduleRecursiveFuture(0,e,function(a,b){if(f>0){var g=c.now();e=new Date(e.getTime()+f),e.getTime()<=g&&(e=new Date(g+f))}d.onNext(a),b(a+1,new Date(e))})})}function h(a,b,c){return a===b?new t(function(a){return c.schedulePeriodic(0,b,function(b){return a.onNext(b),b+1})}):v(function(){return g(new Date(c.now()+a),b,c)})}function i(a,b,c){return new t(function(d){var e,f=!1,g=new A,h=null,i=[],j=!1;return e=a.materialize().timestamp(c).subscribe(function(a){var e,k;"E"===a.value.kind?(i=[],i.push(a),h=a.value.error,k=!j):(i.push({value:a.value,timestamp:a.timestamp+b}),k=!f,f=!0),k&&(null!==h?d.onError(h):(e=new z,g.setDisposable(e),e.setDisposable(c.scheduleRecursiveFuture(null,b,function(a,b){var e,g,k,l;if(null===h){j=!0;do k=null,i.length>0&&i[0].timestamp-c.now()<=0&&(k=i.shift().value),null!==k&&k.accept(d);while(null!==k);l=!1,g=0,i.length>0?(l=!0,g=Math.max(0,i[0].timestamp-c.now())):f=!1,e=h,j=!1,null!==e?d.onError(e):l&&b(null,g)}}))))}),new C(e,g)},a)}function j(a,b,c){return v(function(){return i(a,b-c.now(),c)})}function k(a,b,c){var d,e;return J(b)?e=b:(d=b,e=c),new t(function(b){function c(){i.setDisposable(a.subscribe(function(a){var c=N(e)(a);if(c===M)return b.onError(c.e);var d=new z;g.add(d),d.setDisposable(c.subscribe(function(){b.onNext(a),g.remove(d),f()},function(a){b.onError(a)},function(){b.onNext(a),g.remove(d),f()}))},function(a){b.onError(a)},function(){h=!0,i.dispose(),f()}))}function f(){h&&0===g.length&&b.onCompleted()}var g=new B,h=!1,i=new A;return d?i.setDisposable(d.subscribe(c,function(a){b.onError(a)},c)):c(),new C(i,g)},a)}function l(a,b){return new t(function(c){var d,e=!1,f=new A,g=0,h=a.subscribe(function(a){var h=N(b)(a);if(h===M)return c.onError(h.e);I(h)&&(h=L(h)),e=!0,d=a,g++;var i=g,j=new z;f.setDisposable(j),j.setDisposable(h.subscribe(function(){e&&g===i&&c.onNext(d),e=!1,j.dispose()},function(a){c.onError(a)},function(){e&&g===i&&c.onNext(d),e=!1,j.dispose()}))},function(a){f.dispose(),c.onError(a),e=!1,g++},function(){f.dispose(),e&&c.onNext(d),c.onCompleted(),e=!1,g++});return new C(h,f)},a)}function m(a){return a.toArray()}function m(a){return a.toArray()}function n(a,b,c,d){return J(b)&&(d=c,c=b,b=w()),r.isObservable(d)||(d=x(new Z)),new t(function(e){function f(a){function b(){return l=c===k}var c=k,f=new z;i.setDisposable(f),f.setDisposable(a.subscribe(function(){b()&&h.setDisposable(d.subscribe(e)),f.dispose()},function(a){b()&&e.onError(a)},function(){b()&&h.setDisposable(d.subscribe(e))}))}function g(){var a=!l;return a&&k++,a}var h=new A,i=new A,j=new z;h.setDisposable(j);var k=0,l=!1;return f(b),j.setDisposable(a.subscribe(function(a){if(g()){e.onNext(a);var b=N(c)(a);if(b===M)return e.onError(b.e);f(I(b)?L(b):b)}},function(a){g()&&e.onError(a)},function(){g()&&e.onCompleted()})),new C(h,i)},a)}function o(a,b,c,d){return K(c)&&(d=c,c=x(new Z)),c instanceof Error&&(c=x(c)),K(d)||(d=y),r.isObservable(c)||(c=x(new Z)),new t(function(e){function f(){var a=g;k.setDisposable(d.scheduleFuture(null,b,function(){j=g===a,j&&(I(c)&&(c=L(c)),i.setDisposable(c.subscribe(e)))}))}var g=0,h=new z,i=new A,j=!1,k=new A;return i.setDisposable(h),f(),h.setDisposable(a.subscribe(function(a){j||(g++,e.onNext(a),f())},function(a){j||(g++,e.onError(a))},function(){j||(g++,e.onCompleted())})),new C(i,k)},a)}var p=c.internals.inherits,q=c.internals.AbstractObserver,r=c.Observable,s=r.prototype,t=c.AnonymousObservable,u=c.ObservableBase,v=r.defer,w=(r.empty,r.never),x=r["throw"],y=(r.fromArray,c.Scheduler["default"]),z=c.SingleAssignmentDisposable,A=c.SerialDisposable,B=c.CompositeDisposable,C=c.BinaryDisposable,D=c.RefCountDisposable,E=c.Subject,F=c.internals.addRef,G=c.Scheduler.normalize,H=c.helpers,I=H.isPromise,J=H.isFunction,K=c.Scheduler.isScheduler,L=r.fromPromise,M={e:{}},N=c.internals.tryCatch=function(a){if(!J(a))throw new TypeError("fn must be a function");return e(a)},O=function(a){function b(b,c){this._dt=b,this._s=c,a.call(this)}function c(a,b){b.onNext(0),b.onCompleted()}return p(b,a),b.prototype.subscribeCore=function(a){return this._s.scheduleFuture(a,this._dt,c)},b}(u),P=r.interval=function(a,b){return h(a,a,K(b)?b:y)};r.timer=function(a,b,c){var e;return K(c)||(c=y),null!=b&&"number"==typeof b?e=b:K(b)&&(c=b),(a instanceof Date||"number"==typeof a)&&e===d?f(a,c):a instanceof Date&&e!==d?g(a,b,c):h(a,e,c)};s.delay=function(){var a=arguments[0];if("number"==typeof a||a instanceof Date){var b=a,c=arguments[1];return K(c)||(c=y),b instanceof Date?j(this,b,c):i(this,b,c)}if(r.isObservable(a)||J(a))return k(this,a,arguments[1]);throw new Error("Invalid arguments")};var Q=function(a){function b(b,c,d){K(d)||(d=y),this.source=b,this._dt=c,this._s=d,a.call(this)}return p(b,a),b.prototype.subscribeCore=function(a){var b=new A;return new C(this.source.subscribe(new R(a,this._dt,this._s,b)),b)},b}(u),R=function(a){function b(b,c,d,e){this._o=b,this._d=c,this._scheduler=d,this._c=e,this._v=null,this._hv=!1,this._id=0,a.call(this)}return p(b,a),b.prototype.next=function(a){this._hv=!0,this._v=a;var b=++this._id,c=new z;this._c.setDisposable(c),c.setDisposable(this._scheduler.scheduleFuture(this,this._d,function(c,d){d._hv&&d._id===b&&d._o.onNext(a),d._hv=!1}))},b.prototype.error=function(a){this._c.dispose(),this._o.onError(a),this._hv=!1,this._id++},b.prototype.completed=function(){this._c.dispose(),this._hv&&this._o.onNext(this._v),this._o.onCompleted(),this._hv=!1,this._id++},b}(q);s.debounce=function(){if(J(arguments[0]))return l(this,arguments[0]);if("number"==typeof arguments[0])return new Q(this,arguments[0],arguments[1]);throw new Error("Invalid arguments")},s.windowWithTime=s.windowTime=function(a,b,c){var d,e=this;return null==b&&(d=a),K(c)||(c=y),"number"==typeof b?d=b:K(b)&&(d=a,c=b),new t(function(b){function f(){var a=new z,e=!1,g=!1;l.setDisposable(a),j===i?(e=!0,g=!0):i>j?e=!0:g=!0;var n=e?j:i,o=n-m;m=n,e&&(j+=d),g&&(i+=d),a.setDisposable(c.scheduleFuture(null,o,function(){if(g){var a=new E;k.push(a),b.onNext(F(a,h))}e&&k.shift().onCompleted(),f()}))}var g,h,i=d,j=a,k=[],l=new A,m=0;return g=new B(l),h=new D(g),k.push(new E),b.onNext(F(k[0],h)),f(),g.add(e.subscribe(function(a){for(var b=0,c=k.length;c>b;b++)k[b].onNext(a)},function(a){for(var c=0,d=k.length;d>c;c++)k[c].onError(a);b.onError(a)},function(){for(var a=0,c=k.length;c>a;a++)k[a].onCompleted();b.onCompleted()})),h},e)},s.windowWithTimeOrCount=s.windowTimeOrCount=function(a,b,c){var d=this;return K(c)||(c=y),new t(function(e){function f(b){var d=new z;g.setDisposable(d),d.setDisposable(c.scheduleFuture(null,a,function(){if(b===k){j=0;var a=++k;l.onCompleted(),l=new E,e.onNext(F(l,i)),f(a)}}))}var g=new A,h=new B(g),i=new D(h),j=0,k=0,l=new E;return e.onNext(F(l,i)),f(0),h.add(d.subscribe(function(a){var c=0,d=!1;l.onNext(a),++j===b&&(d=!0,j=0,c=++k,l.onCompleted(),l=new E,e.onNext(F(l,i))),d&&f(c)},function(a){l.onError(a),e.onError(a)},function(){l.onCompleted(),e.onCompleted()})),i},d)},s.bufferWithTime=s.bufferTime=function(a,b,c){return this.windowWithTime(a,b,c).flatMap(m)},s.bufferWithTimeOrCount=s.bufferTimeOrCount=function(a,b,c){return this.windowWithTimeOrCount(a,b,c).flatMap(m)};var S=function(a){function b(b,c){this.source=b,this._s=c,a.call(this)}return p(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new T(a,this._s))},b}(u),T=function(a){function b(b,c){this._o=b,this._s=c,this._l=c.now(),a.call(this)}return p(b,a),b.prototype.next=function(a){var b=this._s.now(),c=b-this._l;this._l=b,this._o.onNext({value:a,interval:c})},b.prototype.error=function(a){this._o.onError(a)},b.prototype.completed=function(){this._o.onCompleted()},b}(q);s.timeInterval=function(a){return K(a)||(a=y),new S(this,a)};var U=function(a){function b(b,c){this.source=b,this._s=c,a.call(this)}return p(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new V(a,this._s))},b}(u),V=function(a){function b(b,c){this._o=b,this._s=c,a.call(this)}return p(b,a),b.prototype.next=function(a){this._o.onNext({value:a,timestamp:this._s.now()})},b.prototype.error=function(a){this._o.onError(a)},b.prototype.completed=function(){this._o.onCompleted()},b}(q);s.timestamp=function(a){return K(a)||(a=y),new U(this,a)};var W=function(a){function b(b,c){this.source=b,this._sampler=c,a.call(this)}return p(b,a),b.prototype.subscribeCore=function(a){var b={o:a,atEnd:!1,value:null,hasValue:!1,sourceSubscription:new z};return b.sourceSubscription.setDisposable(this.source.subscribe(new Y(b))),new C(b.sourceSubscription,this._sampler.subscribe(new X(b)))},b}(u),X=function(a){function b(b){this._s=b,a.call(this)}return p(b,a),b.prototype._handleMessage=function(){this._s.hasValue&&(this._s.hasValue=!1,this._s.o.onNext(this._s.value)),this._s.atEnd&&this._s.o.onCompleted()},b.prototype.next=function(){this._handleMessage()},b.prototype.error=function(a){this._s.onError(a)},b.prototype.completed=function(){this._handleMessage()},b}(q),Y=function(a){function b(b){this._s=b,a.call(this)}return p(b,a),b.prototype.next=function(a){this._s.hasValue=!0,this._s.value=a},b.prototype.error=function(a){this._s.o.onError(a)},b.prototype.completed=function(){this._s.atEnd=!0,this._s.sourceSubscription.dispose()},b}(q);s.sample=function(a,b){return K(b)||(b=y),"number"==typeof a?new W(this,P(a,b)):new W(this,a)};var Z=c.TimeoutError=function(a){this.message=a||"Timeout has occurred",this.name="TimeoutError",Error.call(this)};Z.prototype=Object.create(Error.prototype),s.timeout=function(){var a=arguments[0];if(a instanceof Date||"number"==typeof a)return o(this,a,arguments[1],arguments[2]);if(r.isObservable(a)||J(a))return n(this,a,arguments[1],arguments[2]);throw new Error("Invalid arguments")};var $=function(a){function b(b,c,d,e,f,g){this._state=b,this._cndFn=c,this._itrFn=d,this._resFn=e,this._timeFn=f,this._s=g,a.call(this)}function c(a,b){if(a.hasResult&&a.o.onNext(a.result),a.first)a.first=!1;else if(a.newState=N(a.self._itrFn)(a.newState),a.newState===M)return a.o.onError(a.newState.e);if(a.hasResult=N(a.self._cndFn)(a.newState),a.hasResult===M)return a.o.onError(a.hasResult.e);if(a.hasResult){if(a.result=N(a.self._resFn)(a.newState),a.result===M)return a.o.onError(a.result.e);var c=N(a.self._timeFn)(a.newState);if(c===M)return a.o.onError(c.e);b(a,c)}else a.o.onCompleted()}return p(b,a),b.prototype.subscribeCore=function(a){var b={o:a,self:this,newState:this._state,first:!0,hasResult:!1};return this._s.scheduleRecursiveFuture(b,new Date(this._s.now()),c)},b}(u);r.generateWithAbsoluteTime=function(a,b,c,d,e,f){return K(f)||(f=y),new $(a,b,c,d,e,f)};var _=function(a){function b(b,c,d,e,f,g){this._state=b,this._cndFn=c,this._itrFn=d,this._resFn=e,this._timeFn=f,this._s=g,a.call(this)}function c(a,b){if(a.hasResult&&a.o.onNext(a.result),a.first)a.first=!1;else if(a.newState=N(a.self._itrFn)(a.newState),a.newState===M)return a.o.onError(a.newState.e);if(a.hasResult=N(a.self._cndFn)(a.newState),a.hasResult===M)return a.o.onError(a.hasResult.e);if(a.hasResult){if(a.result=N(a.self._resFn)(a.newState),a.result===M)return a.o.onError(a.result.e);var c=N(a.self._timeFn)(a.newState);if(c===M)return a.o.onError(c.e);b(a,c)}else a.o.onCompleted()}return p(b,a),b.prototype.subscribeCore=function(a){var b={o:a,self:this,newState:this._state,first:!0,hasResult:!1};return this._s.scheduleRecursiveFuture(b,0,c)},b}(u);r.generateWithRelativeTime=function(a,b,c,d,e,f){return K(f)||(f=y),new _(a,b,c,d,e,f)};var aa=function(a){function b(b,c,d){this.source=b,this._dt=c,this._s=d,a.call(this)}function c(a,b){var c=b[0],d=b[1],e=b[2];e.setDisposable(c.subscribe(d))}return p(b,a),b.prototype.subscribeCore=function(a){var b=new A;return b.setDisposable(this._s.scheduleFuture([this.source,a,b],this._dt,c)),b},b}(u);s.delaySubscription=function(a,b){return K(b)||(b=y),new aa(this,a,b)};var ba=function(a){function b(b,c,d){this.source=b,this._d=c,this._s=d,a.call(this)}return p(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new ca(a,this))},b}(u),ca=function(a){function b(b,c){this._o=b,this._s=c._s,this._d=c._d,this._q=[],a.call(this)}return p(b,a),b.prototype.next=function(a){var b=this._s.now();for(this._q.push({interval:b,value:a});this._q.length>0&&b-this._q[0].interval>=this._d;)this._o.onNext(this._q.shift().value)},b.prototype.error=function(a){this._o.onError(a)},b.prototype.completed=function(){for(var a=this._s.now();this._q.length>0&&a-this._q[0].interval>=this._d;)this._o.onNext(this._q.shift().value);this._o.onCompleted()},b}(q);s.skipLastWithTime=function(a,b){return K(b)||(b=y),new ba(this,a,b)};var da=function(a){function b(b,c,d){this.source=b,this._d=c,this._s=d,a.call(this)}return p(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new ea(a,this._d,this._s))},b}(u),ea=function(a){function b(b,c,d){this._o=b,this._d=c,this._s=d,this._q=[],a.call(this)}return p(b,a),b.prototype.next=function(a){var b=this._s.now();for(this._q.push({interval:b,value:a});this._q.length>0&&b-this._q[0].interval>=this._d;)this._q.shift()},b.prototype.error=function(a){this._o.onError(a)},b.prototype.completed=function(){for(var a=this._s.now();this._q.length>0;){var b=this._q.shift();a-b.interval<=this._d&&this._o.onNext(b.value)}this._o.onCompleted()},b}(q);s.takeLastWithTime=function(a,b){return K(b)||(b=y),new da(this,a,b)},s.takeLastBufferWithTime=function(a,b){var c=this;return K(b)||(b=y),new t(function(d){var e=[];return c.subscribe(function(c){var d=b.now();for(e.push({interval:d,value:c});e.length>0&&d-e[0].interval>=a;)e.shift()},function(a){d.onError(a)},function(){for(var c=b.now(),f=[];e.length>0;){var g=e.shift();c-g.interval<=a&&f.push(g.value)}d.onNext(f),d.onCompleted()})},c)};var fa=function(a){function b(b,c,d){this.source=b,this._d=c,this._s=d,a.call(this)}function c(a,b){b.onCompleted()}return p(b,a),b.prototype.subscribeCore=function(a){return new C(this._s.scheduleFuture(a,this._d,c),this.source.subscribe(a))},b}(u);s.takeWithTime=function(a,b){return K(b)||(b=y),new fa(this,a,b)};var ga=function(a){function b(b,c,d){this.source=b,this._d=c,this._s=d,this._open=!1,a.call(this)}function c(a,b){b._open=!0}return p(b,a),b.prototype.subscribeCore=function(a){return new C(this._s.scheduleFuture(this,this._d,c),this.source.subscribe(new ha(a,this)))},b}(u),ha=function(a){function b(b,c){this._o=b,this._p=c,a.call(this)}return p(b,a),b.prototype.next=function(a){this._p._open&&this._o.onNext(a)},b.prototype.error=function(a){this._o.onError(a)},b.prototype.completed=function(){this._o.onCompleted()},b}(q);s.skipWithTime=function(a,b){return K(b)||(b=y),new ga(this,a,b)};var ia=function(a){function b(b,c,d){this.source=b,this._st=c,this._s=d,a.call(this)}function c(a,b){b._open=!0}return p(b,a),b.prototype.subscribeCore=function(a){return this._open=!1,new C(this._s.scheduleFuture(this,this._st,c),this.source.subscribe(new ja(a,this)))},b}(u),ja=function(a){function b(b,c){this._o=b,this._p=c,a.call(this)}return p(b,a),b.prototype.next=function(a){this._p._open&&this._o.onNext(a)},b.prototype.error=function(a){this._o.onError(a)},b.prototype.completed=function(){this._o.onCompleted()},b}(q);return s.skipUntilWithTime=function(a,b){return K(b)||(b=y),new ia(this,a,b)},s.takeUntilWithTime=function(a,b){K(b)||(b=y);var c=this;return new t(function(d){return new C(b.scheduleFuture(d,a,function(a,b){b.onCompleted()}),c.subscribe(d))},c)},s.throttle=function(a,b){K(b)||(b=y);var c=+a||0;if(0>=c)throw new RangeError("windowDuration cannot be less or equal zero.");var d=this;return new t(function(a){var e=0;return d.subscribe(function(d){var f=b.now();(0===e||f-e>=c)&&(e=f,a.onNext(d))},function(b){a.onError(b)},function(){a.onCompleted()})},d)},c});
- //# sourceMappingURL=rx.time.map
|