forked from Reactive-Extensions/RxJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rx.experimental.min.js
1 lines (1 loc) · 4.07 KB
/
rx.experimental.min.js
1
(function(t){var e={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},n=e[typeof window]&&window||this,r=e[typeof exports]&&exports&&!exports.nodeType&&exports,o=e[typeof module]&&module&&!module.nodeType&&module,i=(o&&o.exports===r&&r,e[typeof global]&&global);!i||i.global!==i&&i.window!==i||(n=i),"function"==typeof define&&define.amd?define(["rx","exports"],function(e,r){return n.Rx=t(n,r,e),n.Rx}):"object"==typeof module&&module&&module.exports===r?module.exports=t(n,module.exports,require("./rx")):n.Rx=t(n,{},n.Rx)}).call(this,function(t,e,n,r){function o(t,e){return 1===t.length&&Array.isArray(t[e])?t[e]:x.call(t)}function i(t,e){return new m(function(){return new v(function(){return t()?{done:!1,value:e}:{done:!0,value:r}})})}var s=n.Observable,u=s.prototype,c=n.AnonymousObservable,a=s.concat,l=s.defer,f=s.empty,h=n.Disposable.empty,p=n.CompositeDisposable,d=n.SerialDisposable,b=n.SingleAssignmentDisposable,v=n.internals.Enumerator,m=n.internals.Enumerable,y=m.forEach,w=n.Scheduler.immediate,g=n.Scheduler.currentThread,x=Array.prototype.slice,E=n.AsyncSubject,C=n.Observer,D=n.internals.inherits,S=n.internals.addProperties,N=n.helpers.noop,A=n.helpers.isPromise,_=s.fromPromise,O="object"==typeof Symbol&&Symbol.iterator||"_es6shim_iterator_";t.Set&&"function"==typeof(new t.Set)["@@iterator"]&&(O="@@iterator"),u.letBind=u.let=function(t){return t(this)},s["if"]=s.ifThen=function(t,e,n){return l(function(){return n||(n=f()),A(e)&&(e=_(e)),A(n)&&(n=_(n)),"function"==typeof n.now&&(n=f(n)),t()?e:n})},s["for"]=s.forIn=function(t,e){return y(t,e).concat()};var j=s["while"]=s.whileDo=function(t,e){return A(e)&&(e=_(e)),i(t,e).concat()};u.doWhile=function(t){return a([this,j(t,this)])},s["case"]=s.switchCase=function(t,e,n){return l(function(){n||(n=f()),"function"==typeof n.now&&(n=f(n));var r=e[t()];return A(r)&&(r=_(r)),r||n})},u.expand=function(t,e){e||(e=w);var n=this;return new c(function(o){var i=[],s=new d,u=new p(s),c=0,a=!1,l=function(){var n=!1;i.length>0&&(n=!a,a=!0),n&&s.setDisposable(e.scheduleRecursive(function(e){var n;if(!(i.length>0))return a=!1,r;n=i.shift();var s=new b;u.add(s),s.setDisposable(n.subscribe(function(e){o.onNext(e);var n=null;try{n=t(e)}catch(r){o.onError(r)}i.push(n),c++,l()},o.onError.bind(o),function(){u.remove(s),c--,0===c&&o.onCompleted()})),e()}))};return i.push(n),c++,l(),u})},s.forkJoin=function(){var t=o(arguments,0);return new c(function(e){var n=t.length;if(0===n)return e.onCompleted(),h;for(var o=new p,i=!1,s=Array(n),u=Array(n),c=Array(n),a=0;n>a;a++)(function(a){var l=t[a];A(l)&&(l=_(l)),o.add(l.subscribe(function(t){i||(s[a]=!0,c[a]=t)},function(t){i=!0,e.onError(t),o.dispose()},function(){if(!i){if(!s[a])return e.onCompleted(),r;u[a]=!0;for(var t=0;n>t;t++)if(!u[t])return;i=!0,e.onNext(c),e.onCompleted()}}))})(a);return o})},u.forkJoin=function(t,e){var n=this;return new c(function(o){var i,s,u=!1,c=!1,a=!1,l=!1,f=new b,h=new b;return A(t)&&(t=_(t)),f.setDisposable(n.subscribe(function(t){a=!0,i=t},function(t){h.dispose(),o.onError(t)},function(){if(u=!0,c)if(a)if(l){var t;try{t=e(i,s)}catch(n){return o.onError(n),r}o.onNext(t),o.onCompleted()}else o.onCompleted();else o.onCompleted()})),h.setDisposable(t.subscribe(function(t){l=!0,s=t},function(t){f.dispose(),o.onError(t)},function(){if(c=!0,u)if(a)if(l){var t;try{t=e(i,s)}catch(n){return o.onError(n),r}o.onNext(t),o.onCompleted()}else o.onCompleted();else o.onCompleted()})),new p(f,h)})},u.manySelect=function(t,e){e||(e=w);var n=this;return l(function(){var r;return n.select(function(t){var e=new R(t);return r&&r.onNext(t),r=e,e}).doAction(N,function(t){r&&r.onError(t)},function(){r&&r.onCompleted()}).observeOn(e).select(function(e,n,r){return t(e,n,r)})})};var R=function(t){function e(t){var e=this,n=new p;return n.add(g.schedule(function(){t.onNext(e.head),n.add(e.tail.mergeObservable().subscribe(t))})),n}function n(n){t.call(this,e),this.head=n,this.tail=new E}return D(n,t),S(n.prototype,C,{onCompleted:function(){this.onNext(s.empty())},onError:function(t){this.onNext(s.throwException(t))},onNext:function(t){this.tail.onNext(t),this.tail.onCompleted()}}),n}(s);return n});