forked from Reactive-Extensions/RxJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rx.joinpatterns.min.js
1 lines (1 loc) · 4.32 KB
/
rx.joinpatterns.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){function r(t,e){return 1===t.length&&Array.isArray(t[e])?t[e]:y.call(t)}function o(t){this.patterns=t}function i(t,e){this.expression=t,this.selector=e}function s(t,e,n){var r=t.get(e);if(!r){var o=new w(e,n);return t.set(e,o),o}return r}function u(t,e,n){var r,o;for(this.joinObserverArray=t,this.onNext=e,this.onCompleted=n,this.joinObservers=new g,r=0;this.joinObserverArray.length>r;r++)o=this.joinObserverArray[r],this.joinObservers.set(o,o)}var c=n.Observable,a=c.prototype,l=n.AnonymousObservable,h=c.throwException,f=n.Observer.create,p=n.SingleAssignmentDisposable,d=n.CompositeDisposable,b=n.internals.AbstractObserver,v=n.helpers.noop,m=(n.internals.isEqual,n.internals.inherits),y=Array.prototype.slice,g=function(){function t(){this.keys=[],this.values=[]}return t.prototype["delete"]=function(t){var e=this.keys.indexOf(t);return-1!==e&&(this.keys.splice(e,1),this.values.splice(e,1)),-1!==e},t.prototype.get=function(t,e){var n=this.keys.indexOf(t);return-1!==n?this.values[n]:e},t.prototype.set=function(t,e){var n=this.keys.indexOf(t);-1!==n&&(this.values[n]=e),this.values[this.keys.push(t)-1]=e},t.prototype.size=function(){return this.keys.length},t.prototype.has=function(t){return-1!==this.keys.indexOf(t)},t.prototype.getKeys=function(){return this.keys.slice(0)},t.prototype.getValues=function(){return this.values.slice(0)},t}();o.prototype.and=function(t){var e=this.patterns.slice(0);return e.push(t),new o(e)},o.prototype.then=function(t){return new i(this,t)},i.prototype.activate=function(t,e,n){for(var r=this,o=[],i=0,c=this.expression.patterns.length;c>i;i++)o.push(s(t,this.expression.patterns[i],e.onError.bind(e)));var a=new u(o,function(){var t;try{t=r.selector.apply(r,arguments)}catch(n){return e.onError(n),undefined}e.onNext(t)},function(){for(var t=0,e=o.length;e>t;t++)o[t].removeActivePlan(a);n(a)});for(i=0,c=o.length;c>i;i++)o[i].addActivePlan(a);return a},u.prototype.dequeue=function(){for(var t=this.joinObservers.getValues(),e=0,n=t.length;n>e;e++)t[e].queue.shift()},u.prototype.match=function(){var t,e,n,r,o,i=!0;for(e=0,n=this.joinObserverArray.length;n>e;e++)if(0===this.joinObserverArray[e].queue.length){i=!1;break}if(i){for(t=[],r=!1,e=0,n=this.joinObserverArray.length;n>e;e++)t.push(this.joinObserverArray[e].queue[0]),"C"===this.joinObserverArray[e].queue[0].kind&&(r=!0);if(r)this.onCompleted();else{for(this.dequeue(),o=[],e=0;t.length>e;e++)o.push(t[e].value);this.onNext.apply(this,o)}}};var w=function(t){function e(e,n){t.call(this),this.source=e,this.onError=n,this.queue=[],this.activePlans=[],this.subscription=new p,this.isDisposed=!1}m(e,t);var n=e.prototype;return n.next=function(t){if(!this.isDisposed){if("E"===t.kind)return this.onError(t.exception),undefined;this.queue.push(t);for(var e=this.activePlans.slice(0),n=0,r=e.length;r>n;n++)e[n].match()}},n.error=v,n.completed=v,n.addActivePlan=function(t){this.activePlans.push(t)},n.subscribe=function(){this.subscription.setDisposable(this.source.materialize().subscribe(this))},n.removeActivePlan=function(t){var e=this.activePlans.indexOf(t);this.activePlans.splice(e,1),0===this.activePlans.length&&this.dispose()},n.dispose=function(){t.prototype.dispose.call(this),this.isDisposed||(this.isDisposed=!0,this.subscription.dispose())},e}(b);return a.and=function(t){return new o([this,t])},a.then=function(t){return new o([this]).then(t)},c.when=function(){var t=r(arguments,0);return new l(function(e){var n,r,o,i,s,u,c=[],a=new g;u=f(e.onNext.bind(e),function(t){for(var n=a.getValues(),r=0,o=n.length;o>r;r++)n[r].onError(t);e.onError(t)},e.onCompleted.bind(e));try{for(r=0,o=t.length;o>r;r++)c.push(t[r].activate(a,u,function(t){var e=c.indexOf(t);c.splice(e,1),0===c.length&&u.onCompleted()}))}catch(l){h(l).subscribe(e)}for(n=new d,s=a.getValues(),r=0,o=s.length;o>r;r++)i=s[r],i.subscribe(),n.add(i);return n})},n});