UNPKG

box-chrome-sdk

Version:

A Chrome App SDK for the Box V2 API

1 lines 8.52 kB
(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,i=e[typeof module]&&module&&!module.nodeType&&module,o=(i&&i.exports===r&&r,e[typeof global]&&global);!o||o.global!==o&&o.window!==o||(n=o),"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 i(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 o(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(i(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 i=t.charCodeAt(n);e=(e<<5)-e+i,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 w()},function(t,e){return e})}function h(t){var e=this;return new g(function(n){var r=new m,i=new p,o=new d(i);return n.onNext(E(r,o)),i.add(e.subscribe(function(t){r.onNext(t)},function(t){r.onError(t),n.onError(t)},function(){r.onCompleted(),n.onCompleted()})),i.add(t.subscribe(function(){r.onCompleted(),r=new m,n.onNext(E(r,o))},function(t){r.onError(t),n.onError(t)},function(){r.onCompleted(),n.onCompleted()})),o})}function l(t){var e=this;return new g(function(n){var i,o=new b,s=new p(o),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()})),i=function(){var e,s;try{s=t()}catch(a){return n.onError(a),r}e=new v,o.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)),i()}))},i(),u})}var f=n.Observable,p=n.CompositeDisposable,d=n.RefCountDisposable,v=n.SingleAssignmentDisposable,b=n.SerialDisposable,m=n.Subject,y=f.prototype,w=f.empty,g=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=o(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 i,o=2147483647&A(t),s=o%this.buckets.length,u=this.buckets[s];u>=0;u=this.entries[u].next)if(this.entries[u].hashCode===o&&this.comparer(this.entries[u].key,t)){if(n)throw Error(N);return this.entries[u].value=e,r}this.freeCount>0?(i=this.freeList,this.freeList=this.entries[i].next,--this.freeCount):(this.size===this.entries.length&&(this._resize(),s=o%this.buckets.length),i=this.size,++this.size),this.entries[i].hashCode=o,this.entries[i].next=this.buckets[s],this.entries[i].key=t,this.entries[i].value=e,this.buckets[s]=i},_.prototype._resize=function(){var t=o(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 i=0;this.size>i;++i){var s=n[i].hashCode%t;n[i].next=e[s],e[s]=i}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,i=this.buckets[n];i>=0;i=this.entries[i].next){if(this.entries[i].hashCode===e&&this.comparer(this.entries[i].key,t))return 0>r?this.buckets[n]=this.entries[i].next:this.entries[r].next=this.entries[i].next,this.entries[i].hashCode=-1,this.entries[i].next=this.freeList,this.entries[i].key=null,this.entries[i].value=null,this.freeList=i,++this.freeCount,!0;r=i}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,i){var o=this;return new g(function(s){var u=new p,c=!1,a=0,h=new _,l=!1,f=0,d=new _;return u.add(o.subscribe(function(t){var n,o,l,f,p=a++,b=new v;h.add(p,t),u.add(b),o=function(){return h.remove(p)&&0===h.count()&&c&&s.onCompleted(),u.remove(b)};try{n=e(t)}catch(m){return s.onError(m),r}b.setDisposable(n.take(1).subscribe(C,s.onError.bind(s),function(){o()})),f=d.getValues();for(var y=0;f.length>y;y++){try{l=i(t,f[y])}catch(w){return s.onError(w),r}s.onNext(l)}},s.onError.bind(s),function(){c=!0,(l||0===h.count())&&s.onCompleted()})),u.add(t.subscribe(function(t){var e,o,c,a,p=f++,b=new v;d.add(p,t),u.add(b),o=function(){return d.remove(p)&&0===d.count()&&l&&s.onCompleted(),u.remove(b)};try{e=n(t)}catch(m){return s.onError(m),r}b.setDisposable(e.take(1).subscribe(C,s.onError.bind(s),function(){o()})),a=h.getValues();for(var y=0;a.length>y;y++){try{c=i(a[y],t)}catch(m){return s.onError(m),r}s.onNext(c)}},s.onError.bind(s),function(){l=!0,(c||0===d.count())&&s.onCompleted()})),u})},y.groupJoin=function(t,e,n,i){var o=this;return new g(function(s){var u=function(){},c=new p,a=new d(c),h=new _,l=new _,f=0,b=0;return c.add(o.subscribe(function(t){var n=new m,o=f++;h.add(o,n);var p,d,b,y,w;try{w=i(t,E(n,a))}catch(g){for(b=h.getValues(),p=0,d=b.length;d>p;p++)b[p].onError(g);return s.onError(g),r}for(s.onNext(w),y=l.getValues(),p=0,d=y.length;d>p;p++)n.onNext(y[p]);var x=new v;c.add(x);var C,D=function(){h.remove(o)&&n.onCompleted(),c.remove(x)};try{C=e(t)}catch(g){for(b=h.getValues(),p=0,d=h.length;d>p;p++)b[p].onError(g);return s.onError(g),r}x.setDisposable(C.take(1).subscribe(u,function(t){for(b=h.getValues(),p=0,d=b.length;d>p;p++)b[p].onError(t);s.onError(t)},D))},function(t){for(var e=h.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,i,o,a=b++;l.add(a,t);var f=new v;c.add(f);var p,d=function(){l.remove(a),c.remove(f)};try{p=n(t)}catch(m){for(e=h.getValues(),i=0,o=h.length;o>i;i++)e[i].onError(m);return s.onError(m),r}for(f.setDisposable(p.take(1).subscribe(u,function(t){for(e=h.getValues(),i=0,o=h.length;o>i;i++)e[i].onError(t);s.onError(t)},d)),e=h.getValues(),i=0,o=e.length;o>i;i++)e[i].onNext(t)},function(t){for(var e=h.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]?h.call(this,t):"function"==typeof t?l.call(this,t):a.call(this,t,e)},y.pairwise=function(){var t=this;return new g(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,i){return!t.call(e,n,r,i)})]},n});