3 lines
6.4 KiB
JavaScript
3 lines
6.4 KiB
JavaScript
/* Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.*/
|
|
(function(a){var b={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},c=b[typeof window]&&window||this,d=b[typeof exports]&&exports&&!exports.nodeType&&exports,e=b[typeof module]&&module&&!module.nodeType&&module,f=(e&&e.exports===d&&d,b[typeof global]&&global);!f||f.global!==f&&f.window!==f||(c=f),"function"==typeof define&&define.amd?define(["rx"],function(b,d){return a(c,d,b)}):"object"==typeof module&&module&&module.exports===d?module.exports=a(c,module.exports,require("./rx")):c.Rx=a(c,{},c.Rx)}).call(this,function(a,b,c,d){function e(a,b){return 1===a.length&&Array.isArray(a[b])?a[b]:I.call(a)}function f(a,b){this.scheduler=a,this.disposable=b,this.isDisposed=!1}function g(a,b,c){for(var d=0,e=a.length;e>d;d++)if(c(a[d],b))return d;return-1}function h(a){this.comparer=a,this.set=[]}var i=c.Observable,j=i.prototype,k=i.never,l=i.throwException,m=c.AnonymousObservable,n=c.AnonymousObserver,o=c.Notification.createOnNext,p=c.Notification.createOnError,q=c.Notification.createOnCompleted,r=c.Observer,s=c.Subject,t=c.internals,u=c.helpers,v=t.ScheduledObserver,w=c.SerialDisposable,x=c.SingleAssignmentDisposable,y=c.CompositeDisposable,z=c.RefCountDisposable,A=c.Disposable.empty,B=c.Scheduler.immediate,C=(u.defaultKeySerializer,c.internals.addRef),D=(u.identity,u.isPromise),E=t.inherits,F=t.bindCallback,G=(u.noop,u.isScheduler),H=i.fromPromise,I=Array.prototype.slice,J="Argument out of range";f.prototype.dispose=function(){var a=this;this.scheduler.schedule(function(){a.isDisposed||(a.isDisposed=!0,a.disposable.dispose())})};var K=function(a){function b(b){a.call(this),this._observer=b,this._state=0}E(b,a);var c=b.prototype;return c.onNext=function(a){this.checkAccess();try{this._observer.onNext(a)}catch(b){throw b}finally{this._state=0}},c.onError=function(a){this.checkAccess();try{this._observer.onError(a)}catch(b){throw b}finally{this._state=2}},c.onCompleted=function(){this.checkAccess();try{this._observer.onCompleted()}catch(a){throw a}finally{this._state=2}},c.checkAccess=function(){if(1===this._state)throw new Error("Re-entrancy detected");if(2===this._state)throw new Error("Observer completed");0===this._state&&(this._state=1)},b}(r),L=function(a){function b(b,c,d){a.call(this,b,c),this._cancel=d}return E(b,a),b.prototype.next=function(b){a.prototype.next.call(this,b),this.ensureActive()},b.prototype.error=function(b){a.prototype.error.call(this,b),this.ensureActive()},b.prototype.completed=function(){a.prototype.completed.call(this),this.ensureActive()},b.prototype.dispose=function(){a.prototype.dispose.call(this),this._cancel&&this._cancel.dispose(),this._cancel=null},b}(v);r.prototype.checked=function(){return new K(this)},r.notifyOn=function(a){return new L(a,this)},r.fromNotifier=function(a,b){var c=F(a,b,1);return new n(function(a){return c(o(a))},function(a){return c(p(a))},function(){return c(q())})},r.prototype.toNotifier=function(){var a=this;return function(b){return b.accept(a)}},r.prototype.asObserver=function(){var a=this;return new n(function(b){a.onNext(b)},function(b){a.onError(b)},function(){a.onCompleted()})},j.observeOn=function(a){var b=this;return new m(function(c){return b.subscribe(new L(a,c))},b)},j.subscribeOn=function(a){var b=this;return new m(function(c){var d=new x,e=new w;return e.setDisposable(d),d.setDisposable(a.schedule(function(){e.setDisposable(new f(a,b.subscribe(c)))})),e},b)},i.generate=function(a,b,c,d,e){return G(e)||(e=currentThreadScheduler),new m(function(f){var g=!0,h=a;return e.scheduleRecursive(function(a){var e,i;try{g?g=!1:h=c(h),e=b(h),e&&(i=d(h))}catch(j){return void f.onError(j)}e?(f.onNext(i),a()):f.onCompleted()})})},i.using=function(a,b){return new m(function(c){var d,e,f=A;try{d=a(),d&&(f=d),e=b(d)}catch(g){return new y(l(g).subscribe(c),f)}return new y(e.subscribe(c),f)})},j.amb=function(a){var b=this;return new m(function(c){function d(){f||(f=g,j.dispose())}function e(){f||(f=h,i.dispose())}var f,g="L",h="R",i=new x,j=new x;return D(a)&&(a=H(a)),i.setDisposable(b.subscribe(function(a){d(),f===g&&c.onNext(a)},function(a){d(),f===g&&c.onError(a)},function(){d(),f===g&&c.onCompleted()})),j.setDisposable(a.subscribe(function(a){e(),f===h&&c.onNext(a)},function(a){e(),f===h&&c.onError(a)},function(){e(),f===h&&c.onCompleted()})),new y(i,j)})},i.amb=function(){function a(a,b){return a.amb(b)}for(var b=k(),c=e(arguments,0),d=0,f=c.length;f>d;d++)b=a(b,c[d]);return b},j.onErrorResumeNext=function(a){if(!a)throw new Error("Second observable is required");return M([this,a])};var M=i.onErrorResumeNext=function(){var a=e(arguments,0);return new m(function(b){var c=0,d=new w,e=B.scheduleRecursive(function(e){var f,g;c<a.length?(f=a[c++],D(f)&&(f=H(f)),g=new x,d.setDisposable(g),g.setDisposable(f.subscribe(b.onNext.bind(b),e,e))):b.onCompleted()});return new y(d,e)})};return j.bufferWithCount=function(a,b){return"number"!=typeof b&&(b=a),this.windowWithCount(a,b).selectMany(function(a){return a.toArray()}).where(function(a){return a.length>0})},j.windowWithCount=function(a,b){var c=this;if(+a||(a=0),1/0===Math.abs(a)&&(a=0),0>=a)throw new Error(J);if(null==b&&(b=a),+b||(b=0),1/0===Math.abs(b)&&(b=0),0>=b)throw new Error(J);return new m(function(d){function e(){var a=new s;i.push(a),d.onNext(C(a,g))}var f=new x,g=new z(f),h=0,i=[];return e(),f.setDisposable(c.subscribe(function(c){for(var d=0,f=i.length;f>d;d++)i[d].onNext(c);var g=h-a+1;g>=0&&g%b===0&&i.shift().onCompleted(),++h%b===0&&e()},function(a){for(;i.length>0;)i.shift().onError(a);d.onError(a)},function(){for(;i.length>0;)i.shift().onCompleted();d.onCompleted()})),g},c)},j.takeLastBuffer=function(a){var b=this;return new m(function(c){var d=[];return b.subscribe(function(b){d.push(b),d.length>a&&d.shift()},function(a){c.onError(a)},function(){c.onNext(d),c.onCompleted()})},b)},j.defaultIfEmpty=function(a){var b=this;return a===d&&(a=null),new m(function(c){var d=!1;return b.subscribe(function(a){d=!0,c.onNext(a)},function(a){c.onError(a)},function(){!d&&c.onNext(a),c.onCompleted()})},b)},h.prototype.push=function(a){var b=-1===g(this.set,a,this.comparer);return b&&this.set.push(a),b},j.distinct=function(a,b){var c=this;return b||(b=defaultComparer),new m(function(d){var e=new h(b);return c.subscribe(function(b){var c=b;if(a)try{c=a(b)}catch(f){return void d.onError(f)}e.push(c)&&d.onNext(b)},function(a){d.onError(a)},function(){d.onCompleted()})},this)},c});
|
|
//# sourceMappingURL=rx.lite.extras.map
|