forked from Reactive-Extensions/RxJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rx.coincidence.min.js
1 lines (1 loc) · 8.32 KB
/
rx.coincidence.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){if(false&t)return 2===t;for(var e=Math.sqrt(t),n=3;e>=n;){if(0===t%n)return!1;n+=2}return!0}function i(t){var e,n,r;for(e=0;D.length>e;++e)if(n=D[e],n>=t)return n;for(r=1|t;D[D.length-1]>r;){if(o(r))return r;r+=2}return t}function s(t){var e=757602046;if(!t.length)return e;for(var n=0,r=t.length;r>n;n++){var o=t.charCodeAt(n);e=(e<<5)-e+o,e&=e}return e}function u(t){var e=668265261;return t=61^t^t>>>16,t+=t<<3,t^=t>>>4,t*=e,t^=t>>>15}function c(){return{key:null,value:null,next:0,hashCode:0}}function a(t,e){return t.groupJoin(this,e,function(){return g()},function(t,e){return e})}function l(t){var e=this;return new w(function(n){var r=new m,o=new p,i=new d(o);return n.onNext(E(r,i)),o.add(e.subscribe(function(t){r.onNext(t)},function(t){r.onError(t),n.onError(t)},function(){r.onCompleted(),n.onCompleted()})),o.add(t.subscribe(function(){r.onCompleted(),r=new m,n.onNext(E(r,i))},function(t){r.onError(t),n.onError(t)},function(){r.onCompleted(),n.onCompleted()})),i})}function h(t){var e=this;return new w(function(n){var o,i=new v,s=new p(i),u=new d(s),c=new m;return n.onNext(E(c,u)),s.add(e.subscribe(function(t){c.onNext(t)},function(t){c.onError(t),n.onError(t)},function(){c.onCompleted(),n.onCompleted()})),o=function(){var e,s;try{s=t()}catch(a){return n.onError(a),r}e=new b,i.setDisposable(e),e.setDisposable(s.take(1).subscribe(C,function(t){c.onError(t),n.onError(t)},function(){c.onCompleted(),c=new m,n.onNext(E(c,u)),o()}))},o(),u})}var f=n.Observable,p=n.CompositeDisposable,d=n.RefCountDisposable,b=n.SingleAssignmentDisposable,v=n.SerialDisposable,m=n.Subject,y=f.prototype,g=f.empty,w=n.AnonymousObservable,E=(n.Observer.create,n.internals.addRef),x=n.internals.isEqual,C=n.helpers.noop,D=[1,3,7,13,31,61,127,251,509,1021,2039,4093,8191,16381,32749,65521,131071,262139,524287,1048573,2097143,4194301,8388593,16777213,33554393,67108859,134217689,268435399,536870909,1073741789,2147483647],S="no such key",N="duplicate key",A=function(){var t=0;return function(e){if(null==e)throw Error(S);if("string"==typeof e)return s(e);if("number"==typeof e)return u(e);if("boolean"==typeof e)return e===!0?1:0;if(e instanceof Date)return e.getTime();if(e.getHashCode)return e.getHashCode();var n=17*t++;return e.getHashCode=function(){return n},n}}(),_=function(t,e){if(0>t)throw Error("out of range");t>0&&this._initialize(t),this.comparer=e||x,this.freeCount=0,this.size=0,this.freeList=-1};return _.prototype._initialize=function(t){var e,n=i(t);for(this.buckets=Array(n),this.entries=Array(n),e=0;n>e;e++)this.buckets[e]=-1,this.entries[e]=c();this.freeList=-1},_.prototype.count=function(){return this.size},_.prototype.add=function(t,e){return this._insert(t,e,!0)},_.prototype._insert=function(t,e,n){this.buckets||this._initialize(0);for(var o,i=2147483647&A(t),s=i%this.buckets.length,u=this.buckets[s];u>=0;u=this.entries[u].next)if(this.entries[u].hashCode===i&&this.comparer(this.entries[u].key,t)){if(n)throw Error(N);return this.entries[u].value=e,r}this.freeCount>0?(o=this.freeList,this.freeList=this.entries[o].next,--this.freeCount):(this.size===this.entries.length&&(this._resize(),s=i%this.buckets.length),o=this.size,++this.size),this.entries[o].hashCode=i,this.entries[o].next=this.buckets[s],this.entries[o].key=t,this.entries[o].value=e,this.buckets[s]=o},_.prototype._resize=function(){var t=i(2*this.size),e=Array(t);for(r=0;e.length>r;++r)e[r]=-1;var n=Array(t);for(r=0;this.size>r;++r)n[r]=this.entries[r];for(var r=this.size;t>r;++r)n[r]=c();for(var o=0;this.size>o;++o){var s=n[o].hashCode%t;n[o].next=e[s],e[s]=o}this.buckets=e,this.entries=n},_.prototype.remove=function(t){if(this.buckets)for(var e=2147483647&A(t),n=e%this.buckets.length,r=-1,o=this.buckets[n];o>=0;o=this.entries[o].next){if(this.entries[o].hashCode===e&&this.comparer(this.entries[o].key,t))return 0>r?this.buckets[n]=this.entries[o].next:this.entries[r].next=this.entries[o].next,this.entries[o].hashCode=-1,this.entries[o].next=this.freeList,this.entries[o].key=null,this.entries[o].value=null,this.freeList=o,++this.freeCount,!0;r=o}return!1},_.prototype.clear=function(){var t,e;if(!(0>=this.size)){for(t=0,e=this.buckets.length;e>t;++t)this.buckets[t]=-1;for(t=0;this.size>t;++t)this.entries[t]=c();this.freeList=-1,this.size=0}},_.prototype._findEntry=function(t){if(this.buckets)for(var e=2147483647&A(t),n=this.buckets[e%this.buckets.length];n>=0;n=this.entries[n].next)if(this.entries[n].hashCode===e&&this.comparer(this.entries[n].key,t))return n;return-1},_.prototype.count=function(){return this.size-this.freeCount},_.prototype.tryGetValue=function(t){var e=this._findEntry(t);return e>=0?this.entries[e].value:r},_.prototype.getValues=function(){var t=0,e=[];if(this.entries)for(var n=0;this.size>n;n++)this.entries[n].hashCode>=0&&(e[t++]=this.entries[n].value);return e},_.prototype.get=function(t){var e=this._findEntry(t);if(e>=0)return this.entries[e].value;throw Error(S)},_.prototype.set=function(t,e){this._insert(t,e,!1)},_.prototype.containskey=function(t){return this._findEntry(t)>=0},y.join=function(t,e,n,o){var i=this;return new w(function(s){var u=new p,c=!1,a=0,l=new _,h=!1,f=0,d=new _;return u.add(i.subscribe(function(t){var n,i,h,f,p=a++,v=new b;l.add(p,t),u.add(v),i=function(){return l.remove(p)&&0===l.count()&&c&&s.onCompleted(),u.remove(v)};try{n=e(t)}catch(m){return s.onError(m),r}v.setDisposable(n.take(1).subscribe(C,s.onError.bind(s),function(){i()})),f=d.getValues();for(var y=0;f.length>y;y++){try{h=o(t,f[y])}catch(g){return s.onError(g),r}s.onNext(h)}},s.onError.bind(s),function(){c=!0,(h||0===l.count())&&s.onCompleted()})),u.add(t.subscribe(function(t){var e,i,c,a,p=f++,v=new b;d.add(p,t),u.add(v),i=function(){return d.remove(p)&&0===d.count()&&h&&s.onCompleted(),u.remove(v)};try{e=n(t)}catch(m){return s.onError(m),r}v.setDisposable(e.take(1).subscribe(C,s.onError.bind(s),function(){i()})),a=l.getValues();for(var y=0;a.length>y;y++){try{c=o(a[y],t)}catch(m){return s.onError(m),r}s.onNext(c)}},s.onError.bind(s),function(){h=!0,(c||0===d.count())&&s.onCompleted()})),u})},y.groupJoin=function(t,e,n,o){var i=this;return new w(function(s){var u=function(){},c=new p,a=new d(c),l=new _,h=new _,f=0,v=0;return c.add(i.subscribe(function(t){var n=new m,i=f++;l.add(i,n);var p,d,v,y,g;try{g=o(t,E(n,a))}catch(w){for(v=l.getValues(),p=0,d=v.length;d>p;p++)v[p].onError(w);return s.onError(w),r}for(s.onNext(g),y=h.getValues(),p=0,d=y.length;d>p;p++)n.onNext(y[p]);var x=new b;c.add(x);var C,D=function(){l.remove(i)&&n.onCompleted(),c.remove(x)};try{C=e(t)}catch(w){for(v=l.getValues(),p=0,d=l.length;d>p;p++)v[p].onError(w);return s.onError(w),r}x.setDisposable(C.take(1).subscribe(u,function(t){for(v=l.getValues(),p=0,d=v.length;d>p;p++)v[p].onError(t);s.onError(t)},D))},function(t){for(var e=l.getValues(),n=0,r=e.length;r>n;n++)e[n].onError(t);s.onError(t)},s.onCompleted.bind(s))),c.add(t.subscribe(function(t){var e,o,i,a=v++;h.add(a,t);var f=new b;c.add(f);var p,d=function(){h.remove(a),c.remove(f)};try{p=n(t)}catch(m){for(e=l.getValues(),o=0,i=l.length;i>o;o++)e[o].onError(m);return s.onError(m),r}for(f.setDisposable(p.take(1).subscribe(u,function(t){for(e=l.getValues(),o=0,i=l.length;i>o;o++)e[o].onError(t);s.onError(t)},d)),e=l.getValues(),o=0,i=e.length;i>o;o++)e[o].onNext(t)},function(t){for(var e=l.getValues(),n=0,r=e.length;r>n;n++)e[n].onError(t);s.onError(t)})),a})},y.buffer=function(){return this.window.apply(this,arguments).selectMany(function(t){return t.toArray()})},y.window=function(t,e){return 1===arguments.length&&"function"!=typeof arguments[0]?l.call(this,t):"function"==typeof t?h.call(this,t):a.call(this,t,e)},y.pairwise=function(){var t=this;return new w(function(e){var n,r=!1;return t.subscribe(function(t){r?e.onNext([n,t]):r=!0,n=t},e.onError.bind(e),e.onCompleted.bind(e))})},y.partition=function(t,e){var n=this.publish().refCount();return[n.filter(t,e),n.filter(function(n,r,o){return!t.call(e,n,r,o)})]},n});