UNPKG

box-chrome-sdk

Version:

A Chrome App SDK for the Box V2 API

1 lines 6.15 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,e){return 1===t.length&&Array.isArray(t[e])?t[e]:_.call(t)}function o(t,e){this.scheduler=t,this.disposable=e,this.isDisposed=!1}var s=n.Observable,u=s.prototype,c=s.never,a=s.throwException,h=n.AnonymousObservable,l=n.Observer,f=n.Subject,p=n.internals,d=n.helpers,b=p.ScheduledObserver,v=n.SingleAssignmentDisposable,m=n.CompositeDisposable,y=n.RefCountDisposable,w=n.Disposable.empty,g=n.Scheduler.immediate,E=d.defaultKeySerializer,x=n.internals.addRef,C=d.identity,D=d.isPromise,S=p.inherits,N=d.noop,A=s.fromPromise,_=Array.prototype.slice,O="Argument out of range";o.prototype.dispose=function(){var t=this;this.scheduler.schedule(function(){t.isDisposed||(t.isDisposed=!0,t.disposable.dispose())})},function(t){function e(e){t.call(this),this._observer=e,this._state=0}S(e,t);var n=e.prototype;return n.onNext=function(t){this.checkAccess();try{this._observer.onNext(t)}catch(e){throw e}finally{this._state=0}},n.onError=function(t){this.checkAccess();try{this._observer.onError(t)}catch(e){throw e}finally{this._state=2}},n.onCompleted=function(){this.checkAccess();try{this._observer.onCompleted()}catch(t){throw t}finally{this._state=2}},n.checkAccess=function(){if(1===this._state)throw Error("Re-entrancy detected");if(2===this._state)throw Error("Observer completed");0===this._state&&(this._state=1)},e}(l);var j=function(t){function e(){t.apply(this,arguments)}return S(e,t),e.prototype.next=function(e){t.prototype.next.call(this,e),this.ensureActive()},e.prototype.error=function(e){t.prototype.error.call(this,e),this.ensureActive()},e.prototype.completed=function(){t.prototype.completed.call(this),this.ensureActive()},e}(b);u.observeOn=function(t){var e=this;return new h(function(n){return e.subscribe(new j(t,n))})},u.subscribeOn=function(t){var e=this;return new h(function(n){var r=new v,i=new SerialDisposable;return i.setDisposable(r),r.setDisposable(t.schedule(function(){i.setDisposable(new o(t,e.subscribe(n)))})),i})},s.using=function(t,e){return new h(function(n){var r,i,o=w;try{r=t(),r&&(o=r),i=e(r)}catch(s){return new m(a(s).subscribe(n),o)}return new m(i.subscribe(n),o)})},u.amb=function(t){var e=this;return new h(function(n){function r(){o||(o=s,a.dispose())}function i(){o||(o=u,c.dispose())}var o,s="L",u="R",c=new v,a=new v;return D(t)&&(t=A(t)),c.setDisposable(e.subscribe(function(t){r(),o===s&&n.onNext(t)},function(t){r(),o===s&&n.onError(t)},function(){r(),o===s&&n.onCompleted()})),a.setDisposable(t.subscribe(function(t){i(),o===u&&n.onNext(t)},function(t){i(),o===u&&n.onError(t)},function(){i(),o===u&&n.onCompleted()})),new m(c,a)})},s.amb=function(){function t(t,e){return t.amb(e)}for(var e=c(),n=i(arguments,0),r=0,o=n.length;o>r;r++)e=t(e,n[r]);return e},u.onErrorResumeNext=function(t){if(!t)throw Error("Second observable is required");return R([this,t])};var R=s.onErrorResumeNext=function(){var t=i(arguments,0);return new h(function(e){var n=0,r=new SerialDisposable,i=g.scheduleRecursive(function(i){var o,s;t.length>n?(o=t[n++],D(o)&&(o=A(o)),s=new v,r.setDisposable(s),s.setDisposable(o.subscribe(e.onNext.bind(e),function(){i()},function(){i()}))):e.onCompleted()});return new m(r,i)})};u.bufferWithCount=function(t,e){return"number"!=typeof e&&(e=t),this.windowWithCount(t,e).selectMany(function(t){return t.toArray()}).where(function(t){return t.length>0})},u.windowWithCount=function(t,e){var n=this;if(0>=t)throw Error(O);if(1===arguments.length&&(e=t),0>=e)throw Error(O);return new h(function(r){var i=new v,o=new y(i),s=0,u=[],c=function(){var t=new f;u.push(t),r.onNext(x(t,o))};return c(),i.setDisposable(n.subscribe(function(n){for(var r,i=0,o=u.length;o>i;i++)u[i].onNext(n);var a=s-t+1;a>=0&&0===a%e&&(r=u.shift(),r.onCompleted()),s++,0===s%e&&c()},function(t){for(;u.length>0;)u.shift().onError(t);r.onError(t)},function(){for(;u.length>0;)u.shift().onCompleted();r.onCompleted()})),o})},u.defaultIfEmpty=function(t){var e=this;return t===r&&(t=null),new h(function(n){var r=!1;return e.subscribe(function(t){r=!0,n.onNext(t)},n.onError.bind(n),function(){r||n.onNext(t),n.onCompleted()})})},u.distinct=function(t,e){var n=this;return t||(t=C),e||(e=E),new h(function(i){var o={};return n.subscribe(function(n){var s,u,c,a=!1;try{s=t(n),u=e(s)}catch(h){return i.onError(h),r}for(c in o)if(u===c){a=!0;break}a||(o[u]=null,i.onNext(n))},i.onError.bind(i),i.onCompleted.bind(i))})},u.groupBy=function(t,e,n){return this.groupByUntil(t,e,function(){return c()},n)},u.groupByUntil=function(t,e,n,i){var o=this;return e||(e=C),i||(i=E),new h(function(s){var u={},c=new m,a=new y(c);return c.add(o.subscribe(function(o){var h,l,p,d,b,m,y,w,g,E;try{m=t(o),y=i(m)}catch(x){for(E in u)u[E].onError(x);return s.onError(x),r}d=!1;try{g=u[y],g||(g=new f,u[y]=g,d=!0)}catch(x){for(E in u)u[E].onError(x);return s.onError(x),r}if(d){b=new W(m,g,a),l=new W(m,g);try{h=n(l)}catch(x){for(E in u)u[E].onError(x);return s.onError(x),r}s.onNext(b),w=new v,c.add(w);var C=function(){y in u&&(delete u[y],g.onCompleted()),c.remove(w)};w.setDisposable(h.take(1).subscribe(N,function(t){for(E in u)u[E].onError(t);s.onError(t)},function(){C()}))}try{p=e(o)}catch(x){for(E in u)u[E].onError(x);return s.onError(x),r}g.onNext(p)},function(t){for(var e in u)u[e].onError(t);s.onError(t)},function(){for(var t in u)u[t].onCompleted();s.onCompleted()})),a})};var W=function(t){function e(t){return this.underlyingObservable.subscribe(t)}function n(n,r,i){t.call(this,e),this.key=n,this.underlyingObservable=i?new h(function(t){return new m(i.getDisposable(),r.subscribe(t))}):r}return S(n,t),n}(s);return n});