Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated documentation and changed inheritance

  • Loading branch information...
commit 5a8770914b070a0bfac1a74f6d7f512456ccf5d3 1 parent 505fc45
@mattpodwysocki mattpodwysocki authored
Showing with 559 additions and 167 deletions.
  1. +4 −4 Gruntfile.js
  2. +1 −1  rx.binding.js
  3. +1 −1  rx.binding.min.js
  4. +53 −13 rx.joinpatterns.js
  5. +1 −1  rx.joinpatterns.min.js
  6. +87 −15 rx.js
  7. +2 −2 rx.min.js
  8. +87 −15 rx.modern.js
  9. +2 −2 rx.modern.min.js
  10. +102 −33 rx.testing.js
  11. +1 −1  rx.testing.min.js
  12. +6 −1 src/core/anonymousobservable.js
  13. +26 −1 src/core/autodetachobserver.js
  14. +1 −1  src/core/concurrency/historicalscheduler.js
  15. +4 −4 src/core/concurrency/virtualtimescheduler.js
  16. +1 −1  src/core/disposables/compositedisposable.js
  17. +5 −5 src/core/exports.js
  18. +1 −1  src/core/intro.js
  19. +53 −13 src/core/joins/joinobserver.js
  20. +1 −1  src/core/subjects/replaysubject.js
  21. +1 −1  src/core/subjects/subject.js
  22. +11 −4 src/core/testing/coldobservable.js
  23. +11 −4 src/core/testing/hotobservable.js
  24. +6 −0 src/core/testing/mockdisposable.js
  25. +31 −6 src/core/testing/mockobserver.js
  26. +22 −1 src/core/testing/reactivetest.js
  27. +10 −8 src/core/testing/recorded.js
  28. +6 −5 src/core/testing/subscription.js
  29. +5 −5 src/core/testing/testscheduler.js
  30. +9 −9 tests/ConnectableObservableTest.js
  31. +8 −8 tests/ObservableBindingTest.js
View
8 Gruntfile.js
@@ -24,7 +24,7 @@ module.exports = function (grunt) {
'src/core/license.js',
'src/core/intro.js',
'src/core/basicheader.js',
- 'src/core/util.js',
+ 'src/core/internal/util.js',
'src/core/internal/polyfills.js',
'src/core/internal/priorityqueue.js',
'src/core/disposables/compositedisposable.js',
@@ -75,7 +75,7 @@ module.exports = function (grunt) {
'src/core/license.js',
'src/core/intro.js',
'src/core/basicheader.js',
- 'src/core/util.js',
+ 'src/core/internal/util.js',
'src/core/internal/priorityqueue.js',
'src/core/disposables/compositedisposable.js',
'src/core/disposables/disposable.js',
@@ -275,9 +275,9 @@ module.exports = function (grunt) {
'uglify:experimental',
'uglify:joinpatterns',
'uglify:testing',
- 'uglify:time',
+ 'uglify:time'//,
- 'qunit'
+ //'qunit'
]);
};
View
2  rx.binding.js
@@ -288,7 +288,7 @@
* Represents an object that is both an observable sequence as well as an observer.
* Each notification is broadcasted to all subscribed and future observers, subject to buffer trimming policies.
*/
- var ReplaySubject = Rx.ReplaySubject = (function (base) {
+ var ReplaySubject = Rx.ReplaySubject = (function (_super) {
/**
* @private
* @constructor
View
2  rx.binding.min.js
@@ -1 +1 @@
-(function(t,e){var n="object"==typeof exports&&exports&&("object"==typeof t&&t&&t==t.global&&(window=t),exports);"function"==typeof define&&define.amd?define(["rx","exports"],function(n,r){return t.Rx=e(t,r,n),t.Rx}):"object"==typeof module&&module&&module.exports==n?module.exports=e(t,module.exports,require("./rx")):t.Rx=e(t,{},t.Rx)})(this,function(t,e,n){function r(){if(this.isDisposed)throw Error(m)}var i=n.Observable,o=i.prototype,s=n.Internals.AnonymousObservable,u=n.Subject,c=n.AsyncSubject,h=n.Observer,a=n.Internals.ScheduledObserver,l=n.Disposable.create,f=n.Disposable.empty,p=n.CompositeDisposable,d=n.Scheduler.currentThread,b=n.Internals.inherits,v=n.Internals.addProperties,m="Object has been disposed";o.multicast=function(t,e){var n=this;return"function"==typeof t?new s(function(r){var i=n.multicast(t());return new p(e(i).subscribe(r),i.connect())}):new E(n,t)},o.publish=function(t){return t?this.multicast(function(){return new u},t):this.multicast(new u)},o.publishLast=function(t){return t?this.multicast(function(){return new c},t):this.multicast(new c)},o.publishValue=function(t,e){return 2===arguments.length?this.multicast(function(){return new w(e)},t):this.multicast(new w(t))},o.replay=function(t,e,n,r){return t?this.multicast(function(){return new g(e,n,r)},t):this.multicast(new g(e,n,r))};var y=function(t,e){this.subject=t,this.observer=e};y.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var t=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(t,1),this.observer=null}};var w=Rx.BehaviorSubject=function(t){function e(t){var e;return r.call(this),this.isStopped?(e=this.exception,e?t.onError(e):t.onCompleted(),f):(this.observers.push(t),t.onNext(this.value),new y(this,t))}function n(n){t.call(this,e),this.value=n,this.observers=[],this.isDisposed=!1,this.isStopped=!1,this.exception=null}return b(n,t),v(n.prototype,h,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(r.call(this),!this.isStopped){var t=this.observers.slice(0);this.isStopped=!0;for(var e=0,n=t.length;n>e;e++)t[e].onCompleted();this.observers=[]}},onError:function(t){if(r.call(this),!this.isStopped){var e=this.observers.slice(0);this.isStopped=!0,this.exception=t;for(var n=0,i=e.length;i>n;n++)e[n].onError(t);this.observers=[]}},onNext:function(t){if(r.call(this),!this.isStopped){this.value=t;for(var e=this.observers.slice(0),n=0,i=e.length;i>n;n++)e[n].onNext(t)}},dispose:function(){this.isDisposed=!0,this.observers=null,this.value=null,this.exception=null}}),n}(i),g=Rx.ReplaySubject=function(){function t(t){var e=new a(this.scheduler,t),i=new n(this,e);r.call(this),this._trim(this.scheduler.now()),this.observers.push(e);for(var o=this.q.length,s=0,u=this.q.length;u>s;s++)e.onNext(this.q[s].value);return this.hasError?(o++,e.onError(this.error)):this.isStopped&&(o++,e.onCompleted()),e.ensureActive(o),i}function e(e,n,r){this.bufferSize=null==e?Number.MAX_VALUE:e,this.window=null==n?Number.MAX_VALUE:n,this.scheduler=r||d,this.q=[],this.observers=[],this.isStopped=!1,this.isDisposed=!1,this.hasError=!1,this.error=null,_super.call(this,t)}var n=function(t,e){this.subject=t,this.observer=e};return n.prototype.dispose=function(){if(this.observer.dispose(),!this.subject.isDisposed){var t=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(t,1)}},b(e,_super),v(e.prototype,h,{hasObservers:function(){return this.observers.length>0},_trim:function(t){for(;this.q.length>this.bufferSize;)this.q.shift();for(;this.q.length>0&&t-this.q[0].interval>this.window;)this.q.shift()},onNext:function(t){var e;if(r.call(this),!this.isStopped){var n=this.scheduler.now();this.q.push({interval:n,value:t}),this._trim(n);for(var i=this.observers.slice(0),o=0,s=i.length;s>o;o++)e=i[o],e.onNext(t),e.ensureActive()}},onError:function(t){var e;if(r.call(this),!this.isStopped){this.isStopped=!0,this.error=t,this.hasError=!0;var n=this.scheduler.now();this._trim(n);for(var i=this.observers.slice(0),o=0,s=i.length;s>o;o++)e=i[o],e.onError(t),e.ensureActive();this.observers=[]}},onCompleted:function(){var t;if(r.call(this),!this.isStopped){this.isStopped=!0;var e=this.scheduler.now();this._trim(e);for(var n=this.observers.slice(0),i=0,o=n.length;o>i;i++)t=n[i],t.onCompleted(),t.ensureActive();this.observers=[]}},dispose:function(){this.isDisposed=!0,this.observers=null}}),e}(i),E=function(t){function e(e,n){function r(t){return i.subject.subscribe(t)}var i={subject:n,source:e.asObservable(),hasSubscription:!1,subscription:null};this.connect=function(){return i.hasSubscription||(i.hasSubscription=!0,i.subscription=new p(i.source.subscribe(i.subject),l(function(){i.hasSubscription=!1}))),i.subscription},t.call(this,r)}return b(e,t),e.prototype.connect=function(){return this.connect()},e.prototype.refCount=function(){var t=null,e=0,n=this;return new s(function(r){var i,o;return e++,i=1===e,o=n.subscribe(r),i&&(t=n.connect()),l(function(){o.dispose(),e--,0===e&&t.dispose()})})},e}(i);return n});
+(function(t,e){var n="object"==typeof exports&&exports&&("object"==typeof t&&t&&t==t.global&&(window=t),exports);"function"==typeof define&&define.amd?define(["rx","exports"],function(n,r){return t.Rx=e(t,r,n),t.Rx}):"object"==typeof module&&module&&module.exports==n?module.exports=e(t,module.exports,require("./rx")):t.Rx=e(t,{},t.Rx)})(this,function(t,e,n){function r(){if(this.isDisposed)throw Error(m)}var i=n.Observable,o=i.prototype,s=n.Internals.AnonymousObservable,u=n.Subject,c=n.AsyncSubject,h=n.Observer,a=n.Internals.ScheduledObserver,l=n.Disposable.create,f=n.Disposable.empty,p=n.CompositeDisposable,d=n.Scheduler.currentThread,b=n.Internals.inherits,v=n.Internals.addProperties,m="Object has been disposed";o.multicast=function(t,e){var n=this;return"function"==typeof t?new s(function(r){var i=n.multicast(t());return new p(e(i).subscribe(r),i.connect())}):new E(n,t)},o.publish=function(t){return t?this.multicast(function(){return new u},t):this.multicast(new u)},o.publishLast=function(t){return t?this.multicast(function(){return new c},t):this.multicast(new c)},o.publishValue=function(t,e){return 2===arguments.length?this.multicast(function(){return new w(e)},t):this.multicast(new w(t))},o.replay=function(t,e,n,r){return t?this.multicast(function(){return new g(e,n,r)},t):this.multicast(new g(e,n,r))};var y=function(t,e){this.subject=t,this.observer=e};y.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var t=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(t,1),this.observer=null}};var w=Rx.BehaviorSubject=function(t){function e(t){var e;return r.call(this),this.isStopped?(e=this.exception,e?t.onError(e):t.onCompleted(),f):(this.observers.push(t),t.onNext(this.value),new y(this,t))}function n(n){t.call(this,e),this.value=n,this.observers=[],this.isDisposed=!1,this.isStopped=!1,this.exception=null}return b(n,t),v(n.prototype,h,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(r.call(this),!this.isStopped){var t=this.observers.slice(0);this.isStopped=!0;for(var e=0,n=t.length;n>e;e++)t[e].onCompleted();this.observers=[]}},onError:function(t){if(r.call(this),!this.isStopped){var e=this.observers.slice(0);this.isStopped=!0,this.exception=t;for(var n=0,i=e.length;i>n;n++)e[n].onError(t);this.observers=[]}},onNext:function(t){if(r.call(this),!this.isStopped){this.value=t;for(var e=this.observers.slice(0),n=0,i=e.length;i>n;n++)e[n].onNext(t)}},dispose:function(){this.isDisposed=!0,this.observers=null,this.value=null,this.exception=null}}),n}(i),g=Rx.ReplaySubject=function(t){function e(t){var e=new a(this.scheduler,t),n=new i(this,e);r.call(this),this._trim(this.scheduler.now()),this.observers.push(e);for(var o=this.q.length,s=0,u=this.q.length;u>s;s++)e.onNext(this.q[s].value);return this.hasError?(o++,e.onError(this.error)):this.isStopped&&(o++,e.onCompleted()),e.ensureActive(o),n}function n(n,r,i){this.bufferSize=null==n?Number.MAX_VALUE:n,this.window=null==r?Number.MAX_VALUE:r,this.scheduler=i||d,this.q=[],this.observers=[],this.isStopped=!1,this.isDisposed=!1,this.hasError=!1,this.error=null,t.call(this,e)}var i=function(t,e){this.subject=t,this.observer=e};return i.prototype.dispose=function(){if(this.observer.dispose(),!this.subject.isDisposed){var t=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(t,1)}},b(n,t),v(n.prototype,h,{hasObservers:function(){return this.observers.length>0},_trim:function(t){for(;this.q.length>this.bufferSize;)this.q.shift();for(;this.q.length>0&&t-this.q[0].interval>this.window;)this.q.shift()},onNext:function(t){var e;if(r.call(this),!this.isStopped){var n=this.scheduler.now();this.q.push({interval:n,value:t}),this._trim(n);for(var i=this.observers.slice(0),o=0,s=i.length;s>o;o++)e=i[o],e.onNext(t),e.ensureActive()}},onError:function(t){var e;if(r.call(this),!this.isStopped){this.isStopped=!0,this.error=t,this.hasError=!0;var n=this.scheduler.now();this._trim(n);for(var i=this.observers.slice(0),o=0,s=i.length;s>o;o++)e=i[o],e.onError(t),e.ensureActive();this.observers=[]}},onCompleted:function(){var t;if(r.call(this),!this.isStopped){this.isStopped=!0;var e=this.scheduler.now();this._trim(e);for(var n=this.observers.slice(0),i=0,o=n.length;o>i;i++)t=n[i],t.onCompleted(),t.ensureActive();this.observers=[]}},dispose:function(){this.isDisposed=!0,this.observers=null}}),n}(i),E=function(t){function e(e,n){function r(t){return i.subject.subscribe(t)}var i={subject:n,source:e.asObservable(),hasSubscription:!1,subscription:null};this.connect=function(){return i.hasSubscription||(i.hasSubscription=!0,i.subscription=new p(i.source.subscribe(i.subject),l(function(){i.hasSubscription=!1}))),i.subscription},t.call(this,r)}return b(e,t),e.prototype.connect=function(){return this.connect()},e.prototype.refCount=function(){var t=null,e=0,n=this;return new s(function(r){var i,o;return e++,i=1===e,o=n.subscribe(r),i&&(t=n.connect()),l(function(){o.dispose(),e--,0===e&&t.dispose()})})},e}(i);return n});
View
66 rx.joinpatterns.js
@@ -236,13 +236,17 @@
}
};
- // Join Observer
- var JoinObserver = (function () {
+ /** @private */
+ var JoinObserver = (function (_super) {
- inherits(JoinObserver, AbstractObserver);
+ inherits(JoinObserver, _super);
+ /**
+ * @constructor
+ * @private
+ */
function JoinObserver(source, onError) {
- JoinObserver.super_.constructor.call(this);
+ _super.call(this);
this.source = source;
this.onError = onError;
this.queue = [];
@@ -251,7 +255,13 @@
this.isDisposed = false;
}
- JoinObserver.prototype.next = function (notification) {
+ var JoinObserverPrototype = JoinObserver.prototype;
+
+ /**
+ * @memberOf JoinObserver#
+ * @private
+ */
+ JoinObserverPrototype.next = function (notification) {
if (!this.isDisposed) {
if (notification.kind === 'E') {
this.onError(notification.exception);
@@ -264,31 +274,61 @@
}
}
};
- JoinObserver.prototype.error = noop;
- JoinObserver.prototype.completed = noop;
- JoinObserver.prototype.addActivePlan = function (activePlan) {
+ /**
+ * @memberOf JoinObserver#
+ * @private
+ */
+ JoinObserverPrototype.error = noop;
+
+ /**
+ * @memberOf JoinObserver#
+ * @private
+ */
+ JoinObserverPrototype.completed = noop;
+
+ /**
+ * @memberOf JoinObserver#
+ * @private
+ */
+ JoinObserverPrototype.addActivePlan = function (activePlan) {
this.activePlans.push(activePlan);
};
- JoinObserver.prototype.subscribe = function () {
+
+ /**
+ * @memberOf JoinObserver#
+ * @private
+ */
+ JoinObserverPrototype.subscribe = function () {
this.subscription.disposable(this.source.materialize().subscribe(this));
};
- JoinObserver.prototype.removeActivePlan = function (activePlan) {
+
+ /**
+ * @memberOf JoinObserver#
+ * @private
+ */
+ JoinObserverPrototype.removeActivePlan = function (activePlan) {
var idx = this.activePlans.indexOf(activePlan);
this.activePlans.splice(idx, 1);
if (this.activePlans.length === 0) {
this.dispose();
}
};
- JoinObserver.prototype.dispose = function () {
- JoinObserver.super_.dispose.call(this);
+
+ /**
+ * @memberOf JoinObserver#
+ * @private
+ */
+ JoinObserverPrototype.dispose = function () {
+ _super.prototype.dispose.call(this);
if (!this.isDisposed) {
this.isDisposed = true;
this.subscription.dispose();
}
};
+
return JoinObserver;
- } ());
+ } (AbstractObserver));
// Observable extensions
View
2  rx.joinpatterns.min.js
@@ -1 +1 @@
-(function(t,e){var n="object"==typeof exports&&exports&&("object"==typeof t&&t&&t==t.global&&(window=t),exports);"function"==typeof define&&define.amd?define(["rx","exports"],function(n,r){return t.Rx=e(t,r,n),t.Rx}):"object"==typeof module&&module&&module.exports==n?module.exports=e(t,module.exports,require("./rx")):t.Rx=e(t,{},t.Rx)})(this,function(t,e,n){function r(){}function i(t,e){return 1===t.length&&Array.isArray(t[e])?t[e]:y.call(t)}function o(t){this.patterns=t}function s(t,e){this.expression=t,this.selector=e}function u(t,e,n){var r=t.get(e);if(!r){var i=new g(e,n);return t.set(e,i),i}return r}function c(t,e,n){var r,i;for(this.joinObserverArray=t,this.onNext=e,this.onCompleted=n,this.joinObservers=new w,r=0;this.joinObserverArray.length>r;r++)i=this.joinObserverArray[r],this.joinObservers.set(i,i)}var h=n.Observable,a=h.prototype,l=n.Internals.AnonymousObservable,f=h.throwException,p=n.Observer.create,d=n.SingleAssignmentDisposable,b=n.CompositeDisposable,v=n.Internals.AbstractObserver,m=n.Internals.inherits,y=Array.prototype.slice,w=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 s(this,t)},s.prototype.activate=function(t,e,n){for(var r=this,i=[],o=0,s=this.expression.patterns.length;s>o;o++)i.push(u(t,this.expression.patterns[o],e.onError.bind(e)));var h=new c(i,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=i.length;e>t;t++)i[t].removeActivePlan(h);n(h)});for(o=0,s=i.length;s>o;o++)i[o].addActivePlan(h);return h},c.prototype.dequeue=function(){for(var t=this.joinObservers.getValues(),e=0,n=t.length;n>e;e++)t[e].queue.shift()},c.prototype.match=function(){var t,e,n,r,i,o=!0;for(e=0,n=this.joinObserverArray.length;n>e;e++)if(0===this.joinObserverArray[e].queue.length){o=!1;break}if(o){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(),i=[],e=0;t.length>e;e++)i.push(t[e].value);this.onNext.apply(this,i)}}};var g=function(){function t(e,n){t.super_.constructor.call(this),this.source=e,this.onError=n,this.queue=[],this.activePlans=[],this.subscription=new d,this.isDisposed=!1}return m(t,v),t.prototype.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()}},t.prototype.error=r,t.prototype.completed=r,t.prototype.addActivePlan=function(t){this.activePlans.push(t)},t.prototype.subscribe=function(){this.subscription.disposable(this.source.materialize().subscribe(this))},t.prototype.removeActivePlan=function(t){var e=this.activePlans.indexOf(t);this.activePlans.splice(e,1),0===this.activePlans.length&&this.dispose()},t.prototype.dispose=function(){t.super_.dispose.call(this),this.isDisposed||(this.isDisposed=!0,this.subscription.dispose())},t}();return a.and=function(t){return new o([this,t])},a.then=function(t){return new o([this]).then(t)},h.when=function(){var t=i(arguments,0);return new l(function(e){var n,r,i,o,s,u,c=[],h=new w;u=p(e.onNext.bind(e),function(t){for(var n=h.getValues(),r=0,i=n.length;i>r;r++)n[r].onError(t);e.onError(t)},e.onCompleted.bind(e));try{for(r=0,i=t.length;i>r;r++)c.push(t[r].activate(h,u,function(t){var e=c.indexOf(t);c.splice(e,1),0===c.length&&u.onCompleted()}))}catch(a){f(a).subscribe(e)}for(n=new b,s=h.getValues(),r=0,i=s.length;i>r;r++)o=s[r],o.subscribe(),n.add(o);return n})},n});
+(function(t,e){var n="object"==typeof exports&&exports&&("object"==typeof t&&t&&t==t.global&&(window=t),exports);"function"==typeof define&&define.amd?define(["rx","exports"],function(n,r){return t.Rx=e(t,r,n),t.Rx}):"object"==typeof module&&module&&module.exports==n?module.exports=e(t,module.exports,require("./rx")):t.Rx=e(t,{},t.Rx)})(this,function(t,e,n){function r(){}function i(t,e){return 1===t.length&&Array.isArray(t[e])?t[e]:y.call(t)}function o(t){this.patterns=t}function s(t,e){this.expression=t,this.selector=e}function u(t,e,n){var r=t.get(e);if(!r){var i=new g(e,n);return t.set(e,i),i}return r}function c(t,e,n){var r,i;for(this.joinObserverArray=t,this.onNext=e,this.onCompleted=n,this.joinObservers=new w,r=0;this.joinObserverArray.length>r;r++)i=this.joinObserverArray[r],this.joinObservers.set(i,i)}var h=n.Observable,a=h.prototype,l=n.Internals.AnonymousObservable,f=h.throwException,p=n.Observer.create,d=n.SingleAssignmentDisposable,b=n.CompositeDisposable,v=n.Internals.AbstractObserver,m=n.Internals.inherits,y=Array.prototype.slice,w=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 s(this,t)},s.prototype.activate=function(t,e,n){for(var r=this,i=[],o=0,s=this.expression.patterns.length;s>o;o++)i.push(u(t,this.expression.patterns[o],e.onError.bind(e)));var h=new c(i,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=i.length;e>t;t++)i[t].removeActivePlan(h);n(h)});for(o=0,s=i.length;s>o;o++)i[o].addActivePlan(h);return h},c.prototype.dequeue=function(){for(var t=this.joinObservers.getValues(),e=0,n=t.length;n>e;e++)t[e].queue.shift()},c.prototype.match=function(){var t,e,n,r,i,o=!0;for(e=0,n=this.joinObserverArray.length;n>e;e++)if(0===this.joinObserverArray[e].queue.length){o=!1;break}if(o){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(),i=[],e=0;t.length>e;e++)i.push(t[e].value);this.onNext.apply(this,i)}}};var g=function(t){function e(e,n){t.call(this),this.source=e,this.onError=n,this.queue=[],this.activePlans=[],this.subscription=new d,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=r,n.completed=r,n.addActivePlan=function(t){this.activePlans.push(t)},n.subscribe=function(){this.subscription.disposable(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}(v);return a.and=function(t){return new o([this,t])},a.then=function(t){return new o([this]).then(t)},h.when=function(){var t=i(arguments,0);return new l(function(e){var n,r,i,o,s,u,c=[],h=new w;u=p(e.onNext.bind(e),function(t){for(var n=h.getValues(),r=0,i=n.length;i>r;r++)n[r].onError(t);e.onError(t)},e.onCompleted.bind(e));try{for(r=0,i=t.length;i>r;r++)c.push(t[r].activate(h,u,function(t){var e=c.indexOf(t);c.splice(e,1),0===c.length&&u.onCompleted()}))}catch(a){f(a).subscribe(e)}for(n=new b,s=h.getValues(),r=0,i=s.length;i>r;r++)o=s[r],o.subscribe(),n.add(o);return n})},n});
View
102 rx.js
@@ -8,7 +8,7 @@
* @name Rx
* @type Object
*/
- var Rx = { Internals: {} };s
+ var Rx = { Internals: {} };
// Defaults
function noop() { }
@@ -29,6 +29,48 @@
}
}
+ var slice = Array.prototype.slice;
+ function argsOrArray(args, idx) {
+ return args.length === 1 && Array.isArray(args[idx]) ?
+ args[idx] :
+ slice.call(args);
+ }
+ var hasProp = {}.hasOwnProperty;
+
+ /** @private */
+ var inherits = this.inherits = Rx.Internals.inherits = function (child, parent) {
+ function __() { this.constructor = child; }
+ __.prototype = parent.prototype;
+ child.prototype = new __();
+ };
+
+ /** @private */
+ var addProperties = Rx.Internals.addProperties = function (obj) {
+ var sources = slice.call(arguments, 1);
+ for (var i = 0, len = sources.length; i < len; i++) {
+ var source = sources[i];
+ for (var prop in source) {
+ obj[prop] = source[prop];
+ }
+ }
+ };
+
+ // Rx Utils
+ var addRef = Rx.Internals.addRef = function (xs, r) {
+ return new AnonymousObservable(function (observer) {
+ return new CompositeDisposable(r.getDisposable(), xs.subscribe(observer));
+ });
+ };
+
+ // Collection polyfills
+ function arrayInitialize(count, factory) {
+ var a = new Array(count);
+ for (var i = 0; i < count; i++) {
+ a[i] = factory();
+ }
+ return a;
+ }
+
// Utilities
if (!Function.prototype.bind) {
Function.prototype.bind = function (that) {
@@ -254,7 +296,7 @@
*
* @param {Mixed} item Disposable to add.
*/
- CompositeDisposablePrototypeadd = function (item) {
+ CompositeDisposablePrototype.add = function (item) {
if (this.isDisposed) {
item.dispose();
} else {
@@ -1099,7 +1141,7 @@
}());
/** Provides a set of extension methods for virtual time scheduling. */
- root.VirtualTimeScheduler = (function () {
+ Rx.VirtualTimeScheduler = (function (_super) {
function localNow() {
return this.toDateTimeOffset(this.clock);
@@ -1122,7 +1164,7 @@
return disposableEmpty;
}
- inherits(VirtualTimeScheduler, Scheduler);
+ inherits(VirtualTimeScheduler, _super);
/**
* Creates a new virtual time scheduler with the specified initial clock value and absolute time comparer.
@@ -1136,7 +1178,7 @@
this.comparer = comparer;
this.isEnabled = false;
this.queue = new PriorityQueue(1024);
- VirtualTimeScheduler.super_.constructor.call(this, localNow, scheduleNow, scheduleRelative, scheduleAbsolute);
+ _super.call(this, localNow, scheduleNow, scheduleRelative, scheduleAbsolute);
}
var VirtualTimeSchedulerPrototype = VirtualTimeScheduler.prototype;
@@ -1331,7 +1373,7 @@
}
return VirtualTimeScheduler;
- }());
+ }(Scheduler));
/** Provides a virtual time scheduler that uses Date for absolute time and number for relative time. */
Rx.HistoricalScheduler = (function (_super) {
@@ -1347,7 +1389,7 @@
function HistoricalScheduler(initialClock, comparer) {
var clock = initialClock == null ? 0 : initialClock;
var cmp = comparer || defaultSubComparer;
- super_.call(this, clock, cmp);
+ _super.call(this, clock, cmp);
}
var HistoricalSchedulerProto = HistoricalScheduler.prototype;
@@ -4154,9 +4196,14 @@
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
});
};
+ /** @private */
var AnonymousObservable = Rx.Internals.AnonymousObservable = (function (_super) {
inherits(AnonymousObservable, _super);
+ /**
+ * @private
+ * @constructor
+ */
function AnonymousObservable(subscribe) {
function s(observer) {
@@ -4184,24 +4231,33 @@
return autoDetachObserver;
}
- super_.call(this, s);
+ _super.call(this, s);
}
return AnonymousObservable;
}(Observable));
+ /** @private */
var AutoDetachObserver = (function (_super) {
inherits(AutoDetachObserver, _super);
+ /**
+ * @private
+ * @constructor
+ */
function AutoDetachObserver(observer) {
- AutoDetachObserver.super_.constructor.call(this);
+ _super.call(this);
this.observer = observer;
this.m = new SingleAssignmentDisposable();
}
var AutoDetachObserverPrototype = AutoDetachObserver.prototype
+ /**
+ * @private
+ * @memberOf AutoDetachObserver#
+ */
AutoDetachObserverPrototype.next = function (value) {
var noError = false;
try {
@@ -4216,6 +4272,10 @@
}
};
+ /**
+ * @private
+ * @memberOf AutoDetachObserver#
+ */
AutoDetachObserverPrototype.error = function (exn) {
try {
this.observer.onError(exn);
@@ -4226,6 +4286,10 @@
}
};
+ /**
+ * @private
+ * @memberOf AutoDetachObserver#
+ */
AutoDetachObserverPrototype.completed = function () {
try {
this.observer.onCompleted();
@@ -4236,10 +4300,18 @@
}
};
+ /**
+ * @private
+ * @memberOf AutoDetachObserver#
+ */
AutoDetachObserverPrototype.disposable = function (value) {
return this.m.disposable(value);
};
+ /**
+ * @private
+ * @memberOf AutoDetachObserver#
+ */
AutoDetachObserverPrototype.dispose = function () {
_super.prototype.dispose.call(this);
this.m.dispose();
@@ -4295,7 +4367,7 @@
* Represents an object that is both an observable sequence as well as an observer.
* Each notification is broadcasted to all subscribed observers.
*/
- var Subject = root.Subject = (function (_super) {
+ var Subject = Rx.Subject = (function (_super) {
function subscribe(observer) {
checkDisposed.call(this);
if (!this.isStopped) {
@@ -4591,17 +4663,17 @@
// Check for AMD
if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
- window.Rx = root;
+ window.Rx = Rx;
return define(function () {
- return root;
+ return Rx;
});
} else if (freeExports) {
if (typeof module == 'object' && module && module.exports == freeExports) {
- module.exports = root;
+ module.exports = Rx;
} else {
- freeExports = root;
+ freeExports = Rx;
}
} else {
- window.Rx = root;
+ window.Rx = Rx;
}
}(this));
View
4 rx.min.js
@@ -1,2 +1,2 @@
-(function(t,e){function n(){}function r(t){return t}function i(){return(new Date).getTime()}function o(t,e){return t===e}function s(t,e){return t-e}function u(t){return""+t}function c(t){throw t}function a(){if(this.isDisposed)throw Error(w)}function h(t,e){this.scheduler=t,this.disposable=e,this.isDisposed=!1}function l(t,e,n,r,i){this.scheduler=t,this.state=e,this.action=n,this.dueTime=r,this.comparer=i||s,this.disposable=new O}function f(t,n){return new me(function(r){var i=new O,o=new k;return o.setDisposable(i),i.setDisposable(t.subscribe(r.onNext.bind(r),function(t){var i,s;try{s=n(t)}catch(u){return r.onError(u),e}i=new O,o.setDisposable(i),i.setDisposable(s.subscribe(r))},r.onCompleted.bind(r))),o})}function p(t,n){var r=this;return new me(function(i){var o=0,s=t.length;return r.subscribe(function(r){if(s>o){var u,c=t[o++];try{u=n(r,c)}catch(a){return i.onError(a),e}i.onNext(u)}else i.onCompleted()},i.onError.bind(i),i.onCompleted.bind(i))})}function d(t){return this.select(t).mergeObservable()}var b="object"==typeof exports&&exports&&("object"==typeof global&&global&&global==global.global&&(t=global),exports),v={Internals:{}},m="Sequence contains no elements.",y="Argument out of range",w="Object has been disposed";Function.prototype.bind||(Function.prototype.bind=function(t){var e=this,n=slice.call(arguments,1),r=function(){function i(){}if(this instanceof r){i.prototype=e.prototype;var o=new i,s=e.apply(o,n.concat(slice.call(arguments)));return Object(s)===s?s:o}return e.apply(t,n.concat(slice.call(arguments)))};return r});var g=Object("a"),E="a"!=g[0]||!(0 in g);Array.prototype.every||(Array.prototype.every=function(t){var e=Object(this),n=E&&"[object String]"=={}.toString.call(this)?this.split(""):e,r=n.length>>>0,i=arguments[1];if("[object Function]"!={}.toString.call(t))throw new TypeError(t+" is not a function");for(var o=0;r>o;o++)if(o in n&&!t.call(i,n[o],o,e))return!1;return!0}),Array.prototype.map||(Array.prototype.map=function(t){var e=Object(this),n=E&&"[object String]"=={}.toString.call(this)?this.split(""):e,r=n.length>>>0,i=Array(r),o=arguments[1];if("[object Function]"!={}.toString.call(t))throw new TypeError(t+" is not a function");for(var s=0;r>s;s++)s in n&&(i[s]=t.call(o,n[s],s,e));return i}),Array.prototype.filter||(Array.prototype.filter=function(t){for(var e,n=[],r=Object(this),i=0,o=r.length>>>0;o>i;i++)e=r[i],i in r&&t.call(arguments[1],e,i,r)&&n.push(e);return n}),Array.isArray||(Array.isArray=function(t){return"[object Array]"==Object.prototype.toString.call(t)}),Array.prototype.indexOf||(Array.prototype.indexOf=function(t){var e=Object(this),n=e.length>>>0;if(0===n)return-1;var r=0;if(arguments.length>1&&(r=Number(arguments[1]),r!=r?r=0:0!=r&&1/0!=r&&r!=-1/0&&(r=(r>0||-1)*Math.floor(Math.abs(r)))),r>=n)return-1;for(var i=r>=0?r:Math.max(n-Math.abs(r),0);n>i;i++)if(i in e&&e[i]===t)return i;return-1});var x=function(t,e){this.id=t,this.value=e};x.prototype.compareTo=function(t){var e=this.value.compareTo(t.value);return 0===e&&(e=this.id-t.id),e};var C=function(t){this.items=Array(t),this.length=0},A=C.prototype;A.isHigherPriority=function(t,e){return 0>this.items[t].compareTo(this.items[e])},A.percolate=function(t){if(!(t>=this.length||0>t)){var e=t-1>>1;if(!(0>e||e===t)&&this.isHigherPriority(t,e)){var n=this.items[t];this.items[t]=this.items[e],this.items[e]=n,this.percolate(e)}}},A.heapify=function(t){if(t===e&&(t=0),!(t>=this.length||0>t)){var n=2*t+1,r=2*t+2,i=t;if(this.length>n&&this.isHigherPriority(n,i)&&(i=n),this.length>r&&this.isHigherPriority(r,i)&&(i=r),i!==t){var o=this.items[t];this.items[t]=this.items[i],this.items[i]=o,this.heapify(i)}}},A.peek=function(){return this.items[0].value},A.removeAt=function(t){this.items[t]=this.items[--this.length],delete this.items[this.length],this.heapify()},A.dequeue=function(){var t=this.peek();return this.removeAt(0),t},A.enqueue=function(t){var e=this.length++;this.items[e]=new x(C.count++,t),this.percolate(e)},A.remove=function(t){for(var e=0;this.length>e;e++)if(this.items[e].value===t)return this.removeAt(e),!0;return!1},C.count=0;var D=v.CompositeDisposable=function(){this.disposables=argsOrArray(arguments,0),this.isDisposed=!1,this.length=this.disposables.length},_=D.prototype;CompositeDisposablePrototypeadd=function(t){this.isDisposed?t.dispose():(this.disposables.push(t),this.length++)},_.remove=function(t){var e=!1;if(!this.isDisposed){var n=this.disposables.indexOf(t);-1!==n&&(e=!0,this.disposables.splice(n,1),this.length--,t.dispose())}return e},_.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var t=this.disposables.slice(0);this.disposables=[],this.length=0;for(var e=0,n=t.length;n>e;e++)t[e].dispose()}},_.clear=function(){var t=this.disposables.slice(0);this.disposables=[],this.length=0;for(var e=0,n=t.length;n>e;e++)t[e].dispose()},_.contains=function(t){return-1!==this.disposables.indexOf(t)},_.toArray=function(){return this.disposables.slice(0)};var S=v.Disposable=function(t){this.isDisposed=!1,this.action=t};S.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var N=S.create=function(t){return new S(t)},R=S.empty={dispose:n},O=v.SingleAssignmentDisposable=function(){this.isDisposed=!1,this.current=null},W=O.prototype;W.disposable=function(t){return t?this.setDisposable(t):this.getDisposable()},W.getDisposable=function(){return this.current},W.setDisposable=function(t){if(this.current)throw Error("Disposable has already been assigned");var e=this.isDisposed;e||(this.current=t),e&&t&&t.dispose()},W.dispose=function(){var t;this.isDisposed||(this.isDisposed=!0,t=this.current,this.current=null),t&&t.dispose()};var k=v.SerialDisposable=function(){this.isDisposed=!1,this.current=null};k.prototype.getDisposable=function(){return this.current},k.prototype.setDisposable=function(t){var e,n=this.isDisposed;n||(e=this.current,this.current=t),e&&e.dispose(),n&&t&&t.dispose()},k.prototype.disposable=function(t){return t?(this.setDisposable(t),e):this.getDisposable()},k.prototype.dispose=function(){var t;this.isDisposed||(this.isDisposed=!0,t=this.current,this.current=null),t&&t.dispose()};var q=v.RefCountDisposable=function(){function t(t){this.disposable=t,this.disposable.count++,this.isInnerDisposed=!1}function e(t){this.underlyingDisposable=t,this.isDisposed=!1,this.isPrimaryDisposed=!1,this.count=0}return t.prototype.dispose=function(){this.disposable.isDisposed||this.isInnerDisposed||(this.isInnerDisposed=!0,this.disposable.count--,0===this.disposable.count&&this.disposable.isPrimaryDisposed&&(this.disposable.isDisposed=!0,this.disposable.underlyingDisposable.dispose()))},e.prototype.dispose=function(){this.isDisposed||this.isPrimaryDisposed||(this.isPrimaryDisposed=!0,0===this.count&&(this.isDisposed=!0,this.underlyingDisposable.dispose()))},e.prototype.getDisposable=function(){return this.isDisposed?R:new t(this)},e}();h.prototype.dispose=function(){var t=this;this.scheduler.schedule(function(){t.isDisposed||(t.isDisposed=!0,t.disposable.dispose())})},l.prototype.invoke=function(){this.disposable.disposable(this.invokeCore())},l.prototype.compareTo=function(t){return this.comparer(this.dueTime,t.dueTime)},l.prototype.isCancelled=function(){return this.disposable.isDisposed},l.prototype.invokeCore=function(){return this.action(this.scheduler,this.state)};var T=v.Scheduler=function(){function e(t,e,n,r){this.now=t,this._schedule=e,this._scheduleRelative=n,this._scheduleAbsolute=r}function n(t,e){var n=e.first,r=e.second,i=new D,o=function(e){r(e,function(e){var n=!1,r=!1,s=t.scheduleWithState(e,function(t,e){return n?i.remove(s):r=!0,o(e),R});r||(i.add(s),n=!0)})};return o(n),i}function r(t,e,n){var r=e.first,i=e.second,o=new D,s=function(e){i(e,function(e,r){var i=!1,u=!1,c=t[n].call(t,e,r,function(t,e){return i?o.remove(c):u=!0,s(e),R});u||(o.add(c),i=!0)})};return s(r),o}function o(t,e){return e(),R}var s=e.prototype;return s.catchException=function(t){return new F(this,t)},s.schedulePeriodic=function(t,e){return this.schedulePeriodicWithState(null,t,function(){e()})},s.schedulePeriodicWithState=function(e,n,r){var i=e,o=t.setInterval(function(){i=r(i)},n);return N(function(){t.clearInterval(o)})},s.schedule=function(t){return this._schedule(t,o)},s.scheduleWithState=function(t,e){return this._schedule(t,e)},s.scheduleWithRelative=function(t,e){return this._scheduleRelative(e,t,o)},s.scheduleWithRelativeAndState=function(t,e,n){return this._scheduleRelative(t,e,n)},s.scheduleWithAbsolute=function(t,e){return this._scheduleAbsolute(e,t,o)},s.scheduleWithAbsoluteAndState=function(t,e,n){return this._scheduleAbsolute(t,e,n)},s.scheduleRecursive=function(t){return this.scheduleRecursiveWithState(t,function(t,e){t(function(){e(t)})})},s.scheduleRecursiveWithState=function(t,e){return this.scheduleWithState({first:t,second:e},function(t,e){return n(t,e)})},s.scheduleRecursiveWithRelative=function(t,e){return this.scheduleRecursiveWithRelativeAndState(e,t,function(t,e){t(function(n){e(t,n)})})},s.scheduleRecursiveWithRelativeAndState=function(t,e,n){return this._scheduleRelative({first:t,second:n},e,function(t,e){return r(t,e,"scheduleWithRelativeAndState")})},s.scheduleRecursiveWithAbsolute=function(t,e){return this.scheduleRecursiveWithAbsoluteAndState(e,t,function(t,e){t(function(n){e(t,n)})})},s.scheduleRecursiveWithAbsoluteAndState=function(t,e,n){return this._scheduleAbsolute({first:t,second:n},e,function(t,e){return r(t,e,"scheduleWithAbsoluteAndState")})},e.now=i,e.normalize=function(t){return 0>t&&(t=0),t},e}(),j="Scheduler is not allowed to block the thread",I=T.immediate=function(){function t(t,e){return e(this,t)}function e(t,e,n){if(e>0)throw Error(j);return n(this,t)}function n(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new T(i,t,e,n)}(),P=T.currentThread=function(){function t(){o=new C(4)}function e(t,e){return this.scheduleWithRelativeAndState(t,0,e)}function n(e,n,r){var i,s=this.now()+T.normalize(n),u=new l(this,e,r,s);if(o)o.enqueue(u);else{i=new t;try{o.enqueue(u),i.run()}catch(c){throw c}finally{i.dispose()}}return u.disposable}function r(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}var o;t.prototype.dispose=function(){o=null},t.prototype.run=function(){for(var t;o.length>0;)if(t=o.dequeue(),!t.isCancelled()){for(;t.dueTime-T.now()>0;);t.isCancelled()||t.invoke()}};var s=new T(i,e,n,r);return s.scheduleRequired=function(){return null===o},s.ensureTrampoline=function(t){return null===o?this.schedule(t):t()},s}(),z=function(){function t(t,e){e(0,this._period);try{this._state=this._action(this._state)}catch(n){throw this._cancel.dispose(),n}}function e(t,e,n,r){this._scheduler=t,this._state=e,this._period=n,this._action=r}return e.prototype.start=function(){var e=new O;return this._cancel=e,e.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,t.bind(this))),e},e}();root.VirtualTimeScheduler=function(){function t(){return this.toDateTimeOffset(this.clock)}function n(t,e){return this.scheduleAbsoluteWithState(t,this.clock,e)}function r(t,e,n){return this.scheduleRelativeWithState(t,this.toRelative(e),n)}function i(t,e,n){return this.scheduleRelativeWithState(t,this.toRelative(e-this.now()),n)}function o(t,e){return e(),R}function s(e,o){this.clock=e,this.comparer=o,this.isEnabled=!1,this.queue=new C(1024),s.super_.constructor.call(this,t,n,r,i)}inherits(s,T);var u=s.prototype;return u.schedulePeriodicWithState=function(t,e,n){var r=new z(this,t,e,n);return r.start()},u.scheduleRelativeWithState=function(t,e,n){var r=this.add(this.clock,e);return this.scheduleAbsoluteWithState(t,r,n)},u.scheduleRelative=function(t,e){return this.scheduleRelativeWithState(e,t,o)},u.start=function(){var t;if(!this.isEnabled){this.isEnabled=!0;do t=this.getNext(),null!==t?(this.comparer(t.dueTime,this.clock)>0&&(this.clock=t.dueTime),t.invoke()):this.isEnabled=!1;while(this.isEnabled)}},u.stop=function(){this.isEnabled=!1},u.advanceTo=function(t){var e,n=this.comparer(this.clock,t);if(this.comparer(this.clock,t)>0)throw Error(y);if(0!==n&&!this.isEnabled){this.isEnabled=!0;do e=this.getNext(),null!==e&&0>=this.comparer(e.dueTime,t)?(this.comparer(e.dueTime,this.clock)>0&&(this.clock=e.dueTime),e.invoke()):this.isEnabled=!1;while(this.isEnabled);this.clock=t}},u.advanceBy=function(t){var n=this.add(this.clock,t),r=this.comparer(this.clock,n);if(r>0)throw Error(y);return 0!==r?this.advanceTo(n):e},u.sleep=function(t){var e=this.add(this.clock,t);if(this.comparer(this.clock,e)>=0)throw Error(y);this.clock=e},u.getNext=function(){for(var t;this.queue.length>0;){if(t=this.queue.peek(),!t.isCancelled())return t;this.queue.dequeue()}return null},u.scheduleAbsolute=function(t,e){return this.scheduleAbsoluteWithState(e,t,o)},u.scheduleAbsoluteWithState=function(t,e,n){var r=this,i=function(t,e){return r.queue.remove(o),n(t,e)},o=new l(r,t,i,e,r.comparer);return r.queue.enqueue(o),o.disposable},s}(),v.HistoricalScheduler=function(t){function e(t,e){var n=null==t?0:t,r=e||s;super_.call(this,n,r)}inherits(e,t);var n=e.prototype;return n.add=function(t,e){return t+e},n.toDateTimeOffset=function(t){return new Date(t).getTime()},n.toRelative=function(t){return t},e}(v.VirtualTimeScheduler);var V=T.timeout=function(){function r(t,e){var n=this,r=new O,i=u(function(){r.setDisposable(e(n,t))});return new D(r,N(function(){c(i)}))}function o(e,n,r){var i=this,o=T.normalize(n);if(0===o)return i.scheduleWithState(e,r);var s=new O,u=t.setTimeout(function(){s.setDisposable(r(i,e))},o);return new D(s,N(function(){t.clearTimeout(u)}))}function s(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}var u,c,a="equestAnimationFrame",h="ancelAnimationFrame",l=t["r"+a]||t["webkitR"+a]||t["mozR"+a]||t["oR"+a]||t["msR"+a],f=t["c"+h]||t["webkitC"+h]||t["mozC"+h]||t["oC"+h]||t["msC"+h];return t.process!==e&&"function"==typeof t.process.nextTick?(u=t.process.nextTick,c=n):"function"==typeof t.setImmediate?(u=t.setImmediate,c=t.clearImmediate):"function"==typeof l?(u=l,c=f):(u=function(e){return t.setTimeout(e,0)},c=t.clearTimeout),new T(i,r,o,s)}(),F=function(t){function e(){return this._scheduler.now()}function n(t,e){return this._scheduler.scheduleWithState(t,this._wrap(e))}function r(t,e,n){return this._scheduler.scheduleWithRelativeAndState(t,e,this._wrap(n))}function i(t,e,n){return this._scheduler.scheduleWithAbsoluteAndState(t,e,this._wrap(n))}function o(o,s){this._scheduler=o,this._handler=s,this._recursiveOriginal=null,this._recursiveWrapper=null,t.call(this,e,n,r,i)}return inherits(o,t),o.prototype._clone=function(t){return new o(t,this._handler)},o.prototype._wrap=function(t){var e=this;return function(n,r){try{return t(e._getRecursiveWrapper(n),r)}catch(i){if(!e._handler(i))throw i;return R}}},o.prototype._getRecursiveWrapper=function(t){if(!this._recursiveOriginal!==t){this._recursiveOriginal=t;var e=this._clone(t);e._recursiveOriginal=t,e._recursiveWrapper=e,this._recursiveWrapper=e}return this._recursiveWrapper},o.prototype.schedulePeriodicWithState=function(t,e,n){var r=this,i=!1,o=new O;return o.setDisposable(this._scheduler.schedulePeriodicWithState(t,e,function(t){if(i)return null;try{return n(t)}catch(e){if(i=!0,!r._handler(e))throw e;return o.dispose(),null}})),o},o}(T),M=v.Notification=function(){function t(t,e){this.hasValue=null==e?!1:e,this.kind=t}var e=t.prototype;return e.accept=function(t,e,n){return 1===arguments.length&&"object"==typeof t?this._acceptObservable(t):this._accept(t,e,n)},e.toObservable=function(t){var e=this;return t=t||I,new me(function(n){return t.schedule(function(){e._acceptObservable(n),"N"===e.kind&&n.onCompleted()})})},e.equals=function(t){var e=null==t?"":""+t;return""+this===e},t}(),L=M.createOnNext=function(){function t(t){return t(this.value)}function e(t){return t.onNext(this.value)}function n(){return"OnNext("+this.value+")"}return function(r){var i=new M("N",!0);return i.value=r,i._accept=t.bind(i),i._acceptObservable=e.bind(i),i.toString=n.bind(i),i}}(),B=M.createOnError=function(){function t(t,e){return e(this.exception)}function e(t){return t.onError(this.exception)}function n(){return"OnError("+this.exception+")"}return function(r){var i=new M("E");return i.exception=r,i._accept=t.bind(i),i._acceptObservable=e.bind(i),i.toString=n.bind(i),i}}(),H=M.createOnCompleted=function(){function t(t,e,n){return n()}function e(t){return t.onCompleted()}function n(){return"OnCompleted()"}return function(){var r=new M("C");return r._accept=t.bind(r),r._acceptObservable=e.bind(r),r.toString=n.bind(r),r}}(),U=v.Internals.Enumerator=function(t,e,n){this.moveNext=t,this.getCurrent=e,this.dispose=n},G=U.create=function(t,e,r){var i=!1;return r||(r=n),new U(function(){if(i)return!1;var e=t();return e||(i=!0,r()),e},function(){return e()},function(){i||(r(),i=!0)})},J=v.Internals.Enumerable=function(){function t(t){this.getEnumerator=t}return t.prototype.concat=function(){var t=this;return new me(function(n){var r=t.getEnumerator(),i=!1,o=new k,s=I.scheduleRecursive(function(t){var s,u,c=!1;if(!i){try{c=r.moveNext(),c?s=r.getCurrent():r.dispose()}catch(a){u=a,r.dispose()}if(u)return n.onError(u),e;if(!c)return n.onCompleted(),e;var h=new O;o.setDisposable(h),h.setDisposable(s.subscribe(n.onNext.bind(n),n.onError.bind(n),function(){t()}))}});return new D(o,s,N(function(){i=!0,r.dispose()}))})},t.prototype.catchException=function(){var t=this;return new me(function(n){var r,i=t.getEnumerator(),o=!1,s=new k,u=I.scheduleRecursive(function(t){var u,c,a;if(a=!1,!o){try{a=i.moveNext(),a&&(u=i.getCurrent())}catch(h){c=h}if(c)return n.onError(c),e;if(!a)return r?n.onError(r):n.onCompleted(),e;var l=new O;s.setDisposable(l),l.setDisposable(u.subscribe(n.onNext.bind(n),function(e){r=e,t()},n.onCompleted.bind(n)))}});return new D(s,u,N(function(){o=!0}))})},t}(),K=J.repeat=function(t,n){return n===e&&(n=-1),new J(function(){var e,r=n;return G(function(){return 0===r?!1:(r>0&&r--,e=t,!0)},function(){return e})})},Q=J.forEach=function(t,e){return e||(e=r),new J(function(){var n,r=-1;return G(function(){return++r<t.length?(n=e(t[r],r),!0):!1},function(){return n})})},X=v.Observer=function(){};X.prototype.toNotifier=function(){var t=this;return function(e){return e.accept(t)}},X.prototype.asObserver=function(){return new te(this.onNext.bind(this),this.onError.bind(this),this.onCompleted.bind(this))},X.prototype.checked=function(){return new ee(this)};var Y=X.create=function(t,e,r){return t||(t=n),e||(e=c),r||(r=n),new te(t,e,r)};X.fromNotifier=function(t){return new te(function(e){return t(L(e))},function(e){return t(B(e))},function(){return t(H())})};var Z,$=v.Internals.AbstractObserver=function(t){function e(){this.isStopped=!1,t.call(this)}return inherits(e,t),e.prototype.onNext=function(t){this.isStopped||this.next(t)},e.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.error(t))},e.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.completed())},e.prototype.dispose=function(){this.isStopped=!0},e.prototype.fail=function(){return this.isStopped?!1:(this.isStopped=!0,this.error(!0),!0)},e}(X),te=v.AnonymousObserver=function(t){function e(e,n,r){t.call(this),this._onNext=e,this._onError=n,this._onCompleted=r}return inherits(e,t),e.prototype.next=function(t){this._onNext(t)},e.prototype.error=function(t){this._onError(t)},e.prototype.completed=function(){this._onCompleted()},e}($),ee=function(t){function e(e){t.call(this),this._observer=e,this._state=0}inherits(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}(X),ne=v.Internals.ScheduledObserver=function(t){function n(e,n){t.call(this),this.scheduler=e,this.observer=n,this.isAcquired=!1,this.hasFaulted=!1,this.queue=[],this.disposable=new k}return inherits(n,t),n.prototype.next=function(t){var e=this;this.queue.push(function(){e.observer.onNext(t)})},n.prototype.error=function(t){var e=this;this.queue.push(function(){e.observer.onError(t)})},n.prototype.completed=function(){var t=this;this.queue.push(function(){t.observer.onCompleted()})},n.prototype.ensureActive=function(){var t=!1,n=this;!this.hasFaulted&&this.queue.length>0&&(t=!this.isAcquired,this.isAcquired=!0),t&&this.disposable.setDisposable(this.scheduler.scheduleRecursive(function(t){var r;if(!(n.queue.length>0))return n.isAcquired=!1,e;r=n.queue.shift();try{r()}catch(i){throw n.queue=[],n.hasFaulted=!0,i}t()}))},n.prototype.dispose=function(){t.prototype.dispose.call(this),this.disposable.dispose()},n}($),re=function(t){function e(){t.apply(this,arguments)}return inherits(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}(ne),ie=v.Observable=function(){function t(t){this._subscribe=t}return Z=t.prototype,Z.finalValue=function(){var t=this;return new me(function(e){var n,r=!1;return t.subscribe(function(t){r=!0,n=t},e.onError.bind(e),function(){r?(e.onNext(n),e.onCompleted()):e.onError(Error(m))})})},Z.subscribe=Z.forEach=function(t,e,n){var r;return r="object"==typeof t?t:Y(t,e,n),this._subscribe(r)},Z.toArray=function(){function t(t,e){var n=t.slice(0);return n.push(e),n}return this.scan([],t).startWith([]).finalValue()},t}();ie.start=function(t,e){return oe(t,e)()};var oe=ie.toAsync=function(t,n,r){return n||(n=V),function(){var i=slice.call(arguments,0),o=new xe;return n.schedule(function(){var n;try{n=t.apply(r,i)}catch(s){return o.onError(s),e}o.onNext(n),o.onCompleted()}),o.asObservable()}};Z.observeOn=function(t){var e=this;return new me(function(n){return e.subscribe(new re(t,n))})},Z.subscribeOn=function(t){var e=this;return new me(function(n){var r=new O,i=new k;return i.setDisposable(r),r.setDisposable(t.schedule(function(){i.setDisposable(new h(t,e.subscribe(n)))})),i})},ie.create=function(t){return new me(function(e){return N(t(e))})},ie.createWithDisposable=function(t){return new me(t)};var se=ie.defer=function(t){return new me(function(e){var n;try{n=t()}catch(r){return le(r).subscribe(e)}return n.subscribe(e)})},ue=ie.empty=function(t){return t||(t=I),new me(function(e){return t.schedule(function(){e.onCompleted()})})},ce=ie.fromArray=function(t,e){return e||(e=P),new me(function(n){var r=0;return e.scheduleRecursive(function(e){t.length>r?(n.onNext(t[r++]),e()):n.onCompleted()})})};ie.generate=function(t,n,r,i,o){return o||(o=P),new me(function(s){var u=!0,c=t;return o.scheduleRecursive(function(t){var o,a;try{u?u=!1:c=r(c),o=n(c),o&&(a=i(c))}catch(h){return s.onError(h),e}o?(s.onNext(a),t()):s.onCompleted()})})};var ae=ie.never=function(){return new me(function(){return R})};ie.range=function(t,e,n){return n||(n=P),new me(function(r){return n.scheduleRecursiveWithState(0,function(n,i){e>n?(r.onNext(t+n),i(n+1)):r.onCompleted()})})},ie.repeat=function(t,n,r){return r||(r=P),n==e&&(n=-1),he(t,r).repeat(n)};var he=ie.returnValue=function(t,e){return e||(e=I),new me(function(n){return e.schedule(function(){n.onNext(t),n.onCompleted()})})},le=ie.throwException=function(t,e){return e||(e=I),new me(function(n){return e.schedule(function(){n.onError(t)})})};ie.using=function(t,e){return new me(function(n){var r,i,o=R;try{r=t(),r&&(o=r),i=e(r)}catch(s){return new D(le(s).subscribe(n),o)}return new D(i.subscribe(n),o)})},Z.amb=function(t){var e=this;return new me(function(n){function r(){o||(o=s,a.dispose())}function i(){o||(o=u,c.dispose())}var o,s="L",u="R",c=new O,a=new O;return 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 D(c,a)})},ie.amb=function(){function t(t,e){return t.amb(e)}for(var e=ae(),n=argsOrArray(arguments,0),r=0,i=n.length;i>r;r++)e=t(e,n[r]);return e},Z.catchException=function(t){return"function"==typeof t?f(this,t):fe([this,t])};var fe=ie.catchException=function(){var t=argsOrArray(arguments,0);return Q(t).catchException()};Z.combineLatest=function(){var t=slice.call(arguments);return Array.isArray(t[0])?t[0].unshift(this):t.unshift(this),pe.apply(this,t)};var pe=ie.combineLatest=function(){var t=slice.call(arguments),n=t.pop();return Array.isArray(t[0])&&(t=t[0]),new me(function(r){function i(t){var i;if(c[t]=!0,a||(a=c.every(function(t){return t}))){try{i=n.apply(null,l)}catch(o){return r.onError(o),e}r.onNext(i)}else h.filter(function(e,n){return n!==t}).every(function(t){return t})&&r.onCompleted()}function o(t){h[t]=!0,h.every(function(t){return t})&&r.onCompleted()}for(var s=function(){return!1},u=t.length,c=arrayInitialize(u,s),a=!1,h=arrayInitialize(u,s),l=Array(u),f=Array(u),p=0;u>p;p++)(function(e){f[e]=new O,f[e].setDisposable(t[e].subscribe(function(t){l[e]=t,i(e)},r.onError.bind(r),function(){o(e)}))})(p);return new D(f)})};Z.concat=function(){var t=slice.call(arguments,0);return t.unshift(this),de.apply(this,t)};var de=ie.concat=function(){var t=argsOrArray(arguments,0);return Q(t).concat()};Z.concatObservable=Z.concatAll=function(){return this.merge(1)},Z.merge=function(t){if("number"!=typeof t)return be(this,t);var e=this;return new me(function(n){var r=0,i=new D,o=!1,s=[],u=function(t){var e=new O;i.add(e),e.setDisposable(t.subscribe(n.onNext.bind(n),n.onError.bind(n),function(){var t;i.remove(e),s.length>0?(t=s.shift(),u(t)):(r--,o&&0===r&&n.onCompleted())}))};return i.add(e.subscribe(function(e){t>r?(r++,u(e)):s.push(e)},n.onError.bind(n),function(){o=!0,0===r&&n.onCompleted()})),i})};var be=ie.merge=function(){var t,e;return arguments[0]?arguments[0].now?(t=arguments[0],e=slice.call(arguments,1)):(t=I,e=slice.call(arguments,0)):(t=I,e=slice.call(arguments,1)),Array.isArray(e[0])&&(e=e[0]),ce(e,t).mergeObservable()};Z.mergeObservable=Z.mergeAll=function(){var t=this;return new me(function(e){var n=new D,r=!1,i=new O;return n.add(i),i.setDisposable(t.subscribe(function(t){var i=new O;n.add(i),i.setDisposable(t.subscribe(function(t){e.onNext(t)},e.onError.bind(e),function(){n.remove(i),r&&1===n.length&&e.onCompleted()}))},e.onError.bind(e),function(){r=!0,1===n.length&&e.onCompleted()})),n})},Z.onErrorResumeNext=function(t){if(!t)throw Error("Second observable is required");return ve([this,t])};var ve=ie.onErrorResumeNext=function(){var t=argsOrArray(arguments,0);return new me(function(e){var n=0,r=new k,i=I.scheduleRecursive(function(i){var o,s;t.length>n?(o=t[n++],s=new O,r.setDisposable(s),s.setDisposable(o.subscribe(e.onNext.bind(e),function(){i()},function(){i()}))):e.onCompleted()});return new D(r,i)})};Z.skipUntil=function(t){var e=this;return new me(function(n){var r=!1,i=new D(e.subscribe(function(t){r&&n.onNext(t)},n.onError.bind(n),function(){r&&n.onCompleted()})),o=new O;return i.add(o),o.setDisposable(t.subscribe(function(){r=!0,o.dispose()},n.onError.bind(n),function(){o.dispose()})),i})},Z.switchLatest=function(){var t=this;return new me(function(e){var n=!1,r=new k,i=!1,o=0,s=t.subscribe(function(t){var s=new O,u=++o;n=!0,r.setDisposable(s),s.setDisposable(t.subscribe(function(t){o===u&&e.onNext(t)},function(t){o===u&&e.onError(t)},function(){o===u&&(n=!1,i&&e.onCompleted())}))},e.onError.bind(e),function(){i=!0,n||e.onCompleted()});return new D(s,r)})},Z.takeUntil=function(t){var e=this;return new me(function(r){return new D(e.subscribe(r),t.subscribe(r.onCompleted.bind(r),r.onError.bind(r),n))})},Z.zip=function(){if(Array.isArray(arguments[0]))return p.apply(this,arguments);var t=this,n=slice.call(arguments),r=n.pop();return n.unshift(t),new me(function(i){function o(t){c[t]=!0,c.every(function(t){return t})&&i.onCompleted()}for(var s=n.length,u=arrayInitialize(s,function(){return[]}),c=arrayInitialize(s,function(){return!1}),a=function(n){var o,s;if(u.every(function(t){return t.length>0})){try{s=u.map(function(t){return t.shift()}),o=r.apply(t,s)}catch(a){return i.onError(a),e}i.onNext(o)}else c.filter(function(t,e){return e!==n}).every(function(t){return t})&&i.onCompleted()},h=Array(s),l=0;s>l;l++)(function(t){h[t]=new O,h[t].setDisposable(n[t].subscribe(function(e){u[t].push(e),a(t)},i.onError.bind(i),function(){o(t)}))})(l);return new D(h)})},ie.zip=function(t,e){var n=t[0],r=t.slice(1);return r.push(e),n.zip.apply(n,r)},Z.asObservable=function(){var t=this;return new me(function(e){return t.subscribe(e)})},Z.bufferWithCount=function(t,n){return n===e&&(n=t),this.windowWithCount(t,n).selectMany(function(t){return t.toArray()}).where(function(t){return t.length>0})},Z.dematerialize=function(){var t=this;return new me(function(e){return t.subscribe(function(t){return t.accept(e)},e.onError.bind(e),e.onCompleted.bind(e))})},Z.distinctUntilChanged=function(t,n){var i=this;return t||(t=r),n||(n=o),new me(function(r){var o,s=!1;return i.subscribe(function(i){var u,c=!1;try{u=t(i)}catch(a){return r.onError(a),e}if(s)try{c=n(o,u)}catch(a){return r.onError(a),e}s&&c||(s=!0,o=u,r.onNext(i))},r.onError.bind(r),r.onCompleted.bind(r))})},Z.doAction=function(t,e,n){var r,i=this;return"function"==typeof t?r=t:(r=t.onNext.bind(t),e=t.onError.bind(t),n=t.onCompleted.bind(t)),new me(function(t){return i.subscribe(function(e){try{r(e)}catch(n){t.onError(n)}t.onNext(e)},function(n){if(e){try{e(n)}catch(r){t.onError(r)}t.onError(n)}else t.onError(n)},function(){if(n){try{n()}catch(e){t.onError(e)}t.onCompleted()}else t.onCompleted()})})},Z.finallyAction=function(t){var e=this;return new me(function(n){var r=e.subscribe(n);return N(function(){try{r.dispose()}catch(e){throw e}finally{t()}})})},Z.ignoreElements=function(){var t=this;return new me(function(e){return t.subscribe(n,e.onError.bind(e),e.onCompleted.bind(e))})},Z.materialize=function(){var t=this;return new me(function(e){return t.subscribe(function(t){e.onNext(L(t))},function(t){e.onNext(B(t)),e.onCompleted()},function(){e.onNext(H()),e.onCompleted()})})},Z.repeat=function(t){return K(this,t).concat()},Z.retry=function(t){return K(this,t).catchException()},Z.scan=function(){var t,e,n=!1;2===arguments.length?(t=arguments[0],e=arguments[1],n=!0):e=arguments[0];var r=this;return se(function(){var i,o=!1;return r.select(function(r){return o?i=e(i,r):(i=n?e(t,r):r,o=!0),i})})},Z.skipLast=function(t){var e=this;return new me(function(n){var r=[];return e.subscribe(function(e){r.push(e),r.length>t&&n.onNext(r.shift())},n.onError.bind(n),n.onCompleted.bind(n))})},Z.startWith=function(){var t,n,r=0;return arguments.length>0&&null!=arguments[0]&&arguments[0].now!==e?(n=arguments[0],r=1):n=I,t=slice.call(arguments,r),Q([ce(t,n),this]).concat()},Z.takeLast=function(t,e){return this.takeLastBuffer(t).selectMany(function(t){return ce(t,e)})},Z.takeLastBuffer=function(t){var e=this;return new me(function(n){var r=[];return e.subscribe(function(e){r.push(e),r.length>t&&r.shift()},n.onError.bind(n),function(){n.onNext(r),n.onCompleted()})})},Z.windowWithCount=function(t,e){var n=this;if(0>=t)throw Error(y);if(null==e&&(e=t),0>=e)throw Error(y);return new me(function(r){var i=new O,o=new q(i),s=0,u=[],c=function(){var t=new Ee;u.push(t),r.onNext(addRef(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})},Z.defaultIfEmpty=function(t){var n=this;
-return t===e&&(t=null),new me(function(e){var r=!1;return n.subscribe(function(t){r=!0,e.onNext(t)},e.onError.bind(e),function(){r||e.onNext(t),e.onCompleted()})})},Z.distinct=function(t,n){var i=this;return t||(t=r),n||(n=u),new me(function(r){var o={};return i.subscribe(function(i){var s,u,c,a=!1;try{s=t(i),u=n(s)}catch(h){return r.onError(h),e}for(c in o)if(u===c){a=!0;break}a||(o[u]=null,r.onNext(i))},r.onError.bind(r),r.onCompleted.bind(r))})},Z.groupBy=function(t,e,n){return this.groupByUntil(t,e,function(){return ae()},n)},Z.groupByUntil=function(t,i,o,s){var c=this;return i||(i=r),s||(s=u),new me(function(r){var u={},a=new D,h=new q(a);return a.add(c.subscribe(function(c){var l,f,p,d,b,v,m,y,w,g,E;try{m=t(c),y=s(m)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}b=!1;try{g=u[y],g||(g=new Ee,u[y]=g,b=!0)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}if(b){v=new we(m,g,h),f=new we(m,g);try{l=o(f)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}r.onNext(v),w=new O,a.add(w),d=function(){y in u&&(delete u[y],g.onCompleted()),a.remove(w)},w.setDisposable(l.take(1).subscribe(n,function(t){for(E in u)u[E].onError(t);r.onError(t)},function(){d()}))}try{p=i(c)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}g.onNext(p)},function(t){for(var e in u)u[e].onError(t);r.onError(t)},function(){for(var t in u)u[t].onCompleted();r.onCompleted()})),h})},Z.select=Z.map=function(t){var n=this;return new me(function(r){var i=0;return n.subscribe(function(n){var o;try{o=t(n,i++)}catch(s){return r.onError(s),e}r.onNext(o)},r.onError.bind(r),r.onCompleted.bind(r))})},Z.selectMany=Z.flatMap=function(t,e){return e?this.selectMany(function(n){return t(n).select(function(t){return e(n,t)})}):"function"==typeof t?d.call(this,t):d.call(this,function(){return t})},Z.skip=function(t){if(0>t)throw Error(y);var e=this;return new me(function(n){var r=t;return e.subscribe(function(t){0>=r?n.onNext(t):r--},n.onError.bind(n),n.onCompleted.bind(n))})},Z.skipWhile=function(t){var n=this;return new me(function(r){var i=0,o=!1;return n.subscribe(function(n){if(!o)try{o=!t(n,i++)}catch(s){return r.onError(s),e}o&&r.onNext(n)},r.onError.bind(r),r.onCompleted.bind(r))})},Z.take=function(t,e){if(0>t)throw Error(y);if(0===t)return ue(e);var n=this;return new me(function(e){var r=t;return n.subscribe(function(t){r>0&&(r--,e.onNext(t),0===r&&e.onCompleted())},e.onError.bind(e),e.onCompleted.bind(e))})},Z.takeWhile=function(t){var n=this;return new me(function(r){var i=0,o=!0;return n.subscribe(function(n){if(o){try{o=t(n,i++)}catch(s){return r.onError(s),e}o?r.onNext(n):r.onCompleted()}},r.onError.bind(r),r.onCompleted.bind(r))})},Z.where=Z.filter=function(t){var n=this;return new me(function(r){var i=0;return n.subscribe(function(n){var o;try{o=t(n,i++)}catch(s){return r.onError(s),e}o&&r.onNext(n)},r.onError.bind(r),r.onCompleted.bind(r))})};var me=v.Internals.AnonymousObservable=function(t){function e(t){function e(e){var n=new ye(e);if(P.scheduleRequired())P.schedule(function(){try{n.disposable(t(n))}catch(e){if(!n.fail(e))throw e}});else try{n.disposable(t(n))}catch(r){if(!n.fail(r))throw r}return n}super_.call(this,e)}return inherits(e,t),e}(ie),ye=function(t){function e(t){e.super_.constructor.call(this),this.observer=t,this.m=new O}inherits(e,t);var n=e.prototype;return n.next=function(t){var e=!1;try{this.observer.onNext(t),e=!0}catch(n){throw n}finally{e||this.dispose()}},n.error=function(t){try{this.observer.onError(t)}catch(e){throw e}finally{this.dispose()}},n.completed=function(){try{this.observer.onCompleted()}catch(t){throw t}finally{this.dispose()}},n.disposable=function(t){return this.m.disposable(t)},n.dispose=function(){t.prototype.dispose.call(this),this.m.dispose()},e}($),we=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 me(function(t){return new D(i.getDisposable(),r.subscribe(t))}):r}return inherits(n,t),n}(ie),ge=function(t,e){this.subject=t,this.observer=e};ge.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var t=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(t,1),this.observer=null}};var Ee=root.Subject=function(t){function e(t){return a.call(this),this.isStopped?this.exception?(t.onError(this.exception),R):(t.onCompleted(),R):(this.observers.push(t),new ge(this,t))}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.observers=[]}return inherits(n,t),addProperties(n.prototype,X,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(a.call(this),!this.isStopped){var t=this.observers.slice(0);this.isStopped=!0;for(var e=0,n=t.length;n>e;e++)t[e].onCompleted();this.observers=[]}},onError:function(t){if(a.call(this),!this.isStopped){var e=this.observers.slice(0);this.isStopped=!0,this.exception=t;for(var n=0,r=e.length;r>n;n++)e[n].onError(t);this.observers=[]}},onNext:function(t){if(a.call(this),!this.isStopped)for(var e=this.observers.slice(0),n=0,r=e.length;r>n;n++)e[n].onNext(t)},dispose:function(){this.isDisposed=!0,this.observers=null}}),n.create=function(t,e){return new Ce(t,e)},n}(ie),xe=v.AsyncSubject=function(t){function e(t){if(a.call(this),!this.isStopped)return this.observers.push(t),new ge(this,t);var e=this.exception,n=this.hasValue,r=this.value;return e?t.onError(e):n?(t.onNext(r),t.onCompleted()):t.onCompleted(),R}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.value=null,this.hasValue=!1,this.observers=[],this.exception=null}return inherits(n,t),addProperties(n.prototype,X,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){var t,e,n;if(a.call(this),!this.isStopped){var r=this.observers.slice(0);this.isStopped=!0;var i=this.value,o=this.hasValue;if(o)for(e=0,n=r.length;n>e;e++)t=r[e],t.onNext(i),t.onCompleted();else for(e=0,n=r.length;n>e;e++)r[e].onCompleted();this.observers=[]}},onError:function(t){if(a.call(this),!this.isStopped){var e=this.observers.slice(0);this.isStopped=!0,this.exception=t;for(var n=0,r=e.length;r>n;n++)e[n].onError(t);this.observers=[]}},onNext:function(t){a.call(this),this.isStopped||(this.value=t,this.hasValue=!0)},dispose:function(){this.isDisposed=!0,this.observers=null,this.exception=null,this.value=null}}),n}(ie),Ce=function(t){function e(t){return this.observable.subscribe(t)}function n(n,r){t.call(this,e),this.observer=n,this.observable=r}return inherits(n,t),addProperties(n.prototype,X,{onCompleted:function(){this.observer.onCompleted()},onError:function(t){this.observer.onError(t)},onNext:function(t){this.observer.onNext(t)}}),n}(ie);return"function"==typeof define&&"object"==typeof define.amd&&define.amd?(t.Rx=root,define(function(){return root})):(b?"object"==typeof module&&module&&module.exports==b?module.exports=root:b=root:t.Rx=root,e)})(this);
+(function(t,e){function n(){}function r(t){return t}function i(){return(new Date).getTime()}function o(t,e){return t===e}function s(t,e){return t-e}function u(t){return""+t}function c(t){throw t}function a(){if(this.isDisposed)throw Error(E)}function h(t,e){return 1===t.length&&Array.isArray(t[e])?t[e]:x.call(t)}function l(t,e){for(var n=Array(t),r=0;t>r;r++)n[r]=e();return n}function f(t,e){this.scheduler=t,this.disposable=e,this.isDisposed=!1}function p(t,e,n,r,i){this.scheduler=t,this.state=e,this.action=n,this.dueTime=r,this.comparer=i||s,this.disposable=new I}function d(t,n){return new Ce(function(r){var i=new I,o=new z;return o.setDisposable(i),i.setDisposable(t.subscribe(r.onNext.bind(r),function(t){var i,s;try{s=n(t)}catch(u){return r.onError(u),e}i=new I,o.setDisposable(i),i.setDisposable(s.subscribe(r))},r.onCompleted.bind(r))),o})}function b(t,n){var r=this;return new Ce(function(i){var o=0,s=t.length;return r.subscribe(function(r){if(s>o){var u,c=t[o++];try{u=n(r,c)}catch(a){return i.onError(a),e}i.onNext(u)}else i.onCompleted()},i.onError.bind(i),i.onCompleted.bind(i))})}function v(t){return this.select(t).mergeObservable()}var m="object"==typeof exports&&exports&&("object"==typeof global&&global&&global==global.global&&(t=global),exports),y={Internals:{}},w="Sequence contains no elements.",g="Argument out of range",E="Object has been disposed",x=Array.prototype.slice;({}).hasOwnProperty;var C=this.inherits=y.Internals.inherits=function(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n},D=y.Internals.addProperties=function(t){for(var e=x.call(arguments,1),n=0,r=e.length;r>n;n++){var i=e[n];for(var o in i)t[o]=i[o]}},A=y.Internals.addRef=function(t,e){return new Ce(function(n){return new O(e.getDisposable(),t.subscribe(n))})};Function.prototype.bind||(Function.prototype.bind=function(t){var e=this,n=x.call(arguments,1),r=function(){function i(){}if(this instanceof r){i.prototype=e.prototype;var o=new i,s=e.apply(o,n.concat(x.call(arguments)));return Object(s)===s?s:o}return e.apply(t,n.concat(x.call(arguments)))};return r});var S=Object("a"),_="a"!=S[0]||!(0 in S);Array.prototype.every||(Array.prototype.every=function(t){var e=Object(this),n=_&&"[object String]"=={}.toString.call(this)?this.split(""):e,r=n.length>>>0,i=arguments[1];if("[object Function]"!={}.toString.call(t))throw new TypeError(t+" is not a function");for(var o=0;r>o;o++)if(o in n&&!t.call(i,n[o],o,e))return!1;return!0}),Array.prototype.map||(Array.prototype.map=function(t){var e=Object(this),n=_&&"[object String]"=={}.toString.call(this)?this.split(""):e,r=n.length>>>0,i=Array(r),o=arguments[1];if("[object Function]"!={}.toString.call(t))throw new TypeError(t+" is not a function");for(var s=0;r>s;s++)s in n&&(i[s]=t.call(o,n[s],s,e));return i}),Array.prototype.filter||(Array.prototype.filter=function(t){for(var e,n=[],r=Object(this),i=0,o=r.length>>>0;o>i;i++)e=r[i],i in r&&t.call(arguments[1],e,i,r)&&n.push(e);return n}),Array.isArray||(Array.isArray=function(t){return"[object Array]"==Object.prototype.toString.call(t)}),Array.prototype.indexOf||(Array.prototype.indexOf=function(t){var e=Object(this),n=e.length>>>0;if(0===n)return-1;var r=0;if(arguments.length>1&&(r=Number(arguments[1]),r!=r?r=0:0!=r&&1/0!=r&&r!=-1/0&&(r=(r>0||-1)*Math.floor(Math.abs(r)))),r>=n)return-1;for(var i=r>=0?r:Math.max(n-Math.abs(r),0);n>i;i++)if(i in e&&e[i]===t)return i;return-1});var N=function(t,e){this.id=t,this.value=e};N.prototype.compareTo=function(t){var e=this.value.compareTo(t.value);return 0===e&&(e=this.id-t.id),e};var R=function(t){this.items=Array(t),this.length=0},W=R.prototype;W.isHigherPriority=function(t,e){return 0>this.items[t].compareTo(this.items[e])},W.percolate=function(t){if(!(t>=this.length||0>t)){var e=t-1>>1;if(!(0>e||e===t)&&this.isHigherPriority(t,e)){var n=this.items[t];this.items[t]=this.items[e],this.items[e]=n,this.percolate(e)}}},W.heapify=function(t){if(t===e&&(t=0),!(t>=this.length||0>t)){var n=2*t+1,r=2*t+2,i=t;if(this.length>n&&this.isHigherPriority(n,i)&&(i=n),this.length>r&&this.isHigherPriority(r,i)&&(i=r),i!==t){var o=this.items[t];this.items[t]=this.items[i],this.items[i]=o,this.heapify(i)}}},W.peek=function(){return this.items[0].value},W.removeAt=function(t){this.items[t]=this.items[--this.length],delete this.items[this.length],this.heapify()},W.dequeue=function(){var t=this.peek();return this.removeAt(0),t},W.enqueue=function(t){var e=this.length++;this.items[e]=new N(R.count++,t),this.percolate(e)},W.remove=function(t){for(var e=0;this.length>e;e++)if(this.items[e].value===t)return this.removeAt(e),!0;return!1},R.count=0;var O=y.CompositeDisposable=function(){this.disposables=h(arguments,0),this.isDisposed=!1,this.length=this.disposables.length},k=O.prototype;k.add=function(t){this.isDisposed?t.dispose():(this.disposables.push(t),this.length++)},k.remove=function(t){var e=!1;if(!this.isDisposed){var n=this.disposables.indexOf(t);-1!==n&&(e=!0,this.disposables.splice(n,1),this.length--,t.dispose())}return e},k.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var t=this.disposables.slice(0);this.disposables=[],this.length=0;for(var e=0,n=t.length;n>e;e++)t[e].dispose()}},k.clear=function(){var t=this.disposables.slice(0);this.disposables=[],this.length=0;for(var e=0,n=t.length;n>e;e++)t[e].dispose()},k.contains=function(t){return-1!==this.disposables.indexOf(t)},k.toArray=function(){return this.disposables.slice(0)};var q=y.Disposable=function(t){this.isDisposed=!1,this.action=t};q.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var T=q.create=function(t){return new q(t)},j=q.empty={dispose:n},I=y.SingleAssignmentDisposable=function(){this.isDisposed=!1,this.current=null},P=I.prototype;P.disposable=function(t){return t?this.setDisposable(t):this.getDisposable()},P.getDisposable=function(){return this.current},P.setDisposable=function(t){if(this.current)throw Error("Disposable has already been assigned");var e=this.isDisposed;e||(this.current=t),e&&t&&t.dispose()},P.dispose=function(){var t;this.isDisposed||(this.isDisposed=!0,t=this.current,this.current=null),t&&t.dispose()};var z=y.SerialDisposable=function(){this.isDisposed=!1,this.current=null};z.prototype.getDisposable=function(){return this.current},z.prototype.setDisposable=function(t){var e,n=this.isDisposed;n||(e=this.current,this.current=t),e&&e.dispose(),n&&t&&t.dispose()},z.prototype.disposable=function(t){return t?(this.setDisposable(t),e):this.getDisposable()},z.prototype.dispose=function(){var t;this.isDisposed||(this.isDisposed=!0,t=this.current,this.current=null),t&&t.dispose()};var V=y.RefCountDisposable=function(){function t(t){this.disposable=t,this.disposable.count++,this.isInnerDisposed=!1}function e(t){this.underlyingDisposable=t,this.isDisposed=!1,this.isPrimaryDisposed=!1,this.count=0}return t.prototype.dispose=function(){this.disposable.isDisposed||this.isInnerDisposed||(this.isInnerDisposed=!0,this.disposable.count--,0===this.disposable.count&&this.disposable.isPrimaryDisposed&&(this.disposable.isDisposed=!0,this.disposable.underlyingDisposable.dispose()))},e.prototype.dispose=function(){this.isDisposed||this.isPrimaryDisposed||(this.isPrimaryDisposed=!0,0===this.count&&(this.isDisposed=!0,this.underlyingDisposable.dispose()))},e.prototype.getDisposable=function(){return this.isDisposed?j:new t(this)},e}();f.prototype.dispose=function(){var t=this;this.scheduler.schedule(function(){t.isDisposed||(t.isDisposed=!0,t.disposable.dispose())})},p.prototype.invoke=function(){this.disposable.disposable(this.invokeCore())},p.prototype.compareTo=function(t){return this.comparer(this.dueTime,t.dueTime)},p.prototype.isCancelled=function(){return this.disposable.isDisposed},p.prototype.invokeCore=function(){return this.action(this.scheduler,this.state)};var F=y.Scheduler=function(){function e(t,e,n,r){this.now=t,this._schedule=e,this._scheduleRelative=n,this._scheduleAbsolute=r}function n(t,e){var n=e.first,r=e.second,i=new O,o=function(e){r(e,function(e){var n=!1,r=!1,s=t.scheduleWithState(e,function(t,e){return n?i.remove(s):r=!0,o(e),j});r||(i.add(s),n=!0)})};return o(n),i}function r(t,e,n){var r=e.first,i=e.second,o=new O,s=function(e){i(e,function(e,r){var i=!1,u=!1,c=t[n].call(t,e,r,function(t,e){return i?o.remove(c):u=!0,s(e),j});u||(o.add(c),i=!0)})};return s(r),o}function o(t,e){return e(),j}var s=e.prototype;return s.catchException=function(t){return new G(this,t)},s.schedulePeriodic=function(t,e){return this.schedulePeriodicWithState(null,t,function(){e()})},s.schedulePeriodicWithState=function(e,n,r){var i=e,o=t.setInterval(function(){i=r(i)},n);return T(function(){t.clearInterval(o)})},s.schedule=function(t){return this._schedule(t,o)},s.scheduleWithState=function(t,e){return this._schedule(t,e)},s.scheduleWithRelative=function(t,e){return this._scheduleRelative(e,t,o)},s.scheduleWithRelativeAndState=function(t,e,n){return this._scheduleRelative(t,e,n)},s.scheduleWithAbsolute=function(t,e){return this._scheduleAbsolute(e,t,o)},s.scheduleWithAbsoluteAndState=function(t,e,n){return this._scheduleAbsolute(t,e,n)},s.scheduleRecursive=function(t){return this.scheduleRecursiveWithState(t,function(t,e){t(function(){e(t)})})},s.scheduleRecursiveWithState=function(t,e){return this.scheduleWithState({first:t,second:e},function(t,e){return n(t,e)})},s.scheduleRecursiveWithRelative=function(t,e){return this.scheduleRecursiveWithRelativeAndState(e,t,function(t,e){t(function(n){e(t,n)})})},s.scheduleRecursiveWithRelativeAndState=function(t,e,n){return this._scheduleRelative({first:t,second:n},e,function(t,e){return r(t,e,"scheduleWithRelativeAndState")})},s.scheduleRecursiveWithAbsolute=function(t,e){return this.scheduleRecursiveWithAbsoluteAndState(e,t,function(t,e){t(function(n){e(t,n)})})},s.scheduleRecursiveWithAbsoluteAndState=function(t,e,n){return this._scheduleAbsolute({first:t,second:n},e,function(t,e){return r(t,e,"scheduleWithAbsoluteAndState")})},e.now=i,e.normalize=function(t){return 0>t&&(t=0),t},e}(),M="Scheduler is not allowed to block the thread",L=F.immediate=function(){function t(t,e){return e(this,t)}function e(t,e,n){if(e>0)throw Error(M);return n(this,t)}function n(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new F(i,t,e,n)}(),B=F.currentThread=function(){function t(){o=new R(4)}function e(t,e){return this.scheduleWithRelativeAndState(t,0,e)}function n(e,n,r){var i,s=this.now()+F.normalize(n),u=new p(this,e,r,s);if(o)o.enqueue(u);else{i=new t;try{o.enqueue(u),i.run()}catch(c){throw c}finally{i.dispose()}}return u.disposable}function r(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}var o;t.prototype.dispose=function(){o=null},t.prototype.run=function(){for(var t;o.length>0;)if(t=o.dequeue(),!t.isCancelled()){for(;t.dueTime-F.now()>0;);t.isCancelled()||t.invoke()}};var s=new F(i,e,n,r);return s.scheduleRequired=function(){return null===o},s.ensureTrampoline=function(t){return null===o?this.schedule(t):t()},s}(),H=function(){function t(t,e){e(0,this._period);try{this._state=this._action(this._state)}catch(n){throw this._cancel.dispose(),n}}function e(t,e,n,r){this._scheduler=t,this._state=e,this._period=n,this._action=r}return e.prototype.start=function(){var e=new I;return this._cancel=e,e.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,t.bind(this))),e},e}();y.VirtualTimeScheduler=function(t){function n(){return this.toDateTimeOffset(this.clock)}function r(t,e){return this.scheduleAbsoluteWithState(t,this.clock,e)}function i(t,e,n){return this.scheduleRelativeWithState(t,this.toRelative(e),n)}function o(t,e,n){return this.scheduleRelativeWithState(t,this.toRelative(e-this.now()),n)}function s(t,e){return e(),j}function u(e,s){this.clock=e,this.comparer=s,this.isEnabled=!1,this.queue=new R(1024),t.call(this,n,r,i,o)}C(u,t);var c=u.prototype;return c.schedulePeriodicWithState=function(t,e,n){var r=new H(this,t,e,n);return r.start()},c.scheduleRelativeWithState=function(t,e,n){var r=this.add(this.clock,e);return this.scheduleAbsoluteWithState(t,r,n)},c.scheduleRelative=function(t,e){return this.scheduleRelativeWithState(e,t,s)},c.start=function(){var t;if(!this.isEnabled){this.isEnabled=!0;do t=this.getNext(),null!==t?(this.comparer(t.dueTime,this.clock)>0&&(this.clock=t.dueTime),t.invoke()):this.isEnabled=!1;while(this.isEnabled)}},c.stop=function(){this.isEnabled=!1},c.advanceTo=function(t){var e,n=this.comparer(this.clock,t);if(this.comparer(this.clock,t)>0)throw Error(g);if(0!==n&&!this.isEnabled){this.isEnabled=!0;do e=this.getNext(),null!==e&&0>=this.comparer(e.dueTime,t)?(this.comparer(e.dueTime,this.clock)>0&&(this.clock=e.dueTime),e.invoke()):this.isEnabled=!1;while(this.isEnabled);this.clock=t}},c.advanceBy=function(t){var n=this.add(this.clock,t),r=this.comparer(this.clock,n);if(r>0)throw Error(g);return 0!==r?this.advanceTo(n):e},c.sleep=function(t){var e=this.add(this.clock,t);if(this.comparer(this.clock,e)>=0)throw Error(g);this.clock=e},c.getNext=function(){for(var t;this.queue.length>0;){if(t=this.queue.peek(),!t.isCancelled())return t;this.queue.dequeue()}return null},c.scheduleAbsolute=function(t,e){return this.scheduleAbsoluteWithState(e,t,s)},c.scheduleAbsoluteWithState=function(t,e,n){var r=this,i=function(t,e){return r.queue.remove(o),n(t,e)},o=new p(r,t,i,e,r.comparer);return r.queue.enqueue(o),o.disposable},u}(F),y.HistoricalScheduler=function(t){function e(e,n){var r=null==e?0:e,i=n||s;t.call(this,r,i)}C(e,t);var n=e.prototype;return n.add=function(t,e){return t+e},n.toDateTimeOffset=function(t){return new Date(t).getTime()},n.toRelative=function(t){return t},e}(y.VirtualTimeScheduler);var U=F.timeout=function(){function r(t,e){var n=this,r=new I,i=u(function(){r.setDisposable(e(n,t))});return new O(r,T(function(){c(i)}))}function o(e,n,r){var i=this,o=F.normalize(n);if(0===o)return i.scheduleWithState(e,r);var s=new I,u=t.setTimeout(function(){s.setDisposable(r(i,e))},o);return new O(s,T(function(){t.clearTimeout(u)}))}function s(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}var u,c,a="equestAnimationFrame",h="ancelAnimationFrame",l=t["r"+a]||t["webkitR"+a]||t["mozR"+a]||t["oR"+a]||t["msR"+a],f=t["c"+h]||t["webkitC"+h]||t["mozC"+h]||t["oC"+h]||t["msC"+h];return t.process!==e&&"function"==typeof t.process.nextTick?(u=t.process.nextTick,c=n):"function"==typeof t.setImmediate?(u=t.setImmediate,c=t.clearImmediate):"function"==typeof l?(u=l,c=f):(u=function(e){return t.setTimeout(e,0)},c=t.clearTimeout),new F(i,r,o,s)}(),G=function(t){function e(){return this._scheduler.now()}function n(t,e){return this._scheduler.scheduleWithState(t,this._wrap(e))}function r(t,e,n){return this._scheduler.scheduleWithRelativeAndState(t,e,this._wrap(n))}function i(t,e,n){return this._scheduler.scheduleWithAbsoluteAndState(t,e,this._wrap(n))}function o(o,s){this._scheduler=o,this._handler=s,this._recursiveOriginal=null,this._recursiveWrapper=null,t.call(this,e,n,r,i)}return C(o,t),o.prototype._clone=function(t){return new o(t,this._handler)},o.prototype._wrap=function(t){var e=this;return function(n,r){try{return t(e._getRecursiveWrapper(n),r)}catch(i){if(!e._handler(i))throw i;return j}}},o.prototype._getRecursiveWrapper=function(t){if(!this._recursiveOriginal!==t){this._recursiveOriginal=t;var e=this._clone(t);e._recursiveOriginal=t,e._recursiveWrapper=e,this._recursiveWrapper=e}return this._recursiveWrapper},o.prototype.schedulePeriodicWithState=function(t,e,n){var r=this,i=!1,o=new I;return o.setDisposable(this._scheduler.schedulePeriodicWithState(t,e,function(t){if(i)return null;try{return n(t)}catch(e){if(i=!0,!r._handler(e))throw e;return o.dispose(),null}})),o},o}(F),J=y.Notification=function(){function t(t,e){this.hasValue=null==e?!1:e,this.kind=t}var e=t.prototype;return e.accept=function(t,e,n){return 1===arguments.length&&"object"==typeof t?this._acceptObservable(t):this._accept(t,e,n)},e.toObservable=function(t){var e=this;return t=t||L,new Ce(function(n){return t.schedule(function(){e._acceptObservable(n),"N"===e.kind&&n.onCompleted()})})},e.equals=function(t){var e=null==t?"":""+t;return""+this===e},t}(),K=J.createOnNext=function(){function t(t){return t(this.value)}function e(t){return t.onNext(this.value)}function n(){return"OnNext("+this.value+")"}return function(r){var i=new J("N",!0);return i.value=r,i._accept=t.bind(i),i._acceptObservable=e.bind(i),i.toString=n.bind(i),i}}(),Q=J.createOnError=function(){function t(t,e){return e(this.exception)}function e(t){return t.onError(this.exception)}function n(){return"OnError("+this.exception+")"}return function(r){var i=new J("E");return i.exception=r,i._accept=t.bind(i),i._acceptObservable=e.bind(i),i.toString=n.bind(i),i}}(),X=J.createOnCompleted=function(){function t(t,e,n){return n()}function e(t){return t.onCompleted()}function n(){return"OnCompleted()"}return function(){var r=new J("C");return r._accept=t.bind(r),r._acceptObservable=e.bind(r),r.toString=n.bind(r),r}}(),Y=y.Internals.Enumerator=function(t,e,n){this.moveNext=t,this.getCurrent=e,this.dispose=n},Z=Y.create=function(t,e,r){var i=!1;return r||(r=n),new Y(function(){if(i)return!1;var e=t();return e||(i=!0,r()),e},function(){return e()},function(){i||(r(),i=!0)})},$=y.Internals.Enumerable=function(){function t(t){this.getEnumerator=t}return t.prototype.concat=function(){var t=this;return new Ce(function(n){var r=t.getEnumerator(),i=!1,o=new z,s=L.scheduleRecursive(function(t){var s,u,c=!1;if(!i){try{c=r.moveNext(),c?s=r.getCurrent():r.dispose()}catch(a){u=a,r.dispose()}if(u)return n.onError(u),e;if(!c)return n.onCompleted(),e;var h=new I;o.setDisposable(h),h.setDisposable(s.subscribe(n.onNext.bind(n),n.onError.bind(n),function(){t()}))}});return new O(o,s,T(function(){i=!0,r.dispose()}))})},t.prototype.catchException=function(){var t=this;return new Ce(function(n){var r,i=t.getEnumerator(),o=!1,s=new z,u=L.scheduleRecursive(function(t){var u,c,a;if(a=!1,!o){try{a=i.moveNext(),a&&(u=i.getCurrent())}catch(h){c=h}if(c)return n.onError(c),e;if(!a)return r?n.onError(r):n.onCompleted(),e;var l=new I;s.setDisposable(l),l.setDisposable(u.subscribe(n.onNext.bind(n),function(e){r=e,t()},n.onCompleted.bind(n)))}});return new O(s,u,T(function(){o=!0}))})},t}(),te=$.repeat=function(t,n){return n===e&&(n=-1),new $(function(){var e,r=n;return Z(function(){return 0===r?!1:(r>0&&r--,e=t,!0)},function(){return e})})},ee=$.forEach=function(t,e){return e||(e=r),new $(function(){var n,r=-1;return Z(function(){return++r<t.length?(n=e(t[r],r),!0):!1},function(){return n})})},ne=y.Observer=function(){};ne.prototype.toNotifier=function(){var t=this;return function(e){return e.accept(t)}},ne.prototype.asObserver=function(){return new se(this.onNext.bind(this),this.onError.bind(this),this.onCompleted.bind(this))},ne.prototype.checked=function(){return new ue(this)};var re=ne.create=function(t,e,r){return t||(t=n),e||(e=c),r||(r=n),new se(t,e,r)};ne.fromNotifier=function(t){return new se(function(e){return t(K(e))},function(e){return t(Q(e))},function(){return t(X())})};var ie,oe=y.Internals.AbstractObserver=function(t){function e(){this.isStopped=!1,t.call(this)}return C(e,t),e.prototype.onNext=function(t){this.isStopped||this.next(t)},e.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.error(t))},e.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.completed())},e.prototype.dispose=function(){this.isStopped=!0},e.prototype.fail=function(){return this.isStopped?!1:(this.isStopped=!0,this.error(!0),!0)},e}(ne),se=y.AnonymousObserver=function(t){function e(e,n,r){t.call(this),this._onNext=e,this._onError=n,this._onCompleted=r}return C(e,t),e.prototype.next=function(t){this._onNext(t)},e.prototype.error=function(t){this._onError(t)},e.prototype.completed=function(){this._onCompleted()},e}(oe),ue=function(t){function e(e){t.call(this),this._observer=e,this._state=0}C(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}(ne),ce=y.Internals.ScheduledObserver=function(t){function n(e,n){t.call(this),this.scheduler=e,this.observer=n,this.isAcquired=!1,this.hasFaulted=!1,this.queue=[],this.disposable=new z}return C(n,t),n.prototype.next=function(t){var e=this;this.queue.push(function(){e.observer.onNext(t)})},n.prototype.error=function(t){var e=this;this.queue.push(function(){e.observer.onError(t)})},n.prototype.completed=function(){var t=this;this.queue.push(function(){t.observer.onCompleted()})},n.prototype.ensureActive=function(){var t=!1,n=this;!this.hasFaulted&&this.queue.length>0&&(t=!this.isAcquired,this.isAcquired=!0),t&&this.disposable.setDisposable(this.scheduler.scheduleRecursive(function(t){var r;if(!(n.queue.length>0))return n.isAcquired=!1,e;r=n.queue.shift();try{r()}catch(i){throw n.queue=[],n.hasFaulted=!0,i}t()}))},n.prototype.dispose=function(){t.prototype.dispose.call(this),this.disposable.dispose()},n}(oe),ae=function(t){function e(){t.apply(this,arguments)}return C(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}(ce),he=y.Observable=function(){function t(t){this._subscribe=t}return ie=t.prototype,ie.finalValue=function(){var t=this;return new Ce(function(e){var n,r=!1;return t.subscribe(function(t){r=!0,n=t},e.onError.bind(e),function(){r?(e.onNext(n),e.onCompleted()):e.onError(Error(w))})})},ie.subscribe=ie.forEach=function(t,e,n){var r;return r="object"==typeof t?t:re(t,e,n),this._subscribe(r)},ie.toArray=function(){function t(t,e){var n=t.slice(0);return n.push(e),n}return this.scan([],t).startWith([]).finalValue()},t}();he.start=function(t,e){return le(t,e)()};var le=he.toAsync=function(t,n,r){return n||(n=U),function(){var i=x.call(arguments,0),o=new Ne;return n.schedule(function(){var n;try{n=t.apply(r,i)}catch(s){return o.onError(s),e}o.onNext(n),o.onCompleted()}),o.asObservable()}};ie.observeOn=function(t){var e=this;return new Ce(function(n){return e.subscribe(new ae(t,n))})},ie.subscribeOn=function(t){var e=this;return new Ce(function(n){var r=new I,i=new z;return i.setDisposable(r),r.setDisposable(t.schedule(function(){i.setDisposable(new f(t,e.subscribe(n)))})),i})},he.create=function(t){return new Ce(function(e){return T(t(e))})},he.createWithDisposable=function(t){return new Ce(t)};var fe=he.defer=function(t){return new Ce(function(e){var n;try{n=t()}catch(r){return me(r).subscribe(e)}return n.subscribe(e)})},pe=he.empty=function(t){return t||(t=L),new Ce(function(e){return t.schedule(function(){e.onCompleted()})})},de=he.fromArray=function(t,e){return e||(e=B),new Ce(function(n){var r=0;return e.scheduleRecursive(function(e){t.length>r?(n.onNext(t[r++]),e()):n.onCompleted()})})};he.generate=function(t,n,r,i,o){return o||(o=B),new Ce(function(s){var u=!0,c=t;return o.scheduleRecursive(function(t){var o,a;try{u?u=!1:c=r(c),o=n(c),o&&(a=i(c))}catch(h){return s.onError(h),e}o?(s.onNext(a),t()):s.onCompleted()})})};var be=he.never=function(){return new Ce(function(){return j})};he.range=function(t,e,n){return n||(n=B),new Ce(function(r){return n.scheduleRecursiveWithState(0,function(n,i){e>n?(r.onNext(t+n),i(n+1)):r.onCompleted()})})},he.repeat=function(t,n,r){return r||(r=B),n==e&&(n=-1),ve(t,r).repeat(n)};var ve=he.returnValue=function(t,e){return e||(e=L),new Ce(function(n){return e.schedule(function(){n.onNext(t),n.onCompleted()})})},me=he.throwException=function(t,e){return e||(e=L),new Ce(function(n){return e.schedule(function(){n.onError(t)})})};he.using=function(t,e){return new Ce(function(n){var r,i,o=j;try{r=t(),r&&(o=r),i=e(r)}catch(s){return new O(me(s).subscribe(n),o)}return new O(i.subscribe(n),o)})},ie.amb=function(t){var e=this;return new Ce(function(n){function r(){o||(o=s,a.dispose())}function i(){o||(o=u,c.dispose())}var o,s="L",u="R",c=new I,a=new I;return 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 O(c,a)})},he.amb=function(){function t(t,e){return t.amb(e)}for(var e=be(),n=h(arguments,0),r=0,i=n.length;i>r;r++)e=t(e,n[r]);return e},ie.catchException=function(t){return"function"==typeof t?d(this,t):ye([this,t])};var ye=he.catchException=function(){var t=h(arguments,0);return ee(t).catchException()};ie.combineLatest=function(){var t=x.call(arguments);return Array.isArray(t[0])?t[0].unshift(this):t.unshift(this),we.apply(this,t)};var we=he.combineLatest=function(){var t=x.call(arguments),n=t.pop();return Array.isArray(t[0])&&(t=t[0]),new Ce(function(r){function i(t){var i;if(c[t]=!0,a||(a=c.every(function(t){return t}))){try{i=n.apply(null,f)}catch(o){return r.onError(o),e}r.onNext(i)}else h.filter(function(e,n){return n!==t}).every(function(t){return t})&&r.onCompleted()}function o(t){h[t]=!0,h.every(function(t){return t})&&r.onCompleted()}for(var s=function(){return!1},u=t.length,c=l(u,s),a=!1,h=l(u,s),f=Array(u),p=Array(u),d=0;u>d;d++)(function(e){p[e]=new I,p[e].setDisposable(t[e].subscribe(function(t){f[e]=t,i(e)},r.onError.bind(r),function(){o(e)}))})(d);return new O(p)})};ie.concat=function(){var t=x.call(arguments,0);return t.unshift(this),ge.apply(this,t)};var ge=he.concat=function(){var t=h(arguments,0);return ee(t).concat()};ie.concatObservable=ie.concatAll=function(){return this.merge(1)},ie.merge=function(t){if("number"!=typeof t)return Ee(this,t);var e=this;return new Ce(function(n){var r=0,i=new O,o=!1,s=[],u=function(t){var e=new I;i.add(e),e.setDisposable(t.subscribe(n.onNext.bind(n),n.onError.bind(n),function(){var t;i.remove(e),s.length>0?(t=s.shift(),u(t)):(r--,o&&0===r&&n.onCompleted())}))};return i.add(e.subscribe(function(e){t>r?(r++,u(e)):s.push(e)},n.onError.bind(n),function(){o=!0,0===r&&n.onCompleted()})),i})};var Ee=he.merge=function(){var t,e;return arguments[0]?arguments[0].now?(t=arguments[0],e=x.call(arguments,1)):(t=L,e=x.call(arguments,0)):(t=L,e=x.call(arguments,1)),Array.isArray(e[0])&&(e=e[0]),de(e,t).mergeObservable()};ie.mergeObservable=ie.mergeAll=function(){var t=this;return new Ce(function(e){var n=new O,r=!1,i=new I;return n.add(i),i.setDisposable(t.subscribe(function(t){var i=new I;n.add(i),i.setDisposable(t.subscribe(function(t){e.onNext(t)},e.onError.bind(e),function(){n.remove(i),r&&1===n.length&&e.onCompleted()}))},e.onError.bind(e),function(){r=!0,1===n.length&&e.onCompleted()})),n})},ie.onErrorResumeNext=function(t){if(!t)throw Error("Second observable is required");return xe([this,t])};var xe=he.onErrorResumeNext=function(){var t=h(arguments,0);return new Ce(function(e){var n=0,r=new z,i=L.scheduleRecursive(function(i){var o,s;t.length>n?(o=t[n++],s=new I,r.setDisposable(s),s.setDisposable(o.subscribe(e.onNext.bind(e),function(){i()},function(){i()}))):e.onCompleted()});return new O(r,i)})};ie.skipUntil=function(t){var e=this;return new Ce(function(n){var r=!1,i=new O(e.subscribe(function(t){r&&n.onNext(t)},n.onError.bind(n),function(){r&&n.onCompleted()})),o=new I;return i.add(o),o.setDisposable(t.subscribe(function(){r=!0,o.dispose()},n.onError.bind(n),function(){o.dispose()})),i})},ie.switchLatest=function(){var t=this;return new Ce(function(e){var n=!1,r=new z,i=!1,o=0,s=t.subscribe(function(t){var s=new I,u=++o;n=!0,r.setDisposable(s),s.setDisposable(t.subscribe(function(t){o===u&&e.onNext(t)},function(t){o===u&&e.onError(t)},function(){o===u&&(n=!1,i&&e.onCompleted())}))},e.onError.bind(e),function(){i=!0,n||e.onCompleted()});return new O(s,r)})},ie.takeUntil=function(t){var e=this;return new Ce(function(r){return new O(e.subscribe(r),t.subscribe(r.onCompleted.bind(r),r.onError.bind(r),n))})},ie.zip=function(){if(Array.isArray(arguments[0]))return b.apply(this,arguments);var t=this,n=x.call(arguments),r=n.pop();return n.unshift(t),new Ce(function(i){function o(t){c[t]=!0,c.every(function(t){return t})&&i.onCompleted()}for(var s=n.length,u=l(s,function(){return[]}),c=l(s,function(){return!1}),a=function(n){var o,s;if(u.every(function(t){return t.length>0})){try{s=u.map(function(t){return t.shift()}),o=r.apply(t,s)}catch(a){return i.onError(a),e}i.onNext(o)}else c.filter(function(t,e){return e!==n}).every(function(t){return t})&&i.onCompleted()},h=Array(s),f=0;s>f;f++)(function(t){h[t]=new I,h[t].setDisposable(n[t].subscribe(function(e){u[t].push(e),a(t)},i.onError.bind(i),function(){o(t)}))})(f);return new O(h)})},he.zip=function(t,e){var n=t[0],r=t.slice(1);return r.push(e),n.zip.apply(n,r)},ie.asObservable=function(){var t=this;return new Ce(function(e){return t.subscribe(e)})},ie.bufferWithCount=function(t,n){return n===e&&(n=t),this.windowWithCount(t,n).selectMany(function(t){return t.toArray()}).where(function(t){return t.length>0})},ie.dematerialize=function(){var t=this;return new Ce(function(e){return t.subscribe(function(t){return t.accept(e)},e.onError.bind(e),e.onCompleted.bind(e))})},ie.distinctUntilChanged=function(t,n){var i=this;return t||(t=r),n||(n=o),new Ce(function(r){var o,s=!1;return i.subscribe(function(i){var u,c=!1;try{u=t(i)}catch(a){return r.onError(a),e}if(s)try{c=n(o,u)}catch(a){return r.onError(a),e}s&&c||(s=!0,o=u,r.onNext(i))},r.onError.bind(r),r.onCompleted.bind(r))})},ie.doAction=function(t,e,n){var r,i=this;return"function"==typeof t?r=t:(r=t.onNext.bind(t),e=t.onError.bind(t),n=t.onCompleted.bind(t)),new Ce(function(t){return i.subscribe(function(e){try{r(e)}catch(n){t.onError(n)}t.onNext(e)},function(n){if(e){try{e(n)}catch(r){t.onError(r)}t.onError(n)}else t.onError(n)},function(){if(n){try{n()}catch(e){t.onError(e)}t.onCompleted()}else t.onCompleted()})})},ie.finallyAction=function(t){var e=this;return new Ce(function(n){var r=e.subscribe(n);return T(function(){try{r.dispose()}catch(e){throw e}finally{t()}})})},ie.ignoreElements=function(){var t=this;return new Ce(function(e){return t.subscribe(n,e.onError.bind(e),e.onCompleted.bind(e))})},ie.materialize=function(){var t=this;return new Ce(function(e){return t.subscribe(function(t){e.onNext(K(t))},function(t){e.onNext(Q(t)),e.onCompleted()},function(){e.onNext(X()),e.onCompleted()})})},ie.repeat=function(t){return te(this,t).concat()},ie.retry=function(t){return te(this,t).catchException()},ie.scan=function(){var t,e,n=!1;2===arguments.length?(t=arguments[0],e=arguments[1],n=!0):e=arguments[0];var r=this;return fe(function(){var i,o=!1;return r.select(function(r){return o?i=e(i,r):(i=n?e(t,r):r,o=!0),i})})},ie.skipLast=function(t){var e=this;return new Ce(function(n){var r=[];return e.subscribe(function(e){r.push(e),r.length>t&&n.onNext(r.shift())},n.onError.bind(n),n.onCompleted.bind(n))})},ie.startWith=function(){var t,n,r=0;return arguments.length>0&&null!=arguments[0]&&arguments[0].now!==e?(n=arguments[0],r=1):n=L,t=x.call(arguments,r),ee([de(t,n),this]).concat()},ie.takeLast=function(t,e){return this.takeLastBuffer(t).selectMany(function(t){return de(t,e)})},ie.takeLastBuffer=function(t){var e=this;return new Ce(function(n){var r=[];return e.subscribe(function(e){r.push(e),r.length>t&&r.shift()},n.onError.bind(n),function(){n.onNext(r),n.onCompleted()})})},ie.windowWithCount=function(t,e){var n=this;if(0>=t)throw Error(g);if(null==e&&(e=t),0>=e)throw Error(g);return new Ce(function(r){var i=new I,o=new V(i),s=0,u=[],c=function(){var t=new _e;u.push(t),r.onNext(A(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})},ie.defaultIfEmpty=function(t){var n=this;return t===e&&(t=null),new Ce(function(e){var r=!1;return n.subscribe(function(t){r=!0,e.onNext(t)},e.onError.bind(e),function(){r||e.onNext(t),e.onCompleted()})})},ie.distinct=function(t,n){var i=this;return t||(t=r),n||(n=u),new Ce(function(r){var o={};return i.subscribe(function(i){var s,u,c,a=!1;try{s=t(i),u=n(s)}catch(h){return r.onError(h),e}for(c in o)if(u===c){a=!0;break}a||(o[u]=null,r.onNext(i))},r.onError.bind(r),r.onCompleted.bind(r))})},ie.groupBy=function(t,e,n){return this.groupByUntil(t,e,function(){return be()},n)},ie.groupByUntil=function(t,i,o,s){var c=this;return i||(i=r),s||(s=u),new Ce(function(r){var u={},a=new O,h=new V(a);return a.add(c.subscribe(function(c){var l,f,p,d,b,v,m,y,w,g,E;try{m=t(c),y=s(m)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}b=!1;try{g=u[y],g||(g=new _e,u[y]=g,b=!0)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}if(b){v=new Ae(m,g,h),f=new Ae(m,g);try{l=o(f)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}r.onNext(v),w=new I,a.add(w),d=function(){y in u&&(delete u[y],g.onCompleted()),a.remove(w)},w.setDisposable(l.take(1).subscribe(n,function(t){for(E in u)u[E].onError(t);r.onError(t)},function(){d()}))}try{p=i(c)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}g.onNext(p)},function(t){for(var e in u)u[e].onError(t);r.onError(t)},function(){for(var t in u)u[t].onCompleted();r.onCompleted()})),h})},ie.select=ie.map=function(t){var n=this;return new Ce(function(r){var i=0;return n.subscribe(function(n){var o;try{o=t(n,i++)}catch(s){return r.onError(s),e}r.onNext(o)},r.onError.bind(r),r.onCompleted.bind(r))})},ie.selectMany=ie.flatMap=function(t,e){return e?this.selectMany(function(n){return t(n).select(function(t){return e(n,t)})}):"function"==typeof t?v.call(this,t):v.call(this,function(){return t})},ie.skip=function(t){if(0>t)throw Error(g);var e=this;return new Ce(function(n){var r=t;return e.subscribe(function(t){0>=r?n.onNext(t):r--},n.onError.bind(n),n.onCompleted.bind(n))})},ie.skipWhile=function(t){var n=this;return new Ce(function(r){var i=0,o=!1;return n.subscribe(function(n){if(!o)try{o=!t(n,i++)}catch(s){return r.onError(s),e}o&&r.onNext(n)},r.onError.bind(r),r.onCompleted.bind(r))})},ie.take=function(t,e){if(0>t)throw Error(g);if(0===t)return pe(e);var n=this;return new Ce(function(e){var r=t;return n.subscribe(function(t){r>0&&(r--,e.onNext(t),0===r&&e.onCompleted())},e.onError.bind(e),e.onCompleted.bind(e))})},ie.takeWhile=function(t){var n=this;return new Ce(function(r){var i=0,o=!0;return n.subscribe(function(n){if(o){try{o=t(n,i++)}catch(s){return r.onError(s),e}o?r.onNext(n):r.onCompleted()}},r.onError.bind(r),r.onCompleted.bind(r))})},ie.where=ie.filter=function(t){var n=this;return new Ce(function(r){var i=0;return n.subscribe(function(n){var o;try{o=t(n,i++)}catch(s){return r.onError(s),e}o&&r.onNext(n)},r.onError.bind(r),r.onCompleted.bind(r))})};var Ce=y.Internals.AnonymousObservable=function(t){function e(e){function n(t){var n=new De(t);if(B.scheduleRequired())B.schedule(function(){try{n.disposable(e(n))}catch(t){if(!n.fail(t))throw t}});else try{n.disposable(e(n))}catch(r){if(!n.fail(r))throw r}return n}t.call(this,n)}return C(e,t),e}(he),De=function(t){function e(e){t.call(this),this.observer=e,this.m=new I}C(e,t);var n=e.prototype;return n.next=function(t){var e=!1;try{this.observer.onNext(t),e=!0}catch(n){throw n}finally{e||this.dispose()}},n.error=function(t){try{this.observer.onError(t)}catch(e){throw e}finally{this.dispose()}},n.completed=function(){try{this.observer.onCompleted()}catch(t){throw t}finally{this.dispose()}},n.disposable=function(t){return this.m.disposable(t)},n.dispose=function(){t.prototype.dispose.call(this),this.m.dispose()},e}(oe),Ae=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 Ce(function(t){return new O(i.getDisposable(),r.subscribe(t))}):r}return C(n,t),n}(he),Se=function(t,e){this.subject=t,this.observer=e};Se.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var t=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(t,1),this.observer=null}};var _e=y.Subject=function(t){function e(t){return a.call(this),this.isStopped?this.exception?(t.onError(this.exception),j):(t.onCompleted(),j):(this.observers.push(t),new Se(this,t))}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.observers=[]}return C(n,t),D(n.prototype,ne,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(a.call(this),!this.isStopped){var t=this.observers.slice(0);this.isStopped=!0;for(var e=0,n=t.length;n>e;e++)t[e].onCompleted();this.observers=[]}},onError:function(t){if(a.call(this),!this.isStopped){var e=this.observers.slice(0);this.isStopped=!0,this.exception=t;for(var n=0,r=e.length;r>n;n++)e[n].onError(t);this.observers=[]}},onNext:function(t){if(a.call(this),!this.isStopped)for(var e=this.observers.slice(0),n=0,r=e.length;r>n;n++)e[n].onNext(t)},dispose:function(){this.isDisposed=!0,this.observers=null}}),n.create=function(t,e){return new Re(t,e)},n}(he),Ne=y.AsyncSubject=function(t){function e(t){if(a.call(this),!this.isStopped)return this.observers.push(t),new Se(this,t);var e=this.exception,n=this.hasValue,r=this.value;return e?t.onError(e):n?(t.onNext(r),t.onCompleted()):t.onCompleted(),j}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.value=null,this.hasValue=!1,this.observers=[],this.exception=null}return C(n,t),D(n.prototype,ne,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){var t,e,n;if(a.call(this),!this.isStopped){var r=this.observers.slice(0);this.isStopped=!0;var i=this.value,o=this.hasValue;if(o)for(e=0,n=r.length;n>e;e++)t=r[e],t.onNext(i),t.onCompleted();else for(e=0,n=r.length;n>e;e++)r[e].onCompleted();this.observers=[]}},onError:function(t){if(a.call(this),!this.isStopped){var e=this.observers.slice(0);this.isStopped=!0,this.exception=t;for(var n=0,r=e.length;r>n;n++)e[n].onError(t);this.observers=[]}},onNext:function(t){a.call(this),this.isStopped||(this.value=t,this.hasValue=!0)},dispose:function(){this.isDisposed=!0,this.observers=null,this.exception=null,this.value=null}}),n}(he),Re=function(t){function e(t){return this.observable.subscribe(t)}function n(n,r){t.call(this,e),this.observer=n,this.observable=r}return C(n,t),D(n.prototype,ne,{onCompleted:function(){this.observer.onCompleted()},onError:function(t){this.observer.onError(t)},onNext:function(t){this.observer.onNext(t)}}),n}(he);return"function"==typeof define&&"object"==typeof define.amd&&define.amd?(t.Rx=y,define(function(){return y})):(m?"object"==typeof module&&module&&module.exports==m?module.exports=y:m=y:t.Rx=y,e)})(this);
View
102 rx.modern.js
@@ -8,7 +8,7 @@
* @name Rx
* @type Object
*/
- var Rx = { Internals: {} };s
+ var Rx = { Internals: {} };
// Defaults
function noop() { }
@@ -29,6 +29,48 @@
}
}
+ var slice = Array.prototype.slice;
+ function argsOrArray(args, idx) {
+ return args.length === 1 && Array.isArray(args[idx]) ?
+ args[idx] :
+ slice.call(args);
+ }
+ var hasProp = {}.hasOwnProperty;
+
+ /** @private */
+ var inherits = this.inherits = Rx.Internals.inherits = function (child, parent) {
+ function __() { this.constructor = child; }
+ __.prototype = parent.prototype;
+ child.prototype = new __();
+ };
+
+ /** @private */
+ var addProperties = Rx.Internals.addProperties = function (obj) {
+ var sources = slice.call(arguments, 1);
+ for (var i = 0, len = sources.length; i < len; i++) {
+ var source = sources[i];
+ for (var prop in source) {
+ obj[prop] = source[prop];
+ }
+ }
+ };
+
+ // Rx Utils
+ var addRef = Rx.Internals.addRef = function (xs, r) {
+ return new AnonymousObservable(function (observer) {
+ return new CompositeDisposable(r.getDisposable(), xs.subscribe(observer));
+ });
+ };
+
+ // Collection polyfills
+ function arrayInitialize(count, factory) {
+ var a = new Array(count);
+ for (var i = 0; i < count; i++) {
+ a[i] = factory();
+ }
+ return a;
+ }
+
// Collections
var IndexedItem = function (id, value) {
this.id = id;
@@ -136,7 +178,7 @@
*
* @param {Mixed} item Disposable to add.
*/
- CompositeDisposablePrototypeadd = function (item) {
+ CompositeDisposablePrototype.add = function (item) {
if (this.isDisposed) {
item.dispose();
} else {
@@ -981,7 +1023,7 @@
}());
/** Provides a set of extension methods for virtual time scheduling. */
- root.VirtualTimeScheduler = (function () {
+ Rx.VirtualTimeScheduler = (function (_super) {
function localNow() {
return this.toDateTimeOffset(this.clock);
@@ -1004,7 +1046,7 @@
return disposableEmpty;
}
- inherits(VirtualTimeScheduler, Scheduler);
+ inherits(VirtualTimeScheduler, _super);
/**
* Creates a new virtual time scheduler with the specified initial clock value and absolute time comparer.
@@ -1018,7 +1060,7 @@
this.comparer = comparer;
this.isEnabled = false;
this.queue = new PriorityQueue(1024);
- VirtualTimeScheduler.super_.constructor.call(this, localNow, scheduleNow, scheduleRelative, scheduleAbsolute);
+ _super.call(this, localNow, scheduleNow, scheduleRelative, scheduleAbsolute);
}
var VirtualTimeSchedulerPrototype = VirtualTimeScheduler.prototype;
@@ -1213,7 +1255,7 @@
}
return VirtualTimeScheduler;
- }());
+ }(Scheduler));
/** Provides a virtual time scheduler that uses Date for absolute time and number for relative time. */
Rx.HistoricalScheduler = (function (_super) {
@@ -1229,7 +1271,7 @@
function HistoricalScheduler(initialClock, comparer) {
var clock = initialClock == null ? 0 : initialClock;
var cmp = comparer || defaultSubComparer;
- super_.call(this, clock, cmp);
+ _super.call(this, clock, cmp);
}
var HistoricalSchedulerProto = HistoricalScheduler.prototype;
@@ -4036,9 +4078,14 @@
}, observer.onError.bind(observer), observer.onCompleted.bind(observer));
});
};
+ /** @private */
var AnonymousObservable = Rx.Internals.AnonymousObservable = (function (_super) {
inherits(AnonymousObservable, _super);
+ /**
+ * @private
+ * @constructor
+ */
function AnonymousObservable(subscribe) {
function s(observer) {
@@ -4066,24 +4113,33 @@
return autoDetachObserver;
}
- super_.call(this, s);
+ _super.call(this, s);
}
return AnonymousObservable;
}(Observable));
+ /** @private */
var AutoDetachObserver = (function (_super) {
inherits(AutoDetachObserver, _super);
+ /**
+ * @private
+ * @constructor
+ */
function AutoDetachObserver(observer) {
- AutoDetachObserver.super_.constructor.call(this);
+ _super.call(this);
this.observer = observer;
this.m = new SingleAssignmentDisposable();
}
var AutoDetachObserverPrototype = AutoDetachObserver.prototype
+ /**
+ * @private
+ * @memberOf AutoDetachObserver#
+ */
AutoDetachObserverPrototype.next = function (value) {
var noError = false;
try {
@@ -4098,6 +4154,10 @@
}
};
+ /**
+ * @private
+ * @memberOf AutoDetachObserver#
+ */
AutoDetachObserverPrototype.error = function (exn) {
try {
this.observer.onError(exn);
@@ -4108,6 +4168,10 @@
}
};
+ /**
+ * @private
+ * @memberOf AutoDetachObserver#
+ */
AutoDetachObserverPrototype.completed = function () {
try {
this.observer.onCompleted();
@@ -4118,10 +4182,18 @@
}
};
+ /**
+ * @private
+ * @memberOf AutoDetachObserver#
+ */
AutoDetachObserverPrototype.disposable = function (value) {
return this.m.disposable(value);
};
+ /**
+ * @private
+ * @memberOf AutoDetachObserver#
+ */
AutoDetachObserverPrototype.dispose = function () {
_super.prototype.dispose.call(this);
this.m.dispose();
@@ -4177,7 +4249,7 @@
* Represents an object that is both an observable sequence as well as an observer.
* Each notification is broadcasted to all subscribed observers.
*/
- var Subject = root.Subject = (function (_super) {
+ var Subject = Rx.Subject = (function (_super) {
function subscribe(observer) {
checkDisposed.call(this);
if (!this.isStopped) {
@@ -4473,17 +4545,17 @@
// Check for AMD
if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
- window.Rx = root;
+ window.Rx = Rx;
return define(function () {
- return root;
+ return Rx;
});
} else if (freeExports) {
if (typeof module == 'object' && module && module.exports == freeExports) {
- module.exports = root;
+ module.exports = Rx;
} else {
- freeExports = root;
+ freeExports = Rx;
}
} else {
- window.Rx = root;
+ window.Rx = Rx;
}
}(this));
View
4 rx.modern.min.js
@@ -1,2 +1,2 @@
-(function(t,e){function n(){}function r(t){return t}function i(){return(new Date).getTime()}function o(t,e){return t===e}function s(t,e){return t-e}function u(t){return""+t}function c(t){throw t}function a(){if(this.isDisposed)throw Error(w)}function h(t,e){this.scheduler=t,this.disposable=e,this.isDisposed=!1}function l(t,e,n,r,i){this.scheduler=t,this.state=e,this.action=n,this.dueTime=r,this.comparer=i||s,this.disposable=new N}function f(t,n){return new be(function(r){var i=new N,o=new W;return o.setDisposable(i),i.setDisposable(t.subscribe(r.onNext.bind(r),function(t){var i,s;try{s=n(t)}catch(u){return r.onError(u),e}i=new N,o.setDisposable(i),i.setDisposable(s.subscribe(r))},r.onCompleted.bind(r))),o})}function p(t,n){var r=this;return new be(function(i){var o=0,s=t.length;return r.subscribe(function(r){if(s>o){var u,c=t[o++];try{u=n(r,c)}catch(a){return i.onError(a),e}i.onNext(u)}else i.onCompleted()},i.onError.bind(i),i.onCompleted.bind(i))})}function d(t){return this.select(t).mergeObservable()}var b="object"==typeof exports&&exports&&("object"==typeof global&&global&&global==global.global&&(t=global),exports),v={Internals:{}},m="Sequence contains no elements.",y="Argument out of range",w="Object has been disposed",g=function(t,e){this.id=t,this.value=e};g.prototype.compareTo=function(t){var e=this.value.compareTo(t.value);return 0===e&&(e=this.id-t.id),e};var E=function(t){this.items=Array(t),this.length=0},x=E.prototype;x.isHigherPriority=function(t,e){return 0>this.items[t].compareTo(this.items[e])},x.percolate=function(t){if(!(t>=this.length||0>t)){var e=t-1>>1;if(!(0>e||e===t)&&this.isHigherPriority(t,e)){var n=this.items[t];this.items[t]=this.items[e],this.items[e]=n,this.percolate(e)}}},x.heapify=function(t){if(t===e&&(t=0),!(t>=this.length||0>t)){var n=2*t+1,r=2*t+2,i=t;if(this.length>n&&this.isHigherPriority(n,i)&&(i=n),this.length>r&&this.isHigherPriority(r,i)&&(i=r),i!==t){var o=this.items[t];this.items[t]=this.items[i],this.items[i]=o,this.heapify(i)}}},x.peek=function(){return this.items[0].value},x.removeAt=function(t){this.items[t]=this.items[--this.length],delete this.items[this.length],this.heapify()},x.dequeue=function(){var t=this.peek();return this.removeAt(0),t},x.enqueue=function(t){var e=this.length++;this.items[e]=new g(E.count++,t),this.percolate(e)},x.remove=function(t){for(var e=0;this.length>e;e++)if(this.items[e].value===t)return this.removeAt(e),!0;return!1},E.count=0;var C=v.CompositeDisposable=function(){this.disposables=argsOrArray(arguments,0),this.isDisposed=!1,this.length=this.disposables.length},D=C.prototype;CompositeDisposablePrototypeadd=function(t){this.isDisposed?t.dispose():(this.disposables.push(t),this.length++)},D.remove=function(t){var e=!1;if(!this.isDisposed){var n=this.disposables.indexOf(t);-1!==n&&(e=!0,this.disposables.splice(n,1),this.length--,t.dispose())}return e},D.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var t=this.disposables.slice(0);this.disposables=[],this.length=0;for(var e=0,n=t.length;n>e;e++)t[e].dispose()}},D.clear=function(){var t=this.disposables.slice(0);this.disposables=[],this.length=0;for(var e=0,n=t.length;n>e;e++)t[e].dispose()},D.contains=function(t){return-1!==this.disposables.indexOf(t)},D.toArray=function(){return this.disposables.slice(0)};var A=v.Disposable=function(t){this.isDisposed=!1,this.action=t};A.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var _=A.create=function(t){return new A(t)},S=A.empty={dispose:n},N=v.SingleAssignmentDisposable=function(){this.isDisposed=!1,this.current=null},R=N.prototype;R.disposable=function(t){return t?this.setDisposable(t):this.getDisposable()},R.getDisposable=function(){return this.current},R.setDisposable=function(t){if(this.current)throw Error("Disposable has already been assigned");var e=this.isDisposed;e||(this.current=t),e&&t&&t.dispose()},R.dispose=function(){var t;this.isDisposed||(this.isDisposed=!0,t=this.current,this.current=null),t&&t.dispose()};var W=v.SerialDisposable=function(){this.isDisposed=!1,this.current=null};W.prototype.getDisposable=function(){return this.current},W.prototype.setDisposable=function(t){var e,n=this.isDisposed;n||(e=this.current,this.current=t),e&&e.dispose(),n&&t&&t.dispose()},W.prototype.disposable=function(t){return t?(this.setDisposable(t),e):this.getDisposable()},W.prototype.dispose=function(){var t;this.isDisposed||(this.isDisposed=!0,t=this.current,this.current=null),t&&t.dispose()};var O=v.RefCountDisposable=function(){function t(t){this.disposable=t,this.disposable.count++,this.isInnerDisposed=!1}function e(t){this.underlyingDisposable=t,this.isDisposed=!1,this.isPrimaryDisposed=!1,this.count=0}return t.prototype.dispose=function(){this.disposable.isDisposed||this.isInnerDisposed||(this.isInnerDisposed=!0,this.disposable.count--,0===this.disposable.count&&this.disposable.isPrimaryDisposed&&(this.disposable.isDisposed=!0,this.disposable.underlyingDisposable.dispose()))},e.prototype.dispose=function(){this.isDisposed||this.isPrimaryDisposed||(this.isPrimaryDisposed=!0,0===this.count&&(this.isDisposed=!0,this.underlyingDisposable.dispose()))},e.prototype.getDisposable=function(){return this.isDisposed?S:new t(this)},e}();h.prototype.dispose=function(){var t=this;this.scheduler.schedule(function(){t.isDisposed||(t.isDisposed=!0,t.disposable.dispose())})},l.prototype.invoke=function(){this.disposable.disposable(this.invokeCore())},l.prototype.compareTo=function(t){return this.comparer(this.dueTime,t.dueTime)},l.prototype.isCancelled=function(){return this.disposable.isDisposed},l.prototype.invokeCore=function(){return this.action(this.scheduler,this.state)};var k=v.Scheduler=function(){function e(t,e,n,r){this.now=t,this._schedule=e,this._scheduleRelative=n,this._scheduleAbsolute=r}function n(t,e){var n=e.first,r=e.second,i=new C,o=function(e){r(e,function(e){var n=!1,r=!1,s=t.scheduleWithState(e,function(t,e){return n?i.remove(s):r=!0,o(e),S});r||(i.add(s),n=!0)})};return o(n),i}function r(t,e,n){var r=e.first,i=e.second,o=new C,s=function(e){i(e,function(e,r){var i=!1,u=!1,c=t[n].call(t,e,r,function(t,e){return i?o.remove(c):u=!0,s(e),S});u||(o.add(c),i=!0)})};return s(r),o}function o(t,e){return e(),S}var s=e.prototype;return s.catchException=function(t){return new z(this,t)},s.schedulePeriodic=function(t,e){return this.schedulePeriodicWithState(null,t,function(){e()})},s.schedulePeriodicWithState=function(e,n,r){var i=e,o=t.setInterval(function(){i=r(i)},n);return _(function(){t.clearInterval(o)})},s.schedule=function(t){return this._schedule(t,o)},s.scheduleWithState=function(t,e){return this._schedule(t,e)},s.scheduleWithRelative=function(t,e){return this._scheduleRelative(e,t,o)},s.scheduleWithRelativeAndState=function(t,e,n){return this._scheduleRelative(t,e,n)},s.scheduleWithAbsolute=function(t,e){return this._scheduleAbsolute(e,t,o)},s.scheduleWithAbsoluteAndState=function(t,e,n){return this._scheduleAbsolute(t,e,n)},s.scheduleRecursive=function(t){return this.scheduleRecursiveWithState(t,function(t,e){t(function(){e(t)})})},s.scheduleRecursiveWithState=function(t,e){return this.scheduleWithState({first:t,second:e},function(t,e){return n(t,e)})},s.scheduleRecursiveWithRelative=function(t,e){return this.scheduleRecursiveWithRelativeAndState(e,t,function(t,e){t(function(n){e(t,n)})})},s.scheduleRecursiveWithRelativeAndState=function(t,e,n){return this._scheduleRelative({first:t,second:n},e,function(t,e){return r(t,e,"scheduleWithRelativeAndState")})},s.scheduleRecursiveWithAbsolute=function(t,e){return this.scheduleRecursiveWithAbsoluteAndState(e,t,function(t,e){t(function(n){e(t,n)})})},s.scheduleRecursiveWithAbsoluteAndState=function(t,e,n){return this._scheduleAbsolute({first:t,second:n},e,function(t,e){return r(t,e,"scheduleWithAbsoluteAndState")})},e.now=i,e.normalize=function(t){return 0>t&&(t=0),t},e}(),q="Scheduler is not allowed to block the thread",T=k.immediate=function(){function t(t,e){return e(this,t)}function e(t,e,n){if(e>0)throw Error(q);return n(this,t)}function n(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new k(i,t,e,n)}(),j=k.currentThread=function(){function t(){o=new E(4)}function e(t,e){return this.scheduleWithRelativeAndState(t,0,e)}function n(e,n,r){var i,s=this.now()+k.normalize(n),u=new l(this,e,r,s);if(o)o.enqueue(u);else{i=new t;try{o.enqueue(u),i.run()}catch(c){throw c}finally{i.dispose()}}return u.disposable}function r(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}var o;t.prototype.dispose=function(){o=null},t.prototype.run=function(){for(var t;o.length>0;)if(t=o.dequeue(),!t.isCancelled()){for(;t.dueTime-k.now()>0;);t.isCancelled()||t.invoke()}};var s=new k(i,e,n,r);return s.scheduleRequired=function(){return null===o},s.ensureTrampoline=function(t){return null===o?this.schedule(t):t()},s}(),I=function(){function t(t,e){e(0,this._period);try{this._state=this._action(this._state)}catch(n){throw this._cancel.dispose(),n}}function e(t,e,n,r){this._scheduler=t,this._state=e,this._period=n,this._action=r}return e.prototype.start=function(){var e=new N;return this._cancel=e,e.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,t.bind(this))),e},e}();root.VirtualTimeScheduler=function(){function t(){return this.toDateTimeOffset(this.clock)}function n(t,e){return this.scheduleAbsoluteWithState(t,this.clock,e)}function r(t,e,n){return this.scheduleRelativeWithState(t,this.toRelative(e),n)}function i(t,e,n){return this.scheduleRelativeWithState(t,this.toRelative(e-this.now()),n)}function o(t,e){return e(),S}function s(e,o){this.clock=e,this.comparer=o,this.isEnabled=!1,this.queue=new E(1024),s.super_.constructor.call(this,t,n,r,i)}inherits(s,k);var u=s.prototype;return u.schedulePeriodicWithState=function(t,e,n){var r=new I(this,t,e,n);return r.start()},u.scheduleRelativeWithState=function(t,e,n){var r=this.add(this.clock,e);return this.scheduleAbsoluteWithState(t,r,n)},u.scheduleRelative=function(t,e){return this.scheduleRelativeWithState(e,t,o)},u.start=function(){var t;if(!this.isEnabled){this.isEnabled=!0;do t=this.getNext(),null!==t?(this.comparer(t.dueTime,this.clock)>0&&(this.clock=t.dueTime),t.invoke()):this.isEnabled=!1;while(this.isEnabled)}},u.stop=function(){this.isEnabled=!1},u.advanceTo=function(t){var e,n=this.comparer(this.clock,t);if(this.comparer(this.clock,t)>0)throw Error(y);if(0!==n&&!this.isEnabled){this.isEnabled=!0;do e=this.getNext(),null!==e&&0>=this.comparer(e.dueTime,t)?(this.comparer(e.dueTime,this.clock)>0&&(this.clock=e.dueTime),e.invoke()):this.isEnabled=!1;while(this.isEnabled);this.clock=t}},u.advanceBy=function(t){var n=this.add(this.clock,t),r=this.comparer(this.clock,n);if(r>0)throw Error(y);return 0!==r?this.advanceTo(n):e},u.sleep=function(t){var e=this.add(this.clock,t);if(this.comparer(this.clock,e)>=0)throw Error(y);this.clock=e},u.getNext=function(){for(var t;this.queue.length>0;){if(t=this.queue.peek(),!t.isCancelled())return t;this.queue.dequeue()}return null},u.scheduleAbsolute=function(t,e){return this.scheduleAbsoluteWithState(e,t,o)},u.scheduleAbsoluteWithState=function(t,e,n){var r=this,i=function(t,e){return r.queue.remove(o),n(t,e)},o=new l(r,t,i,e,r.comparer);return r.queue.enqueue(o),o.disposable},s}(),v.HistoricalScheduler=function(t){function e(t,e){var n=null==t?0:t,r=e||s;super_.call(this,n,r)}inherits(e,t);var n=e.prototype;return n.add=function(t,e){return t+e},n.toDateTimeOffset=function(t){return new Date(t).getTime()},n.toRelative=function(t){return t},e}(v.VirtualTimeScheduler);var P=k.timeout=function(){function r(t,e){var n=this,r=new N,i=u(function(){r.setDisposable(e(n,t))});return new C(r,_(function(){c(i)}))}function o(e,n,r){var i=this,o=k.normalize(n);if(0===o)return i.scheduleWithState(e,r);var s=new N,u=t.setTimeout(function(){s.setDisposable(r(i,e))},o);return new C(s,_(function(){t.clearTimeout(u)}))}function s(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}var u,c,a="equestAnimationFrame",h="ancelAnimationFrame",l=t["r"+a]||t["webkitR"+a]||t["mozR"+a]||t["oR"+a]||t["msR"+a],f=t["c"+h]||t["webkitC"+h]||t["mozC"+h]||t["oC"+h]||t["msC"+h];return t.process!==e&&"function"==typeof t.process.nextTick?(u=t.process.nextTick,c=n):"function"==typeof t.setImmediate?(u=t.setImmediate,c=t.clearImmediate):"function"==typeof l?(u=l,c=f):(u=function(e){return t.setTimeout(e,0)},c=t.clearTimeout),new k(i,r,o,s)}(),z=function(t){function e(){return this._scheduler.now()}function n(t,e){return this._scheduler.scheduleWithState(t,this._wrap(e))}function r(t,e,n){return this._scheduler.scheduleWithRelativeAndState(t,e,this._wrap(n))}function i(t,e,n){return this._scheduler.scheduleWithAbsoluteAndState(t,e,this._wrap(n))}function o(o,s){this._scheduler=o,this._handler=s,this._recursiveOriginal=null,this._recursiveWrapper=null,t.call(this,e,n,r,i)}return inherits(o,t),o.prototype._clone=function(t){return new o(t,this._handler)},o.prototype._wrap=function(t){var e=this;return function(n,r){try{return t(e._getRecursiveWrapper(n),r)}catch(i){if(!e._handler(i))throw i;return S}}},o.prototype._getRecursiveWrapper=function(t){if(!this._recursiveOriginal!==t){this._recursiveOriginal=t;var e=this._clone(t);e._recursiveOriginal=t,e._recursiveWrapper=e,this._recursiveWrapper=e}return this._recursiveWrapper},o.prototype.schedulePeriodicWithState=function(t,e,n){var r=this,i=!1,o=new N;return o.setDisposable(this._scheduler.schedulePeriodicWithState(t,e,function(t){if(i)return null;try{return n(t)}catch(e){if(i=!0,!r._handler(e))throw e;return o.dispose(),null}})),o},o}(k),V=v.Notification=function(){function t(t,e){this.hasValue=null==e?!1:e,this.kind=t}var e=t.prototype;return e.accept=function(t,e,n){return 1===arguments.length&&"object"==typeof t?this._acceptObservable(t):this._accept(t,e,n)},e.toObservable=function(t){var e=this;return t=t||T,new be(function(n){return t.schedule(function(){e._acceptObservable(n),"N"===e.kind&&n.onCompleted()})})},e.equals=function(t){var e=null==t?"":""+t;return""+this===e},t}(),L=V.createOnNext=function(){function t(t){return t(this.value)}function e(t){return t.onNext(this.value)}function n(){return"OnNext("+this.value+")"}return function(r){var i=new V("N",!0);return i.value=r,i._accept=t.bind(i),i._acceptObservable=e.bind(i),i.toString=n.bind(i),i}}(),F=V.createOnError=function(){function t(t,e){return e(this.exception)}function e(t){return t.onError(this.exception)}function n(){return"OnError("+this.exception+")"}return function(r){var i=new V("E");return i.exception=r,i._accept=t.bind(i),i._acceptObservable=e.bind(i),i.toString=n.bind(i),i}}(),M=V.createOnCompleted=function(){function t(t,e,n){return n()}function e(t){return t.onCompleted()}function n(){return"OnCompleted()"}return function(){var r=new V("C");return r._accept=t.bind(r),r._acceptObservable=e.bind(r),r.toString=n.bind(r),r}}(),B=v.Internals.Enumerator=function(t,e,n){this.moveNext=t,this.getCurrent=e,this.dispose=n},H=B.create=function(t,e,r){var i=!1;return r||(r=n),new B(function(){if(i)return!1;var e=t();return e||(i=!0,r()),e},function(){return e()},function(){i||(r(),i=!0)})},U=v.Internals.Enumerable=function(){function t(t){this.getEnumerator=t}return t.prototype.concat=function(){var t=this;return new be(function(n){var r=t.getEnumerator(),i=!1,o=new W,s=T.scheduleRecursive(function(t){var s,u,c=!1;if(!i){try{c=r.moveNext(),c?s=r.getCurrent():r.dispose()}catch(a){u=a,r.dispose()}if(u)return n.onError(u),e;if(!c)return n.onCompleted(),e;var h=new N;o.setDisposable(h),h.setDisposable(s.subscribe(n.onNext.bind(n),n.onError.bind(n),function(){t()}))}});return new C(o,s,_(function(){i=!0,r.dispose()}))})},t.prototype.catchException=function(){var t=this;return new be(function(n){var r,i=t.getEnumerator(),o=!1,s=new W,u=T.scheduleRecursive(function(t){var u,c,a;if(a=!1,!o){try{a=i.moveNext(),a&&(u=i.getCurrent())}catch(h){c=h}if(c)return n.onError(c),e;if(!a)return r?n.onError(r):n.onCompleted(),e;var l=new N;s.setDisposable(l),l.setDisposable(u.subscribe(n.onNext.bind(n),function(e){r=e,t()},n.onCompleted.bind(n)))}});return new C(s,u,_(function(){o=!0}))})},t}(),G=U.repeat=function(t,n){return n===e&&(n=-1),new U(function(){var e,r=n;return H(function(){return 0===r?!1:(r>0&&r--,e=t,!0)},function(){return e})})},J=U.forEach=function(t,e){return e||(e=r),new U(function(){var n,r=-1;return H(function(){return++r<t.length?(n=e(t[r],r),!0):!1},function(){return n})})},K=v.Observer=function(){};K.prototype.toNotifier=function(){var t=this;return function(e){return e.accept(t)}},K.prototype.asObserver=function(){return new Z(this.onNext.bind(this),this.onError.bind(this),this.onCompleted.bind(this))},K.prototype.checked=function(){return new $(this)};var Q=K.create=function(t,e,r){return t||(t=n),e||(e=c),r||(r=n),new Z(t,e,r)};K.fromNotifier=function(t){return new Z(function(e){return t(L(e))},function(e){return t(F(e))},function(){return t(M())})};var X,Y=v.Internals.AbstractObserver=function(t){function e(){this.isStopped=!1,t.call(this)}return inherits(e,t),e.prototype.onNext=function(t){this.isStopped||this.next(t)},e.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.error(t))},e.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.completed())},e.prototype.dispose=function(){this.isStopped=!0},e.prototype.fail=function(){return this.isStopped?!1:(this.isStopped=!0,this.error(!0),!0)},e}(K),Z=v.AnonymousObserver=function(t){function e(e,n,r){t.call(this),this._onNext=e,this._onError=n,this._onCompleted=r}return inherits(e,t),e.prototype.next=function(t){this._onNext(t)},e.prototype.error=function(t){this._onError(t)},e.prototype.completed=function(){this._onCompleted()},e}(Y),$=function(t){function e(e){t.call(this),this._observer=e,this._state=0}inherits(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}(K),te=v.Internals.ScheduledObserver=function(t){function n(e,n){t.call(this),this.scheduler=e,this.observer=n,this.isAcquired=!1,this.hasFaulted=!1,this.queue=[],this.disposable=new W}return inherits(n,t),n.prototype.next=function(t){var e=this;this.queue.push(function(){e.observer.onNext(t)})},n.prototype.error=function(t){var e=this;this.queue.push(function(){e.observer.onError(t)})},n.prototype.completed=function(){var t=this;this.queue.push(function(){t.observer.onCompleted()})},n.prototype.ensureActive=function(){var t=!1,n=this;!this.hasFaulted&&this.queue.length>0&&(t=!this.isAcquired,this.isAcquired=!0),t&&this.disposable.setDisposable(this.scheduler.scheduleRecursive(function(t){var r;if(!(n.queue.length>0))return n.isAcquired=!1,e;r=n.queue.shift();try{r()}catch(i){throw n.queue=[],n.hasFaulted=!0,i}t()}))},n.prototype.dispose=function(){t.prototype.dispose.call(this),this.disposable.dispose()},n}(Y),ee=function(t){function e(){t.apply(this,arguments)}return inherits(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}(te),ne=v.Observable=function(){function t(t){this._subscribe=t}return X=t.prototype,X.finalValue=function(){var t=this;return new be(function(e){var n,r=!1;return t.subscribe(function(t){r=!0,n=t},e.onError.bind(e),function(){r?(e.onNext(n),e.onCompleted()):e.onError(Error(m))})})},X.subscribe=X.forEach=function(t,e,n){var r;return r="object"==typeof t?t:Q(t,e,n),this._subscribe(r)},X.toArray=function(){function t(t,e){var n=t.slice(0);return n.push(e),n}return this.scan([],t).startWith([]).finalValue()},t}();ne.start=function(t,e){return re(t,e)()};var re=ne.toAsync=function(t,n,r){return n||(n=P),function(){var i=slice.call(arguments,0),o=new ge;return n.schedule(function(){var n;try{n=t.apply(r,i)}catch(s){return o.onError(s),e}o.onNext(n),o.onCompleted()}),o.asObservable()}};X.observeOn=function(t){var e=this;return new be(function(n){return e.subscribe(new ee(t,n))})},X.subscribeOn=function(t){var e=this;return new be(function(n){var r=new N,i=new W;return i.setDisposable(r),r.setDisposable(t.schedule(function(){i.setDisposable(new h(t,e.subscribe(n)))})),i})},ne.create=function(t){return new be(function(e){return _(t(e))})},ne.createWithDisposable=function(t){return new be(t)};var ie=ne.defer=function(t){return new be(function(e){var n;try{n=t()}catch(r){return ae(r).subscribe(e)}return n.subscribe(e)})},oe=ne.empty=function(t){return t||(t=T),new be(function(e){return t.schedule(function(){e.onCompleted()})})},se=ne.fromArray=function(t,e){return e||(e=j),new be(function(n){var r=0;return e.scheduleRecursive(function(e){t.length>r?(n.onNext(t[r++]),e()):n.onCompleted()})})};ne.generate=function(t,n,r,i,o){return o||(o=j),new be(function(s){var u=!0,c=t;return o.scheduleRecursive(function(t){var o,a;try{u?u=!1:c=r(c),o=n(c),o&&(a=i(c))}catch(h){return s.onError(h),e}o?(s.onNext(a),t()):s.onCompleted()})})};var ue=ne.never=function(){return new be(function(){return S})};ne.range=function(t,e,n){return n||(n=j),new be(function(r){return n.scheduleRecursiveWithState(0,function(n,i){e>n?(r.onNext(t+n),i(n+1)):r.onCompleted()})})},ne.repeat=function(t,n,r){return r||(r=j),n==e&&(n=-1),ce(t,r).repeat(n)};var ce=ne.returnValue=function(t,e){return e||(e=T),new be(function(n){return e.schedule(function(){n.onNext(t),n.onCompleted()})})},ae=ne.throwException=function(t,e){return e||(e=T),new be(function(n){return e.schedule(function(){n.onError(t)})})};ne.using=function(t,e){return new be(function(n){var r,i,o=S;try{r=t(),r&&(o=r),i=e(r)}catch(s){return new C(ae(s).subscribe(n),o)}return new C(i.subscribe(n),o)})},X.amb=function(t){var e=this;return new be(function(n){function r(){o||(o=s,a.dispose())}function i(){o||(o=u,c.dispose())}var o,s="L",u="R",c=new N,a=new N;return 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 C(c,a)})},ne.amb=function(){function t(t,e){return t.amb(e)}for(var e=ue(),n=argsOrArray(arguments,0),r=0,i=n.length;i>r;r++)e=t(e,n[r]);return e},X.catchException=function(t){return"function"==typeof t?f(this,t):he([this,t])};var he=ne.catchException=function(){var t=argsOrArray(arguments,0);return J(t).catchException()};X.combineLatest=function(){var t=slice.call(arguments);return Array.isArray(t[0])?t[0].unshift(this):t.unshift(this),le.apply(this,t)};var le=ne.combineLatest=function(){var t=slice.call(arguments),n=t.pop();return Array.isArray(t[0])&&(t=t[0]),new be(function(r){function i(t){var i;if(c[t]=!0,a||(a=c.every(function(t){return t}))){try{i=n.apply(null,l)}catch(o){return r.onError(o),e}r.onNext(i)}else h.filter(function(e,n){return n!==t}).every(function(t){return t})&&r.onCompleted()}function o(t){h[t]=!0,h.every(function(t){return t})&&r.onCompleted()}for(var s=function(){return!1},u=t.length,c=arrayInitialize(u,s),a=!1,h=arrayInitialize(u,s),l=Array(u),f=Array(u),p=0;u>p;p++)(function(e){f[e]=new N,f[e].setDisposable(t[e].subscribe(function(t){l[e]=t,i(e)},r.onError.bind(r),function(){o(e)}))})(p);return new C(f)})};X.concat=function(){var t=slice.call(arguments,0);return t.unshift(this),fe.apply(this,t)};var fe=ne.concat=function(){var t=argsOrArray(arguments,0);return J(t).concat()};X.concatObservable=X.concatAll=function(){return this.merge(1)},X.merge=function(t){if("number"!=typeof t)return pe(this,t);var e=this;return new be(function(n){var r=0,i=new C,o=!1,s=[],u=function(t){var e=new N;i.add(e),e.setDisposable(t.subscribe(n.onNext.bind(n),n.onError.bind(n),function(){var t;i.remove(e),s.length>0?(t=s.shift(),u(t)):(r--,o&&0===r&&n.onCompleted())}))};return i.add(e.subscribe(function(e){t>r?(r++,u(e)):s.push(e)},n.onError.bind(n),function(){o=!0,0===r&&n.onCompleted()})),i})};var pe=ne.merge=function(){var t,e;return arguments[0]?arguments[0].now?(t=arguments[0],e=slice.call(arguments,1)):(t=T,e=slice.call(arguments,0)):(t=T,e=slice.call(arguments,1)),Array.isArray(e[0])&&(e=e[0]),se(e,t).mergeObservable()};X.mergeObservable=X.mergeAll=function(){var t=this;return new be(function(e){var n=new C,r=!1,i=new N;return n.add(i),i.setDisposable(t.subscribe(function(t){var i=new N;n.add(i),i.setDisposable(t.subscribe(function(t){e.onNext(t)},e.onError.bind(e),function(){n.remove(i),r&&1===n.length&&e.onCompleted()}))},e.onError.bind(e),function(){r=!0,1===n.length&&e.onCompleted()})),n})},X.onErrorResumeNext=function(t){if(!t)throw Error("Second observable is required");return de([this,t])};var de=ne.onErrorResumeNext=function(){var t=argsOrArray(arguments,0);return new be(function(e){var n=0,r=new W,i=T.scheduleRecursive(function(i){var o,s;t.length>n?(o=t[n++],s=new N,r.setDisposable(s),s.setDisposable(o.subscribe(e.onNext.bind(e),function(){i()},function(){i()}))):e.onCompleted()});return new C(r,i)})};X.skipUntil=function(t){var e=this;return new be(function(n){var r=!1,i=new C(e.subscribe(function(t){r&&n.onNext(t)},n.onError.bind(n),function(){r&&n.onCompleted()})),o=new N;return i.add(o),o.setDisposable(t.subscribe(function(){r=!0,o.dispose()},n.onError.bind(n),function(){o.dispose()})),i})},X.switchLatest=function(){var t=this;return new be(function(e){var n=!1,r=new W,i=!1,o=0,s=t.subscribe(function(t){var s=new N,u=++o;n=!0,r.setDisposable(s),s.setDisposable(t.subscribe(function(t){o===u&&e.onNext(t)},function(t){o===u&&e.onError(t)},function(){o===u&&(n=!1,i&&e.onCompleted())}))},e.onError.bind(e),function(){i=!0,n||e.onCompleted()});return new C(s,r)})},X.takeUntil=function(t){var e=this;return new be(function(r){return new C(e.subscribe(r),t.subscribe(r.onCompleted.bind(r),r.onError.bind(r),n))})},X.zip=function(){if(Array.isArray(arguments[0]))return p.apply(this,arguments);var t=this,n=slice.call(arguments),r=n.pop();return n.unshift(t),new be(function(i){function o(t){c[t]=!0,c.every(function(t){return t})&&i.onCompleted()}for(var s=n.length,u=arrayInitialize(s,function(){return[]}),c=arrayInitialize(s,function(){return!1}),a=function(n){var o,s;if(u.every(function(t){return t.length>0})){try{s=u.map(function(t){return t.shift()}),o=r.apply(t,s)}catch(a){return i.onError(a),e}i.onNext(o)}else c.filter(function(t,e){return e!==n}).every(function(t){return t})&&i.onCompleted()},h=Array(s),l=0;s>l;l++)(function(t){h[t]=new N,h[t].setDisposable(n[t].subscribe(function(e){u[t].push(e),a(t)},i.onError.bind(i),function(){o(t)}))})(l);return new C(h)})},ne.zip=function(t,e){var n=t[0],r=t.slice(1);return r.push(e),n.zip.apply(n,r)},X.asObservable=function(){var t=this;return new be(function(e){return t.subscribe(e)})},X.bufferWithCount=function(t,n){return n===e&&(n=t),this.windowWithCount(t,n).selectMany(function(t){return t.toArray()}).where(function(t){return t.length>0})},X.dematerialize=function(){var t=this;return new be(function(e){return t.subscribe(function(t){return t.accept(e)},e.onError.bind(e),e.onCompleted.bind(e))})},X.distinctUntilChanged=function(t,n){var i=this;return t||(t=r),n||(n=o),new be(function(r){var o,s=!1;return i.subscribe(function(i){var u,c=!1;try{u=t(i)}catch(a){return r.onError(a),e}if(s)try{c=n(o,u)}catch(a){return r.onError(a),e}s&&c||(s=!0,o=u,r.onNext(i))},r.onError.bind(r),r.onCompleted.bind(r))})},X.doAction=function(t,e,n){var r,i=this;return"function"==typeof t?r=t:(r=t.onNext.bind(t),e=t.onError.bind(t),n=t.onCompleted.bind(t)),new be(function(t){return i.subscribe(function(e){try{r(e)}catch(n){t.onError(n)}t.onNext(e)},function(n){if(e){try{e(n)}catch(r){t.onError(r)}t.onError(n)}else t.onError(n)},function(){if(n){try{n()}catch(e){t.onError(e)}t.onCompleted()}else t.onCompleted()})})},X.finallyAction=function(t){var e=this;return new be(function(n){var r=e.subscribe(n);return _(function(){try{r.dispose()}catch(e){throw e}finally{t()}})})},X.ignoreElements=function(){var t=this;return new be(function(e){return t.subscribe(n,e.onError.bind(e),e.onCompleted.bind(e))})},X.materialize=function(){var t=this;return new be(function(e){return t.subscribe(function(t){e.onNext(L(t))},function(t){e.onNext(F(t)),e.onCompleted()},function(){e.onNext(M()),e.onCompleted()})})},X.repeat=function(t){return G(this,t).concat()},X.retry=function(t){return G(this,t).catchException()},X.scan=function(){var t,e,n=!1;2===arguments.length?(t=arguments[0],e=arguments[1],n=!0):e=arguments[0];var r=this;return ie(function(){var i,o=!1;return r.select(function(r){return o?i=e(i,r):(i=n?e(t,r):r,o=!0),i})})},X.skipLast=function(t){var e=this;return new be(function(n){var r=[];return e.subscribe(function(e){r.push(e),r.length>t&&n.onNext(r.shift())},n.onError.bind(n),n.onCompleted.bind(n))})},X.startWith=function(){var t,n,r=0;return arguments.length>0&&null!=arguments[0]&&arguments[0].now!==e?(n=arguments[0],r=1):n=T,t=slice.call(arguments,r),J([se(t,n),this]).concat()},X.takeLast=function(t,e){return this.takeLastBuffer(t).selectMany(function(t){return se(t,e)})},X.takeLastBuffer=function(t){var e=this;return new be(function(n){var r=[];return e.subscribe(function(e){r.push(e),r.length>t&&r.shift()},n.onError.bind(n),function(){n.onNext(r),n.onCompleted()})})},X.windowWithCount=function(t,e){var n=this;if(0>=t)throw Error(y);if(null==e&&(e=t),0>=e)throw Error(y);return new be(function(r){var i=new N,o=new O(i),s=0,u=[],c=function(){var t=new we;u.push(t),r.onNext(addRef(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})},X.defaultIfEmpty=function(t){var n=this;return t===e&&(t=null),new be(function(e){var r=!1;return n.subscribe(function(t){r=!0,e.onNext(t)},e.onError.bind(e),function(){r||e.onNext(t),e.onCompleted()})})},X.distinct=function(t,n){var i=this;return t||(t=r),n||(n=u),new be(function(r){var o={};return i.subscribe(function(i){var s,u,c,a=!1;try{s=t(i),u=n(s)}catch(h){return r.onError(h),e}for(c in o)if(u===c){a=!0;break}a||(o[u]=null,r.onNext(i))},r.onError.bind(r),r.onCompleted.bind(r))})},X.groupBy=function(t,e,n){return this.groupByUntil(t,e,function(){return ue()},n)},X.groupByUntil=function(t,i,o,s){var c=this;return i||(i=r),s||(s=u),new be(function(r){var u={},a=new C,h=new O(a);return a.add(c.subscribe(function(c){var l,f,p,d,b,v,m,y,w,g,E;try{m=t(c),y=s(m)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}b=!1;try{g=u[y],g||(g=new we,u[y]=g,b=!0)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}if(b){v=new me(m,g,h),f=new me(m,g);try{l=o(f)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}r.onNext(v),w=new N,a.add(w),d=function(){y in u&&(delete u[y],g.onCompleted()),a.remove(w)},w.setDisposable(l.take(1).subscribe(n,function(t){for(E in u)u[E].onError(t);r.onError(t)},function(){d()}))}try{p=i(c)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}g.onNext(p)},function(t){for(var e in u)u[e].onError(t);r.onError(t)},function(){for(var t in u)u[t].onCompleted();r.onCompleted()})),h})},X.select=X.map=function(t){var n=this;return new be(function(r){var i=0;return n.subscribe(function(n){var o;try{o=t(n,i++)}catch(s){return r.onError(s),e}r.onNext(o)},r.onError.bind(r),r.onCompleted.bind(r))})},X.selectMany=X.flatMap=function(t,e){return e?this.selectMany(function(n){return t(n).select(function(t){return e(n,t)
-})}):"function"==typeof t?d.call(this,t):d.call(this,function(){return t})},X.skip=function(t){if(0>t)throw Error(y);var e=this;return new be(function(n){var r=t;return e.subscribe(function(t){0>=r?n.onNext(t):r--},n.onError.bind(n),n.onCompleted.bind(n))})},X.skipWhile=function(t){var n=this;return new be(function(r){var i=0,o=!1;return n.subscribe(function(n){if(!o)try{o=!t(n,i++)}catch(s){return r.onError(s),e}o&&r.onNext(n)},r.onError.bind(r),r.onCompleted.bind(r))})},X.take=function(t,e){if(0>t)throw Error(y);if(0===t)return oe(e);var n=this;return new be(function(e){var r=t;return n.subscribe(function(t){r>0&&(r--,e.onNext(t),0===r&&e.onCompleted())},e.onError.bind(e),e.onCompleted.bind(e))})},X.takeWhile=function(t){var n=this;return new be(function(r){var i=0,o=!0;return n.subscribe(function(n){if(o){try{o=t(n,i++)}catch(s){return r.onError(s),e}o?r.onNext(n):r.onCompleted()}},r.onError.bind(r),r.onCompleted.bind(r))})},X.where=X.filter=function(t){var n=this;return new be(function(r){var i=0;return n.subscribe(function(n){var o;try{o=t(n,i++)}catch(s){return r.onError(s),e}o&&r.onNext(n)},r.onError.bind(r),r.onCompleted.bind(r))})};var be=v.Internals.AnonymousObservable=function(t){function e(t){function e(e){var n=new ve(e);if(j.scheduleRequired())j.schedule(function(){try{n.disposable(t(n))}catch(e){if(!n.fail(e))throw e}});else try{n.disposable(t(n))}catch(r){if(!n.fail(r))throw r}return n}super_.call(this,e)}return inherits(e,t),e}(ne),ve=function(t){function e(t){e.super_.constructor.call(this),this.observer=t,this.m=new N}inherits(e,t);var n=e.prototype;return n.next=function(t){var e=!1;try{this.observer.onNext(t),e=!0}catch(n){throw n}finally{e||this.dispose()}},n.error=function(t){try{this.observer.onError(t)}catch(e){throw e}finally{this.dispose()}},n.completed=function(){try{this.observer.onCompleted()}catch(t){throw t}finally{this.dispose()}},n.disposable=function(t){return this.m.disposable(t)},n.dispose=function(){t.prototype.dispose.call(this),this.m.dispose()},e}(Y),me=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 be(function(t){return new C(i.getDisposable(),r.subscribe(t))}):r}return inherits(n,t),n}(ne),ye=function(t,e){this.subject=t,this.observer=e};ye.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var t=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(t,1),this.observer=null}};var we=root.Subject=function(t){function e(t){return a.call(this),this.isStopped?this.exception?(t.onError(this.exception),S):(t.onCompleted(),S):(this.observers.push(t),new ye(this,t))}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.observers=[]}return inherits(n,t),addProperties(n.prototype,K,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(a.call(this),!this.isStopped){var t=this.observers.slice(0);this.isStopped=!0;for(var e=0,n=t.length;n>e;e++)t[e].onCompleted();this.observers=[]}},onError:function(t){if(a.call(this),!this.isStopped){var e=this.observers.slice(0);this.isStopped=!0,this.exception=t;for(var n=0,r=e.length;r>n;n++)e[n].onError(t);this.observers=[]}},onNext:function(t){if(a.call(this),!this.isStopped)for(var e=this.observers.slice(0),n=0,r=e.length;r>n;n++)e[n].onNext(t)},dispose:function(){this.isDisposed=!0,this.observers=null}}),n.create=function(t,e){return new Ee(t,e)},n}(ne),ge=v.AsyncSubject=function(t){function e(t){if(a.call(this),!this.isStopped)return this.observers.push(t),new ye(this,t);var e=this.exception,n=this.hasValue,r=this.value;return e?t.onError(e):n?(t.onNext(r),t.onCompleted()):t.onCompleted(),S}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.value=null,this.hasValue=!1,this.observers=[],this.exception=null}return inherits(n,t),addProperties(n.prototype,K,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){var t,e,n;if(a.call(this),!this.isStopped){var r=this.observers.slice(0);this.isStopped=!0;var i=this.value,o=this.hasValue;if(o)for(e=0,n=r.length;n>e;e++)t=r[e],t.onNext(i),t.onCompleted();else for(e=0,n=r.length;n>e;e++)r[e].onCompleted();this.observers=[]}},onError:function(t){if(a.call(this),!this.isStopped){var e=this.observers.slice(0);this.isStopped=!0,this.exception=t;for(var n=0,r=e.length;r>n;n++)e[n].onError(t);this.observers=[]}},onNext:function(t){a.call(this),this.isStopped||(this.value=t,this.hasValue=!0)},dispose:function(){this.isDisposed=!0,this.observers=null,this.exception=null,this.value=null}}),n}(ne),Ee=function(t){function e(t){return this.observable.subscribe(t)}function n(n,r){t.call(this,e),this.observer=n,this.observable=r}return inherits(n,t),addProperties(n.prototype,K,{onCompleted:function(){this.observer.onCompleted()},onError:function(t){this.observer.onError(t)},onNext:function(t){this.observer.onNext(t)}}),n}(ne);return"function"==typeof define&&"object"==typeof define.amd&&define.amd?(t.Rx=root,define(function(){return root})):(b?"object"==typeof module&&module&&module.exports==b?module.exports=root:b=root:t.Rx=root,e)})(this);
+(function(t,e){function n(){}function r(t){return t}function i(){return(new Date).getTime()}function o(t,e){return t===e}function s(t,e){return t-e}function u(t){return""+t}function c(t){throw t}function a(){if(this.isDisposed)throw Error(E)}function h(t,e){return 1===t.length&&Array.isArray(t[e])?t[e]:x.call(t)}function l(t,e){for(var n=Array(t),r=0;t>r;r++)n[r]=e();return n}function f(t,e){this.scheduler=t,this.disposable=e,this.isDisposed=!1}function p(t,e,n,r,i){this.scheduler=t,this.state=e,this.action=n,this.dueTime=r,this.comparer=i||s,this.disposable=new T}function d(t,n){return new Ee(function(r){var i=new T,o=new I;return o.setDisposable(i),i.setDisposable(t.subscribe(r.onNext.bind(r),function(t){var i,s;try{s=n(t)}catch(u){return r.onError(u),e}i=new T,o.setDisposable(i),i.setDisposable(s.subscribe(r))},r.onCompleted.bind(r))),o})}function b(t,n){var r=this;return new Ee(function(i){var o=0,s=t.length;return r.subscribe(function(r){if(s>o){var u,c=t[o++];try{u=n(r,c)}catch(a){return i.onError(a),e}i.onNext(u)}else i.onCompleted()},i.onError.bind(i),i.onCompleted.bind(i))})}function v(t){return this.select(t).mergeObservable()}var m="object"==typeof exports&&exports&&("object"==typeof global&&global&&global==global.global&&(t=global),exports),y={Internals:{}},w="Sequence contains no elements.",g="Argument out of range",E="Object has been disposed",x=Array.prototype.slice;({}).hasOwnProperty;var C=this.inherits=y.Internals.inherits=function(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n},D=y.Internals.addProperties=function(t){for(var e=x.call(arguments,1),n=0,r=e.length;r>n;n++){var i=e[n];for(var o in i)t[o]=i[o]}},A=y.Internals.addRef=function(t,e){return new Ee(function(n){return new R(e.getDisposable(),t.subscribe(n))})},_=function(t,e){this.id=t,this.value=e};_.prototype.compareTo=function(t){var e=this.value.compareTo(t.value);return 0===e&&(e=this.id-t.id),e};var S=function(t){this.items=Array(t),this.length=0},N=S.prototype;N.isHigherPriority=function(t,e){return 0>this.items[t].compareTo(this.items[e])},N.percolate=function(t){if(!(t>=this.length||0>t)){var e=t-1>>1;if(!(0>e||e===t)&&this.isHigherPriority(t,e)){var n=this.items[t];this.items[t]=this.items[e],this.items[e]=n,this.percolate(e)}}},N.heapify=function(t){if(t===e&&(t=0),!(t>=this.length||0>t)){var n=2*t+1,r=2*t+2,i=t;if(this.length>n&&this.isHigherPriority(n,i)&&(i=n),this.length>r&&this.isHigherPriority(r,i)&&(i=r),i!==t){var o=this.items[t];this.items[t]=this.items[i],this.items[i]=o,this.heapify(i)}}},N.peek=function(){return this.items[0].value},N.removeAt=function(t){this.items[t]=this.items[--this.length],delete this.items[this.length],this.heapify()},N.dequeue=function(){var t=this.peek();return this.removeAt(0),t},N.enqueue=function(t){var e=this.length++;this.items[e]=new _(S.count++,t),this.percolate(e)},N.remove=function(t){for(var e=0;this.length>e;e++)if(this.items[e].value===t)return this.removeAt(e),!0;return!1},S.count=0;var R=y.CompositeDisposable=function(){this.disposables=h(arguments,0),this.isDisposed=!1,this.length=this.disposables.length},W=R.prototype;W.add=function(t){this.isDisposed?t.dispose():(this.disposables.push(t),this.length++)},W.remove=function(t){var e=!1;if(!this.isDisposed){var n=this.disposables.indexOf(t);-1!==n&&(e=!0,this.disposables.splice(n,1),this.length--,t.dispose())}return e},W.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var t=this.disposables.slice(0);this.disposables=[],this.length=0;for(var e=0,n=t.length;n>e;e++)t[e].dispose()}},W.clear=function(){var t=this.disposables.slice(0);this.disposables=[],this.length=0;for(var e=0,n=t.length;n>e;e++)t[e].dispose()},W.contains=function(t){return-1!==this.disposables.indexOf(t)},W.toArray=function(){return this.disposables.slice(0)};var k=y.Disposable=function(t){this.isDisposed=!1,this.action=t};k.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var O=k.create=function(t){return new k(t)},q=k.empty={dispose:n},T=y.SingleAssignmentDisposable=function(){this.isDisposed=!1,this.current=null},j=T.prototype;j.disposable=function(t){return t?this.setDisposable(t):this.getDisposable()},j.getDisposable=function(){return this.current},j.setDisposable=function(t){if(this.current)throw Error("Disposable has already been assigned");var e=this.isDisposed;e||(this.current=t),e&&t&&t.dispose()},j.dispose=function(){var t;this.isDisposed||(this.isDisposed=!0,t=this.current,this.current=null),t&&t.dispose()};var I=y.SerialDisposable=function(){this.isDisposed=!1,this.current=null};I.prototype.getDisposable=function(){return this.current},I.prototype.setDisposable=function(t){var e,n=this.isDisposed;n||(e=this.current,this.current=t),e&&e.dispose(),n&&t&&t.dispose()},I.prototype.disposable=function(t){return t?(this.setDisposable(t),e):this.getDisposable()},I.prototype.dispose=function(){var t;this.isDisposed||(this.isDisposed=!0,t=this.current,this.current=null),t&&t.dispose()};var P=y.RefCountDisposable=function(){function t(t){this.disposable=t,this.disposable.count++,this.isInnerDisposed=!1}function e(t){this.underlyingDisposable=t,this.isDisposed=!1,this.isPrimaryDisposed=!1,this.count=0}return t.prototype.dispose=function(){this.disposable.isDisposed||this.isInnerDisposed||(this.isInnerDisposed=!0,this.disposable.count--,0===this.disposable.count&&this.disposable.isPrimaryDisposed&&(this.disposable.isDisposed=!0,this.disposable.underlyingDisposable.dispose()))},e.prototype.dispose=function(){this.isDisposed||this.isPrimaryDisposed||(this.isPrimaryDisposed=!0,0===this.count&&(this.isDisposed=!0,this.underlyingDisposable.dispose()))},e.prototype.getDisposable=function(){return this.isDisposed?q:new t(this)},e}();f.prototype.dispose=function(){var t=this;this.scheduler.schedule(function(){t.isDisposed||(t.isDisposed=!0,t.disposable.dispose())})},p.prototype.invoke=function(){this.disposable.disposable(this.invokeCore())},p.prototype.compareTo=function(t){return this.comparer(this.dueTime,t.dueTime)},p.prototype.isCancelled=function(){return this.disposable.isDisposed},p.prototype.invokeCore=function(){return this.action(this.scheduler,this.state)};var z=y.Scheduler=function(){function e(t,e,n,r){this.now=t,this._schedule=e,this._scheduleRelative=n,this._scheduleAbsolute=r}function n(t,e){var n=e.first,r=e.second,i=new R,o=function(e){r(e,function(e){var n=!1,r=!1,s=t.scheduleWithState(e,function(t,e){return n?i.remove(s):r=!0,o(e),q});r||(i.add(s),n=!0)})};return o(n),i}function r(t,e,n){var r=e.first,i=e.second,o=new R,s=function(e){i(e,function(e,r){var i=!1,u=!1,c=t[n].call(t,e,r,function(t,e){return i?o.remove(c):u=!0,s(e),q});u||(o.add(c),i=!0)})};return s(r),o}function o(t,e){return e(),q}var s=e.prototype;return s.catchException=function(t){return new H(this,t)},s.schedulePeriodic=function(t,e){return this.schedulePeriodicWithState(null,t,function(){e()})},s.schedulePeriodicWithState=function(e,n,r){var i=e,o=t.setInterval(function(){i=r(i)},n);return O(function(){t.clearInterval(o)})},s.schedule=function(t){return this._schedule(t,o)},s.scheduleWithState=function(t,e){return this._schedule(t,e)},s.scheduleWithRelative=function(t,e){return this._scheduleRelative(e,t,o)},s.scheduleWithRelativeAndState=function(t,e,n){return this._scheduleRelative(t,e,n)},s.scheduleWithAbsolute=function(t,e){return this._scheduleAbsolute(e,t,o)},s.scheduleWithAbsoluteAndState=function(t,e,n){return this._scheduleAbsolute(t,e,n)},s.scheduleRecursive=function(t){return this.scheduleRecursiveWithState(t,function(t,e){t(function(){e(t)})})},s.scheduleRecursiveWithState=function(t,e){return this.scheduleWithState({first:t,second:e},function(t,e){return n(t,e)})},s.scheduleRecursiveWithRelative=function(t,e){return this.scheduleRecursiveWithRelativeAndState(e,t,function(t,e){t(function(n){e(t,n)})})},s.scheduleRecursiveWithRelativeAndState=function(t,e,n){return this._scheduleRelative({first:t,second:n},e,function(t,e){return r(t,e,"scheduleWithRelativeAndState")})},s.scheduleRecursiveWithAbsolute=function(t,e){return this.scheduleRecursiveWithAbsoluteAndState(e,t,function(t,e){t(function(n){e(t,n)})})},s.scheduleRecursiveWithAbsoluteAndState=function(t,e,n){return this._scheduleAbsolute({first:t,second:n},e,function(t,e){return r(t,e,"scheduleWithAbsoluteAndState")})},e.now=i,e.normalize=function(t){return 0>t&&(t=0),t},e}(),V="Scheduler is not allowed to block the thread",L=z.immediate=function(){function t(t,e){return e(this,t)}function e(t,e,n){if(e>0)throw Error(V);return n(this,t)}function n(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new z(i,t,e,n)}(),F=z.currentThread=function(){function t(){o=new S(4)}function e(t,e){return this.scheduleWithRelativeAndState(t,0,e)}function n(e,n,r){var i,s=this.now()+z.normalize(n),u=new p(this,e,r,s);if(o)o.enqueue(u);else{i=new t;try{o.enqueue(u),i.run()}catch(c){throw c}finally{i.dispose()}}return u.disposable}function r(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}var o;t.prototype.dispose=function(){o=null},t.prototype.run=function(){for(var t;o.length>0;)if(t=o.dequeue(),!t.isCancelled()){for(;t.dueTime-z.now()>0;);t.isCancelled()||t.invoke()}};var s=new z(i,e,n,r);return s.scheduleRequired=function(){return null===o},s.ensureTrampoline=function(t){return null===o?this.schedule(t):t()},s}(),M=function(){function t(t,e){e(0,this._period);try{this._state=this._action(this._state)}catch(n){throw this._cancel.dispose(),n}}function e(t,e,n,r){this._scheduler=t,this._state=e,this._period=n,this._action=r}return e.prototype.start=function(){var e=new T;return this._cancel=e,e.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,t.bind(this))),e},e}();y.VirtualTimeScheduler=function(t){function n(){return this.toDateTimeOffset(this.clock)}function r(t,e){return this.scheduleAbsoluteWithState(t,this.clock,e)}function i(t,e,n){return this.scheduleRelativeWithState(t,this.toRelative(e),n)}function o(t,e,n){return this.scheduleRelativeWithState(t,this.toRelative(e-this.now()),n)}function s(t,e){return e(),q}function u(e,s){this.clock=e,this.comparer=s,this.isEnabled=!1,this.queue=new S(1024),t.call(this,n,r,i,o)}C(u,t);var c=u.prototype;return c.schedulePeriodicWithState=function(t,e,n){var r=new M(this,t,e,n);return r.start()},c.scheduleRelativeWithState=function(t,e,n){var r=this.add(this.clock,e);return this.scheduleAbsoluteWithState(t,r,n)},c.scheduleRelative=function(t,e){return this.scheduleRelativeWithState(e,t,s)},c.start=function(){var t;if(!this.isEnabled){this.isEnabled=!0;do t=this.getNext(),null!==t?(this.comparer(t.dueTime,this.clock)>0&&(this.clock=t.dueTime),t.invoke()):this.isEnabled=!1;while(this.isEnabled)}},c.stop=function(){this.isEnabled=!1},c.advanceTo=function(t){var e,n=this.comparer(this.clock,t);if(this.comparer(this.clock,t)>0)throw Error(g);if(0!==n&&!this.isEnabled){this.isEnabled=!0;do e=this.getNext(),null!==e&&0>=this.comparer(e.dueTime,t)?(this.comparer(e.dueTime,this.clock)>0&&(this.clock=e.dueTime),e.invoke()):this.isEnabled=!1;while(this.isEnabled);this.clock=t}},c.advanceBy=function(t){var n=this.add(this.clock,t),r=this.comparer(this.clock,n);if(r>0)throw Error(g);return 0!==r?this.advanceTo(n):e},c.sleep=function(t){var e=this.add(this.clock,t);if(this.comparer(this.clock,e)>=0)throw Error(g);this.clock=e},c.getNext=function(){for(var t;this.queue.length>0;){if(t=this.queue.peek(),!t.isCancelled())return t;this.queue.dequeue()}return null},c.scheduleAbsolute=function(t,e){return this.scheduleAbsoluteWithState(e,t,s)},c.scheduleAbsoluteWithState=function(t,e,n){var r=this,i=function(t,e){return r.queue.remove(o),n(t,e)},o=new p(r,t,i,e,r.comparer);return r.queue.enqueue(o),o.disposable},u}(z),y.HistoricalScheduler=function(t){function e(e,n){var r=null==e?0:e,i=n||s;t.call(this,r,i)}C(e,t);var n=e.prototype;return n.add=function(t,e){return t+e},n.toDateTimeOffset=function(t){return new Date(t).getTime()},n.toRelative=function(t){return t},e}(y.VirtualTimeScheduler);var B=z.timeout=function(){function r(t,e){var n=this,r=new T,i=u(function(){r.setDisposable(e(n,t))});return new R(r,O(function(){c(i)}))}function o(e,n,r){var i=this,o=z.normalize(n);if(0===o)return i.scheduleWithState(e,r);var s=new T,u=t.setTimeout(function(){s.setDisposable(r(i,e))},o);return new R(s,O(function(){t.clearTimeout(u)}))}function s(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}var u,c,a="equestAnimationFrame",h="ancelAnimationFrame",l=t["r"+a]||t["webkitR"+a]||t["mozR"+a]||t["oR"+a]||t["msR"+a],f=t["c"+h]||t["webkitC"+h]||t["mozC"+h]||t["oC"+h]||t["msC"+h];return t.process!==e&&"function"==typeof t.process.nextTick?(u=t.process.nextTick,c=n):"function"==typeof t.setImmediate?(u=t.setImmediate,c=t.clearImmediate):"function"==typeof l?(u=l,c=f):(u=function(e){return t.setTimeout(e,0)},c=t.clearTimeout),new z(i,r,o,s)}(),H=function(t){function e(){return this._scheduler.now()}function n(t,e){return this._scheduler.scheduleWithState(t,this._wrap(e))}function r(t,e,n){return this._scheduler.scheduleWithRelativeAndState(t,e,this._wrap(n))}function i(t,e,n){return this._scheduler.scheduleWithAbsoluteAndState(t,e,this._wrap(n))}function o(o,s){this._scheduler=o,this._handler=s,this._recursiveOriginal=null,this._recursiveWrapper=null,t.call(this,e,n,r,i)}return C(o,t),o.prototype._clone=function(t){return new o(t,this._handler)},o.prototype._wrap=function(t){var e=this;return function(n,r){try{return t(e._getRecursiveWrapper(n),r)}catch(i){if(!e._handler(i))throw i;return q}}},o.prototype._getRecursiveWrapper=function(t){if(!this._recursiveOriginal!==t){this._recursiveOriginal=t;var e=this._clone(t);e._recursiveOriginal=t,e._recursiveWrapper=e,this._recursiveWrapper=e}return this._recursiveWrapper},o.prototype.schedulePeriodicWithState=function(t,e,n){var r=this,i=!1,o=new T;return o.setDisposable(this._scheduler.schedulePeriodicWithState(t,e,function(t){if(i)return null;try{return n(t)}catch(e){if(i=!0,!r._handler(e))throw e;return o.dispose(),null}})),o},o}(z),U=y.Notification=function(){function t(t,e){this.hasValue=null==e?!1:e,this.kind=t}var e=t.prototype;return e.accept=function(t,e,n){return 1===arguments.length&&"object"==typeof t?this._acceptObservable(t):this._accept(t,e,n)},e.toObservable=function(t){var e=this;return t=t||L,new Ee(function(n){return t.schedule(function(){e._acceptObservable(n),"N"===e.kind&&n.onCompleted()})})},e.equals=function(t){var e=null==t?"":""+t;return""+this===e},t}(),G=U.createOnNext=function(){function t(t){return t(this.value)}function e(t){return t.onNext(this.value)}function n(){return"OnNext("+this.value+")"}return function(r){var i=new U("N",!0);return i.value=r,i._accept=t.bind(i),i._acceptObservable=e.bind(i),i.toString=n.bind(i),i}}(),J=U.createOnError=function(){function t(t,e){return e(this.exception)}function e(t){return t.onError(this.exception)}function n(){return"OnError("+this.exception+")"}return function(r){var i=new U("E");return i.exception=r,i._accept=t.bind(i),i._acceptObservable=e.bind(i),i.toString=n.bind(i),i}}(),K=U.createOnCompleted=function(){function t(t,e,n){return n()}function e(t){return t.onCompleted()}function n(){return"OnCompleted()"}return function(){var r=new U("C");return r._accept=t.bind(r),r._acceptObservable=e.bind(r),r.toString=n.bind(r),r}}(),Q=y.Internals.Enumerator=function(t,e,n){this.moveNext=t,this.getCurrent=e,this.dispose=n},X=Q.create=function(t,e,r){var i=!1;return r||(r=n),new Q(function(){if(i)return!1;var e=t();return e||(i=!0,r()),e},function(){return e()},function(){i||(r(),i=!0)})},Y=y.Internals.Enumerable=function(){function t(t){this.getEnumerator=t}return t.prototype.concat=function(){var t=this;return new Ee(function(n){var r=t.getEnumerator(),i=!1,o=new I,s=L.scheduleRecursive(function(t){var s,u,c=!1;if(!i){try{c=r.moveNext(),c?s=r.getCurrent():r.dispose()}catch(a){u=a,r.dispose()}if(u)return n.onError(u),e;if(!c)return n.onCompleted(),e;var h=new T;o.setDisposable(h),h.setDisposable(s.subscribe(n.onNext.bind(n),n.onError.bind(n),function(){t()}))}});return new R(o,s,O(function(){i=!0,r.dispose()}))})},t.prototype.catchException=function(){var t=this;return new Ee(function(n){var r,i=t.getEnumerator(),o=!1,s=new I,u=L.scheduleRecursive(function(t){var u,c,a;if(a=!1,!o){try{a=i.moveNext(),a&&(u=i.getCurrent())}catch(h){c=h}if(c)return n.onError(c),e;if(!a)return r?n.onError(r):n.onCompleted(),e;var l=new T;s.setDisposable(l),l.setDisposable(u.subscribe(n.onNext.bind(n),function(e){r=e,t()},n.onCompleted.bind(n)))}});return new R(s,u,O(function(){o=!0}))})},t}(),Z=Y.repeat=function(t,n){return n===e&&(n=-1),new Y(function(){var e,r=n;return X(function(){return 0===r?!1:(r>0&&r--,e=t,!0)},function(){return e})})},$=Y.forEach=function(t,e){return e||(e=r),new Y(function(){var n,r=-1;return X(function(){return++r<t.length?(n=e(t[r],r),!0):!1},function(){return n})})},te=y.Observer=function(){};te.prototype.toNotifier=function(){var t=this;return function(e){return e.accept(t)}},te.prototype.asObserver=function(){return new ie(this.onNext.bind(this),this.onError.bind(this),this.onCompleted.bind(this))},te.prototype.checked=function(){return new oe(this)};var ee=te.create=function(t,e,r){return t||(t=n),e||(e=c),r||(r=n),new ie(t,e,r)};te.fromNotifier=function(t){return new ie(function(e){return t(G(e))},function(e){return t(J(e))},function(){return t(K())})};var ne,re=y.Internals.AbstractObserver=function(t){function e(){this.isStopped=!1,t.call(this)}return C(e,t),e.prototype.onNext=function(t){this.isStopped||this.next(t)},e.prototype.onError=function(t){this.isStopped||(this.isStopped=!0,this.error(t))},e.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.completed())},e.prototype.dispose=function(){this.isStopped=!0},e.prototype.fail=function(){return this.isStopped?!1:(this.isStopped=!0,this.error(!0),!0)},e}(te),ie=y.AnonymousObserver=function(t){function e(e,n,r){t.call(this),this._onNext=e,this._onError=n,this._onCompleted=r}return C(e,t),e.prototype.next=function(t){this._onNext(t)},e.prototype.error=function(t){this._onError(t)},e.prototype.completed=function(){this._onCompleted()},e}(re),oe=function(t){function e(e){t.call(this),this._observer=e,this._state=0}C(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}(te),se=y.Internals.ScheduledObserver=function(t){function n(e,n){t.call(this),this.scheduler=e,this.observer=n,this.isAcquired=!1,this.hasFaulted=!1,this.queue=[],this.disposable=new I}return C(n,t),n.prototype.next=function(t){var e=this;this.queue.push(function(){e.observer.onNext(t)})},n.prototype.error=function(t){var e=this;this.queue.push(function(){e.observer.onError(t)})},n.prototype.completed=function(){var t=this;this.queue.push(function(){t.observer.onCompleted()})},n.prototype.ensureActive=function(){var t=!1,n=this;!this.hasFaulted&&this.queue.length>0&&(t=!this.isAcquired,this.isAcquired=!0),t&&this.disposable.setDisposable(this.scheduler.scheduleRecursive(function(t){var r;if(!(n.queue.length>0))return n.isAcquired=!1,e;r=n.queue.shift();try{r()}catch(i){throw n.queue=[],n.hasFaulted=!0,i}t()}))},n.prototype.dispose=function(){t.prototype.dispose.call(this),this.disposable.dispose()},n}(re),ue=function(t){function e(){t.apply(this,arguments)}return C(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}(se),ce=y.Observable=function(){function t(t){this._subscribe=t}return ne=t.prototype,ne.finalValue=function(){var t=this;return new Ee(function(e){var n,r=!1;return t.subscribe(function(t){r=!0,n=t},e.onError.bind(e),function(){r?(e.onNext(n),e.onCompleted()):e.onError(Error(w))})})},ne.subscribe=ne.forEach=function(t,e,n){var r;return r="object"==typeof t?t:ee(t,e,n),this._subscribe(r)},ne.toArray=function(){function t(t,e){var n=t.slice(0);return n.push(e),n}return this.scan([],t).startWith([]).finalValue()},t}();ce.start=function(t,e){return ae(t,e)()};var ae=ce.toAsync=function(t,n,r){return n||(n=B),function(){var i=x.call(arguments,0),o=new _e;return n.schedule(function(){var n;try{n=t.apply(r,i)}catch(s){return o.onError(s),e}o.onNext(n),o.onCompleted()}),o.asObservable()}};ne.observeOn=function(t){var e=this;return new Ee(function(n){return e.subscribe(new ue(t,n))})},ne.subscribeOn=function(t){var e=this;return new Ee(function(n){var r=new T,i=new I;return i.setDisposable(r),r.setDisposable(t.schedule(function(){i.setDisposable(new f(t,e.subscribe(n)))})),i})},ce.create=function(t){return new Ee(function(e){return O(t(e))})},ce.createWithDisposable=function(t){return new Ee(t)};var he=ce.defer=function(t){return new Ee(function(e){var n;try{n=t()}catch(r){return be(r).subscribe(e)}return n.subscribe(e)})},le=ce.empty=function(t){return t||(t=L),new Ee(function(e){return t.schedule(function(){e.onCompleted()})})},fe=ce.fromArray=function(t,e){return e||(e=F),new Ee(function(n){var r=0;return e.scheduleRecursive(function(e){t.length>r?(n.onNext(t[r++]),e()):n.onCompleted()})})};ce.generate=function(t,n,r,i,o){return o||(o=F),new Ee(function(s){var u=!0,c=t;return o.scheduleRecursive(function(t){var o,a;try{u?u=!1:c=r(c),o=n(c),o&&(a=i(c))}catch(h){return s.onError(h),e}o?(s.onNext(a),t()):s.onCompleted()})})};var pe=ce.never=function(){return new Ee(function(){return q})};ce.range=function(t,e,n){return n||(n=F),new Ee(function(r){return n.scheduleRecursiveWithState(0,function(n,i){e>n?(r.onNext(t+n),i(n+1)):r.onCompleted()})})},ce.repeat=function(t,n,r){return r||(r=F),n==e&&(n=-1),de(t,r).repeat(n)};var de=ce.returnValue=function(t,e){return e||(e=L),new Ee(function(n){return e.schedule(function(){n.onNext(t),n.onCompleted()})})},be=ce.throwException=function(t,e){return e||(e=L),new Ee(function(n){return e.schedule(function(){n.onError(t)})})};ce.using=function(t,e){return new Ee(function(n){var r,i,o=q;try{r=t(),r&&(o=r),i=e(r)}catch(s){return new R(be(s).subscribe(n),o)}return new R(i.subscribe(n),o)})},ne.amb=function(t){var e=this;return new Ee(function(n){function r(){o||(o=s,a.dispose())}function i(){o||(o=u,c.dispose())}var o,s="L",u="R",c=new T,a=new T;return 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 R(c,a)})},ce.amb=function(){function t(t,e){return t.amb(e)}for(var e=pe(),n=h(arguments,0),r=0,i=n.length;i>r;r++)e=t(e,n[r]);return e},ne.catchException=function(t){return"function"==typeof t?d(this,t):ve([this,t])};var ve=ce.catchException=function(){var t=h(arguments,0);return $(t).catchException()};ne.combineLatest=function(){var t=x.call(arguments);return Array.isArray(t[0])?t[0].unshift(this):t.unshift(this),me.apply(this,t)};var me=ce.combineLatest=function(){var t=x.call(arguments),n=t.pop();return Array.isArray(t[0])&&(t=t[0]),new Ee(function(r){function i(t){var i;if(c[t]=!0,a||(a=c.every(function(t){return t}))){try{i=n.apply(null,f)}catch(o){return r.onError(o),e}r.onNext(i)}else h.filter(function(e,n){return n!==t}).every(function(t){return t})&&r.onCompleted()}function o(t){h[t]=!0,h.every(function(t){return t})&&r.onCompleted()}for(var s=function(){return!1},u=t.length,c=l(u,s),a=!1,h=l(u,s),f=Array(u),p=Array(u),d=0;u>d;d++)(function(e){p[e]=new T,p[e].setDisposable(t[e].subscribe(function(t){f[e]=t,i(e)},r.onError.bind(r),function(){o(e)}))})(d);return new R(p)})};ne.concat=function(){var t=x.call(arguments,0);return t.unshift(this),ye.apply(this,t)};var ye=ce.concat=function(){var t=h(arguments,0);return $(t).concat()};ne.concatObservable=ne.concatAll=function(){return this.merge(1)},ne.merge=function(t){if("number"!=typeof t)return we(this,t);var e=this;return new Ee(function(n){var r=0,i=new R,o=!1,s=[],u=function(t){var e=new T;i.add(e),e.setDisposable(t.subscribe(n.onNext.bind(n),n.onError.bind(n),function(){var t;i.remove(e),s.length>0?(t=s.shift(),u(t)):(r--,o&&0===r&&n.onCompleted())}))};return i.add(e.subscribe(function(e){t>r?(r++,u(e)):s.push(e)},n.onError.bind(n),function(){o=!0,0===r&&n.onCompleted()})),i})};var we=ce.merge=function(){var t,e;return arguments[0]?arguments[0].now?(t=arguments[0],e=x.call(arguments,1)):(t=L,e=x.call(arguments,0)):(t=L,e=x.call(arguments,1)),Array.isArray(e[0])&&(e=e[0]),fe(e,t).mergeObservable()};ne.mergeObservable=ne.mergeAll=function(){var t=this;return new Ee(function(e){var n=new R,r=!1,i=new T;return n.add(i),i.setDisposable(t.subscribe(function(t){var i=new T;n.add(i),i.setDisposable(t.subscribe(function(t){e.onNext(t)},e.onError.bind(e),function(){n.remove(i),r&&1===n.length&&e.onCompleted()}))},e.onError.bind(e),function(){r=!0,1===n.length&&e.onCompleted()})),n})},ne.onErrorResumeNext=function(t){if(!t)throw Error("Second observable is required");return ge([this,t])};var ge=ce.onErrorResumeNext=function(){var t=h(arguments,0);return new Ee(function(e){var n=0,r=new I,i=L.scheduleRecursive(function(i){var o,s;t.length>n?(o=t[n++],s=new T,r.setDisposable(s),s.setDisposable(o.subscribe(e.onNext.bind(e),function(){i()},function(){i()}))):e.onCompleted()});return new R(r,i)})};ne.skipUntil=function(t){var e=this;return new Ee(function(n){var r=!1,i=new R(e.subscribe(function(t){r&&n.onNext(t)},n.onError.bind(n),function(){r&&n.onCompleted()})),o=new T;return i.add(o),o.setDisposable(t.subscribe(function(){r=!0,o.dispose()},n.onError.bind(n),function(){o.dispose()})),i})},ne.switchLatest=function(){var t=this;return new Ee(function(e){var n=!1,r=new I,i=!1,o=0,s=t.subscribe(function(t){var s=new T,u=++o;n=!0,r.setDisposable(s),s.setDisposable(t.subscribe(function(t){o===u&&e.onNext(t)},function(t){o===u&&e.onError(t)},function(){o===u&&(n=!1,i&&e.onCompleted())}))},e.onError.bind(e),function(){i=!0,n||e.onCompleted()});return new R(s,r)})},ne.takeUntil=function(t){var e=this;return new Ee(function(r){return new R(e.subscribe(r),t.subscribe(r.onCompleted.bind(r),r.onError.bind(r),n))})},ne.zip=function(){if(Array.isArray(arguments[0]))return b.apply(this,arguments);var t=this,n=x.call(arguments),r=n.pop();return n.unshift(t),new Ee(function(i){function o(t){c[t]=!0,c.every(function(t){return t})&&i.onCompleted()}for(var s=n.length,u=l(s,function(){return[]}),c=l(s,function(){return!1}),a=function(n){var o,s;if(u.every(function(t){return t.length>0})){try{s=u.map(function(t){return t.shift()}),o=r.apply(t,s)}catch(a){return i.onError(a),e}i.onNext(o)}else c.filter(function(t,e){return e!==n}).every(function(t){return t})&&i.onCompleted()},h=Array(s),f=0;s>f;f++)(function(t){h[t]=new T,h[t].setDisposable(n[t].subscribe(function(e){u[t].push(e),a(t)},i.onError.bind(i),function(){o(t)}))})(f);return new R(h)})},ce.zip=function(t,e){var n=t[0],r=t.slice(1);return r.push(e),n.zip.apply(n,r)},ne.asObservable=function(){var t=this;return new Ee(function(e){return t.subscribe(e)})},ne.bufferWithCount=function(t,n){return n===e&&(n=t),this.windowWithCount(t,n).selectMany(function(t){return t.toArray()}).where(function(t){return t.length>0})},ne.dematerialize=function(){var t=this;return new Ee(function(e){return t.subscribe(function(t){return t.accept(e)},e.onError.bind(e),e.onCompleted.bind(e))})},ne.distinctUntilChanged=function(t,n){var i=this;return t||(t=r),n||(n=o),new Ee(function(r){var o,s=!1;return i.subscribe(function(i){var u,c=!1;try{u=t(i)}catch(a){return r.onError(a),e}if(s)try{c=n(o,u)}catch(a){return r.onError(a),e}s&&c||(s=!0,o=u,r.onNext(i))},r.onError.bind(r),r.onCompleted.bind(r))})},ne.doAction=function(t,e,n){var r,i=this;return"function"==typeof t?r=t:(r=t.onNext.bind(t),e=t.onError.bind(t),n=t.onCompleted.bind(t)),new Ee(function(t){return i.subscribe(function(e){try{r(e)}catch(n){t.onError(n)}t.onNext(e)},function(n){if(e){try{e(n)}catch(r){t.onError(r)}t.onError(n)}else t.onError(n)},function(){if(n){try{n()}catch(e){t.onError(e)}t.onCompleted()}else t.onCompleted()})})},ne.finallyAction=function(t){var e=this;return new Ee(function(n){var r=e.subscribe(n);return O(function(){try{r.dispose()}catch(e){throw e}finally{t()}})})},ne.ignoreElements=function(){var t=this;return new Ee(function(e){return t.subscribe(n,e.onError.bind(e),e.onCompleted.bind(e))})},ne.materialize=function(){var t=this;return new Ee(function(e){return t.subscribe(function(t){e.onNext(G(t))},function(t){e.onNext(J(t)),e.onCompleted()},function(){e.onNext(K()),e.onCompleted()})})},ne.repeat=function(t){return Z(this,t).concat()},ne.retry=function(t){return Z(this,t).catchException()},ne.scan=function(){var t,e,n=!1;2===arguments.length?(t=arguments[0],e=arguments[1],n=!0):e=arguments[0];var r=this;return he(function(){var i,o=!1;return r.select(function(r){return o?i=e(i,r):(i=n?e(t,r):r,o=!0),i})})},ne.skipLast=function(t){var e=this;return new Ee(function(n){var r=[];return e.subscribe(function(e){r.push(e),r.length>t&&n.onNext(r.shift())},n.onError.bind(n),n.onCompleted.bind(n))})},ne.startWith=function(){var t,n,r=0;return arguments.length>0&&null!=arguments[0]&&arguments[0].now!==e?(n=arguments[0],r=1):n=L,t=x.call(arguments,r),$([fe(t,n),this]).concat()},ne.takeLast=function(t,e){return this.takeLastBuffer(t).selectMany(function(t){return fe(t,e)})},ne.takeLastBuffer=function(t){var e=this;return new Ee(function(n){var r=[];return e.subscribe(function(e){r.push(e),r.length>t&&r.shift()},n.onError.bind(n),function(){n.onNext(r),n.onCompleted()})})},ne.windowWithCount=function(t,e){var n=this;if(0>=t)throw Error(g);if(null==e&&(e=t),0>=e)throw Error(g);return new Ee(function(r){var i=new T,o=new P(i),s=0,u=[],c=function(){var t=new Ae;u.push(t),r.onNext(A(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})},ne.defaultIfEmpty=function(t){var n=this;return t===e&&(t=null),new Ee(function(e){var r=!1;return n.subscribe(function(t){r=!0,e.onNext(t)},e.onError.bind(e),function(){r||e.onNext(t),e.onCompleted()})})},ne.distinct=function(t,n){var i=this;return t||(t=r),n||(n=u),new Ee(function(r){var o={};return i.subscribe(function(i){var s,u,c,a=!1;try{s=t(i),u=n(s)}catch(h){return r.onError(h),e}for(c in o)if(u===c){a=!0;break}a||(o[u]=null,r.onNext(i))},r.onError.bind(r),r.onCompleted.bind(r))})},ne.groupBy=function(t,e,n){return this.groupByUntil(t,e,function(){return pe()},n)},ne.groupByUntil=function(t,i,o,s){var c=this;return i||(i=r),s||(s=u),new Ee(function(r){var u={},a=new R,h=new P(a);return a.add(c.subscribe(function(c){var l,f,p,d,b,v,m,y,w,g,E;try{m=t(c),y=s(m)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}b=!1;try{g=u[y],g||(g=new Ae,u[y]=g,b=!0)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}if(b){v=new Ce(m,g,h),f=new Ce(m,g);try{l=o(f)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}r.onNext(v),w=new T,a.add(w),d=function(){y in u&&(delete u[y],g.onCompleted()),a.remove(w)},w.setDisposable(l.take(1).subscribe(n,function(t){for(E in u)u[E].onError(t);r.onError(t)},function(){d()}))}try{p=i(c)}catch(x){for(E in u)u[E].onError(x);return r.onError(x),e}g.onNext(p)},function(t){for(var e in u)u[e].onError(t);
+r.onError(t)},function(){for(var t in u)u[t].onCompleted();r.onCompleted()})),h})},ne.select=ne.map=function(t){var n=this;return new Ee(function(r){var i=0;return n.subscribe(function(n){var o;try{o=t(n,i++)}catch(s){return r.onError(s),e}r.onNext(o)},r.onError.bind(r),r.onCompleted.bind(r))})},ne.selectMany=ne.flatMap=function(t,e){return e?this.selectMany(function(n){return t(n).select(function(t){return e(n,t)})}):"function"==typeof t?v.call(this,t):v.call(this,function(){return t})},ne.skip=function(t){if(0>t)throw Error(g);var e=this;return new Ee(function(n){var r=t;return e.subscribe(function(t){0>=r?n.onNext(t):r--},n.onError.bind(n),n.onCompleted.bind(n))})},ne.skipWhile=function(t){var n=this;return new Ee(function(r){var i=0,o=!1;return n.subscribe(function(n){if(!o)try{o=!t(n,i++)}catch(s){return r.onError(s),e}o&&r.onNext(n)},r.onError.bind(r),r.onCompleted.bind(r))})},ne.take=function(t,e){if(0>t)throw Error(g);if(0===t)return le(e);var n=this;return new Ee(function(e){var r=t;return n.subscribe(function(t){r>0&&(r--,e.onNext(t),0===r&&e.onCompleted())},e.onError.bind(e),e.onCompleted.bind(e))})},ne.takeWhile=function(t){var n=this;return new Ee(function(r){var i=0,o=!0;return n.subscribe(function(n){if(o){try{o=t(n,i++)}catch(s){return r.onError(s),e}o?r.onNext(n):r.onCompleted()}},r.onError.bind(r),r.onCompleted.bind(r))})},ne.where=ne.filter=function(t){var n=this;return new Ee(function(r){var i=0;return n.subscribe(function(n){var o;try{o=t(n,i++)}catch(s){return r.onError(s),e}o&&r.onNext(n)},r.onError.bind(r),r.onCompleted.bind(r))})};var Ee=y.Internals.AnonymousObservable=function(t){function e(e){function n(t){var n=new xe(t);if(F.scheduleRequired())F.schedule(function(){try{n.disposable(e(n))}catch(t){if(!n.fail(t))throw t}});else try{n.disposable(e(n))}catch(r){if(!n.fail(r))throw r}return n}t.call(this,n)}return C(e,t),e}(ce),xe=function(t){function e(e){t.call(this),this.observer=e,this.m=new T}C(e,t);var n=e.prototype;return n.next=function(t){var e=!1;try{this.observer.onNext(t),e=!0}catch(n){throw n}finally{e||this.dispose()}},n.error=function(t){try{this.observer.onError(t)}catch(e){throw e}finally{this.dispose()}},n.completed=function(){try{this.observer.onCompleted()}catch(t){throw t}finally{this.dispose()}},n.disposable=function(t){return this.m.disposable(t)},n.dispose=function(){t.prototype.dispose.call(this),this.m.dispose()},e}(re),Ce=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 Ee(function(t){return new R(i.getDisposable(),r.subscribe(t))}):r}return C(n,t),n}(ce),De=function(t,e){this.subject=t,this.observer=e};De.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var t=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(t,1),this.observer=null}};var Ae=y.Subject=function(t){function e(t){return a.call(this),this.isStopped?this.exception?(t.onError(this.exception),q):(t.onCompleted(),q):(this.observers.push(t),new De(this,t))}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.observers=[]}return C(n,t),D(n.prototype,te,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(a.call(this),!this.isStopped){var t=this.observers.slice(0);this.isStopped=!0;for(var e=0,n=t.length;n>e;e++)t[e].onCompleted();this.observers=[]}},onError:function(t){if(a.call(this),!this.isStopped){var e=this.observers.slice(0);this.isStopped=!0,this.exception=t;for(var n=0,r=e.length;r>n;n++)e[n].onError(t);this.observers=[]}},onNext:function(t){if(a.call(this),!this.isStopped)for(var e=this.observers.slice(0),n=0,r=e.length;r>n;n++)e[n].onNext(t)},dispose:function(){this.isDisposed=!0,this.observers=null}}),n.create=function(t,e){return new Se(t,e)},n}(ce),_e=y.AsyncSubject=function(t){function e(t){if(a.call(this),!this.isStopped)return this.observers.push(t),new De(this,t);var e=this.exception,n=this.hasValue,r=this.value;return e?t.onError(e):n?(t.onNext(r),t.onCompleted()):t.onCompleted(),q}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.value=null,this.hasValue=!1,this.observers=[],this.exception=null}return C(n,t),D(n.prototype,te,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){var t,e,n;if(a.call(this),!this.isStopped){var r=this.observers.slice(0);this.isStopped=!0;var i=this.value,o=this.hasValue;if(o)for(e=0,n=r.length;n>e;e++)t=r[e],t.onNext(i),t.onCompleted();else for(e=0,n=r.length;n>e;e++)r[e].onCompleted();this.observers=[]}},onError:function(t){if(a.call(this),!this.isStopped){var e=this.observers.slice(0);this.isStopped=!0,this.exception=t;for(var n=0,r=e.length;r>n;n++)e[n].onError(t);this.observers=[]}},onNext:function(t){a.call(this),this.isStopped||(this.value=t,this.hasValue=!0)},dispose:function(){this.isDisposed=!0,this.observers=null,this.exception=null,this.value=null}}),n}(ce),Se=function(t){function e(t){return this.observable.subscribe(t)}function n(n,r){t.call(this,e),this.observer=n,this.observable=r}return C(n,t),D(n.prototype,te,{onCompleted:function(){this.observer.onCompleted()},onError:function(t){this.observer.onError(t)},onNext:function(t){this.observer.onNext(t)}}),n}(ce);return"function"==typeof define&&"object"==typeof define.amd&&define.amd?(t.Rx=y,define(function(){return y})):(m?"object"==typeof module&&module&&module.exports==m?module.exports=y:m=y:t.Rx=y,e)})(this);
View
135 rx.testing.js
@@ -44,10 +44,18 @@
slice.call(args);
}
- // New predicate tests
+ /**
+ * @private
+ * @constructor
+ */
function OnNextPredicate(predicate) {
this.predicate = predicate;
};
+
+ /**
+ * @private
+ * @memberOf OnNextPredicate#
+ */
OnNextPredicate.prototype.equals = function (other) {
if (other === this) { return true; }
if (other == null) { return false; }
@@ -55,9 +63,18 @@
return this.predicate(other.value);
};
+ /**
+ * @private
+ * @constructor
+ */
function OnErrorPredicate(predicate) {
this.predicate = predicate;
};
+
+ /**
+ * @private
+ * @memberOf OnErrorPredicate#
+ */
OnErrorPredicate.prototype.equals = function (other) {
if (other === this) { return true; }
if (other == null) { return false; }
@@ -65,6 +82,10 @@
return this.predicate(other.exception);
};
+ /**
+ * @static
+ * type Object
+ */
var ReactiveTest = root.ReactiveTest = {
/** Default virtual time used for creation of observable sequences in unit tests. */
created: 100,
@@ -127,12 +148,12 @@
};
/**
- * @constructor
* Creates a new object recording the production of the specified value at the given virtual time.
- *
- * @param time Virtual time the value was produced on.
- * @param value Value that was produced.
- * @param comparer An optional comparer.
+ *
+ * @constructor
+ * @param {Number} time Virtual time the value was produced on.
+ * @param {Mixed} value Value that was produced.
+ * @param {Function} comparer An optional comparer.
*/
var Recorded = root.Recorded = function (time, value, comparer) {
this.time = time;
@@ -142,8 +163,9 @@
/**
* Checks whether the given recorded object is equal to the current instance.
- * @param other Recorded object to check for equality.
- * @return true if both objects are equal; false otherwise.
+ *
+ * @param {Recorded} other Recorded object to check for equality.
+ * @returns {Boolean} true if both objects are equal; false otherwise.
*/
Recorded.prototype.equals = function (other) {
return this.time === other.time && this.comparer(this.value, other.value);
@@ -151,17 +173,19 @@
/**
* Returns a string representation of the current Recorded value.
- * @return String representation of the current Recorded value.
+ *
+ * @returns {String} String representation of the current Recorded value.
*/
Recorded.prototype.toString = function () {
return this.value.toString() + '@' + this.time;
};
/**
- * @constructor
* Creates a new subscription object with the given virtual subscription and unsubscription time.
- * @param subscribe Virtual time at which the subscription occurred.
- * @param unsubscribe Virtual time at which the unsubscription occurred.
+ *
+ * @constructor
+ * @param {Number} subscribe Virtual time at which the subscription occurred.
+ * @param {Number} unsubscribe Virtual time at which the unsubscription occurred.
*/
var Subscription = root.Subscription = function (start, end) {
this.subscribe = start;
@@ -171,7 +195,7 @@
/**
* Checks whether the given subscription is equal to the current instance.
* @param other Subscription object to check for equality.
- * @return true if both objects are equal; false otherwise.
+ * @returns {Boolean} true if both objects are equal; false otherwise.
*/
Subscription.prototype.equals = function (other) {
return this.subscribe === other.subscribe && this.unsubscribe === other.unsubscribe;
@@ -179,40 +203,73 @@
/**
* Returns a string representation of the current Subscription value.
- * @return String representation of the current Subscription value.
+ * @returns {String} String representation of the current Subscription value.
*/
Subscription.prototype.toString = function () {
return '(' + this.subscribe + ', ' + this.unsubscribe === Number.MAX_VALUE ? 'Infinite' : this.unsubscribe + ')';
};
+ /** @private */
var MockDisposable = root.MockDisposable = function (scheduler) {
this.scheduler = scheduler;
this.disposes = [];
this.disposes.push(this.scheduler.clock);
};
+
+ /*
+ * @memberOf MockDisposable#
+ * @prviate
+ */
MockDisposable.prototype.dispose = function () {
this.disposes.push(this.scheduler.clock);
};
- var MockObserver = (function () {
- inherits(MockObserver, Observer);
+ /** @private */
+ var MockObserver = (function (_super) {
+ inherits(MockObserver, _super);
+
+ /*
+ * @constructor
+ * @prviate
+ */
function MockObserver(scheduler) {
+ _super.call(this);
this.scheduler = scheduler;
this.messages = [];
}
- MockObserver.prototype.onNext = function (value) {
+
+ var MockObserverPrototype = MockObserver.prototype;
+
+ /*
+ * @memberOf MockObserverPrototype#
+ * @prviate
+ */
+ MockObserverPrototype.onNext = function (value) {
this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnNext(value)));
};
- MockObserver.prototype.onError = function (exception) {
+
+ /*
+ * @memberOf MockObserverPrototype#
+ * @prviate
+ */
+ MockObserverPrototype.onError = function (exception) {
this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnError(exception)));
};
- MockObserver.prototype.onCompleted = function () {
+
+ /*
+ * @memberOf MockObserverPrototype#
+ * @prviate
+ */
+ MockObserverPrototype.onCompleted = function () {
this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnCompleted()));
};
+
return MockObserver;
- })();
+ })(Observer);
+
+ /** @private */
+ var HotObservable = (function (_super) {
- var HotObservable = (function () {
function subscribe(observer) {
var observable = this;
this.observers.push(observer);
@@ -225,9 +282,14 @@
});
}
- inherits(HotObservable, Observable);
+ inherits(HotObservable, _super);
+
+ /**
+ * @private
+ * @constructor
+ */
function HotObservable(scheduler, messages) {
- HotObservable.super_.constructor.call(this, subscribe);
+ _super.call(this, subscribe);
var message, notification, observable = this;
this.scheduler = scheduler;
this.messages = messages;
@@ -248,9 +310,11 @@
}
return HotObservable;
- })();
+ })(Observable);
+
+ /** @private */
+ var ColdObservable = (function (_super) {
- var ColdObservable = (function () {
function subscribe(observer) {
var message, notification, observable = this;
this.subscriptions.push(new Subscription(this.scheduler.clock));
@@ -272,24 +336,29 @@
});
}
- inherits(ColdObservable, Observable);
+ inherits(ColdObservable, _super);
+
+ /**
+ * @private
+ * @constructor
+ */
function ColdObservable(scheduler, messages) {
- ColdObservable.super_.constructor.call(this, subscribe);
+ _super.call(this, subscribe);
this.scheduler = scheduler;
this.messages = messages;
this.subscriptions = [];
}
return ColdObservable;
- })();
+ })(Observable);
/** Virtual time scheduler used for testing applications and libraries built using Reactive Extensions. */
- root.TestScheduler = (function () {
- inherits(TestScheduler, VirtualTimeScheduler);
+ root.TestScheduler = (function (_super) {
+ inherits(TestScheduler, _super);
/** @constructor */
function TestScheduler() {
- TestScheduler.super_.constructor.call(this, 0, function (a, b) { return a - b; });
+ _super.call(this, 0, function (a, b) { return a - b; });
}
/**
@@ -304,7 +373,7 @@
if (dueTime <= this.clock) {
dueTime = this.clock + 1;
}
- return TestScheduler.super_.scheduleAbsoluteWithState.call(this, state, dueTime, action);
+ return _super.prototype.scheduleAbsoluteWithState.call(this, state, dueTime, action);
};
/**
* Adds a relative virtual time to an absolute virtual time value.
@@ -410,7 +479,7 @@
};
return TestScheduler;
- })();
+ })(VirtualTimeScheduler);
return root;
}));
View
2  rx.testing.min.js
@@ -1 +1 @@
-(function(t,e){var n="object"==typeof exports&&exports&&("object"==typeof t&&t&&t==t.global&&(window=t),exports);"function"==typeof define&&define.amd?define(["rx","exports"],function(n,r){return t.Rx=e(t,r,n),t.Rx}):"object"==typeof module&&module&&module.exports==n?module.exports=e(t,module.exports,require("./rx")):t.Rx=e(t,{},t.Rx)})(this,function(t,e,n){function r(t,e){return e.equals?e.equals(t):t===e}function i(t,e){return 1===t.length&&Array.isArray(t[e])?t[e]:b.call(t)}function o(t){this.predicate=t}function s(t){this.predicate=t}var u=n.Observer,c=n.Observable,h=n.Notification,a=n.VirtualTimeScheduler,l=n.Disposable,f=l.empty,p=l.create,d=n.CompositeDisposable,b=(n.SingleAssignmentDisposable,Array.prototype.slice),v=n.Internals.inherits;o.prototype.equals=function(t){return t===this?!0:null==t?!1:"N"!==t.kind?!1:this.predicate(t.value)},s.prototype.equals=function(t){return t===this?!0:null==t?!1:"E"!==t.kind?!1:this.predicate(t.exception)};var m=n.ReactiveTest={created:100,subscribed:200,disposed:1e3,onNext:function(t,e){return"function"==typeof e?new y(t,new o(e)):new y(t,h.createOnNext(e))},onError:function(t,e){return"function"==typeof e?new y(t,new s(e)):new y(t,h.createOnError(e))},onCompleted:function(t){return new y(t,h.createOnCompleted())},subscribe:function(t,e){return new w(t,e)}},y=n.Recorded=function(t,e,n){this.time=t,this.value=e,this.comparer=n||r};y.prototype.equals=function(t){return this.time===t.time&&this.comparer(this.value,t.value)},y.prototype.toString=function(){return""+this.value+"@"+this.time};var w=n.Subscription=function(t,e){this.subscribe=t,this.unsubscribe=e||Number.MAX_VALUE};w.prototype.equals=function(t){return this.subscribe===t.subscribe&&this.unsubscribe===t.unsubscribe},w.prototype.toString=function(){return"("+this.subscribe+", "+this.unsubscribe===Number.MAX_VALUE?"Infinite":this.unsubscribe+")"};var g=n.MockDisposable=function(t){this.scheduler=t,this.disposes=[],this.disposes.push(this.scheduler.clock)};g.prototype.dispose=function(){this.disposes.push(this.scheduler.clock)};var x=function(){function t(t){this.scheduler=t,this.messages=[]}return v(t,u),t.prototype.onNext=function(t){this.messages.push(new y(this.scheduler.clock,h.createOnNext(t)))},t.prototype.onError=function(t){this.messages.push(new y(this.scheduler.clock,h.createOnError(t)))},t.prototype.onCompleted=function(){this.messages.push(new y(this.scheduler.clock,h.createOnCompleted()))},t}(),E=function(){function t(t){var e=this;this.observers.push(t),this.subscriptions.push(new w(this.scheduler.clock));var n=this.subscriptions.length-1;return p(function(){var r=e.observers.indexOf(t);e.observers.splice(r,1),e.subscriptions[n]=new w(e.subscriptions[n].subscribe,e.scheduler.clock)})}function e(n,r){e.super_.constructor.call(this,t);var i,o,s=this;this.scheduler=n,this.messages=r,this.subscriptions=[],this.observers=[];for(var u=0,c=this.messages.length;c>u;u++)i=this.messages[u],o=i.value,function(t){n.scheduleAbsoluteWithState(null,i.time,function(){for(var e=0;s.observers.length>e;e++)t.accept(s.observers[e]);return f})}(o)}return v(e,c),e}(),C=function(){function t(t){var e,n,r=this;this.subscriptions.push(new w(this.scheduler.clock));for(var i=this.subscriptions.length-1,o=new d,s=0,u=this.messages.length;u>s;s++)e=this.messages[s],n=e.value,function(n){o.add(r.scheduler.scheduleRelativeWithState(null,e.time,function(){return n.accept(t),f}))}(n);return p(function(){r.subscriptions[i]=new w(r.subscriptions[i].subscribe,r.scheduler.clock),o.dispose()})}function e(n,r){e.super_.constructor.call(this,t),this.scheduler=n,this.messages=r,this.subscriptions=[]}return v(e,c),e}();return n.TestScheduler=function(){function t(){t.super_.constructor.call(this,0,function(t,e){return t-e})}return v(t,a),t.prototype.scheduleAbsoluteWithState=function(e,n,r){return this.clock>=n&&(n=this.clock+1),t.super_.scheduleAbsoluteWithState.call(this,e,n,r)},t.prototype.add=function(t,e){return t+e},t.prototype.toDateTimeOffset=function(t){return new Date(t).getTime()},t.prototype.toRelative=function(t){return t},t.prototype.startWithTiming=function(t,e,n,r){var i,o,s=this.createObserver();return this.scheduleAbsoluteWithState(null,e,function(){return i=t(),f}),this.scheduleAbsoluteWithState(null,n,function(){return o=i.subscribe(s),f}),this.scheduleAbsoluteWithState(null,r,function(){return o.dispose(),f}),this.start(),s},t.prototype.startWithDispose=function(t,e){return this.startWithTiming(t,m.created,m.subscribed,e)},t.prototype.startWithCreate=function(t){return this.startWithTiming(t,m.created,m.subscribed,m.disposed)},t.prototype.createHotObservable=function(){var t=i(arguments,0);return new E(this,t)},t.prototype.createColdObservable=function(){var t=i(arguments,0);return new C(this,t)},t.prototype.createObserver=function(){return new x(this)},t}(),n});
+(function(t,e){var n="object"==typeof exports&&exports&&("object"==typeof t&&t&&t==t.global&&(window=t),exports);"function"==typeof define&&define.amd?define(["rx","exports"],function(n,r){return t.Rx=e(t,r,n),t.Rx}):"object"==typeof module&&module&&module.exports==n?module.exports=e(t,module.exports,require("./rx")):t.Rx=e(t,{},t.Rx)})(this,function(t,e,n){function r(t,e){return e.equals?e.equals(t):t===e}function i(t,e){return 1===t.length&&Array.isArray(t[e])?t[e]:b.call(t)}function o(t){this.predicate=t}function s(t){this.predicate=t}var u=n.Observer,c=n.Observable,h=n.Notification,a=n.VirtualTimeScheduler,l=n.Disposable,f=l.empty,p=l.create,d=n.CompositeDisposable,b=(n.SingleAssignmentDisposable,Array.prototype.slice),v=n.Internals.inherits;o.prototype.equals=function(t){return t===this?!0:null==t?!1:"N"!==t.kind?!1:this.predicate(t.value)},s.prototype.equals=function(t){return t===this?!0:null==t?!1:"E"!==t.kind?!1:this.predicate(t.exception)};var m=n.ReactiveTest={created:100,subscribed:200,disposed:1e3,onNext:function(t,e){return"function"==typeof e?new y(t,new o(e)):new y(t,h.createOnNext(e))},onError:function(t,e){return"function"==typeof e?new y(t,new s(e)):new y(t,h.createOnError(e))},onCompleted:function(t){return new y(t,h.createOnCompleted())},subscribe:function(t,e){return new w(t,e)}},y=n.Recorded=function(t,e,n){this.time=t,this.value=e,this.comparer=n||r};y.prototype.equals=function(t){return this.time===t.time&&this.comparer(this.value,t.value)},y.prototype.toString=function(){return""+this.value+"@"+this.time};var w=n.Subscription=function(t,e){this.subscribe=t,this.unsubscribe=e||Number.MAX_VALUE};w.prototype.equals=function(t){return this.subscribe===t.subscribe&&this.unsubscribe===t.unsubscribe},w.prototype.toString=function(){return"("+this.subscribe+", "+this.unsubscribe===Number.MAX_VALUE?"Infinite":this.unsubscribe+")"};var g=n.MockDisposable=function(t){this.scheduler=t,this.disposes=[],this.disposes.push(this.scheduler.clock)};g.prototype.dispose=function(){this.disposes.push(this.scheduler.clock)};var x=function(t){function e(e){t.call(this),this.scheduler=e,this.messages=[]}v(e,t);var n=e.prototype;return n.onNext=function(t){this.messages.push(new y(this.scheduler.clock,h.createOnNext(t)))},n.onError=function(t){this.messages.push(new y(this.scheduler.clock,h.createOnError(t)))},n.onCompleted=function(){this.messages.push(new y(this.scheduler.clock,h.createOnCompleted()))},e}(u),E=function(t){function e(t){var e=this;this.observers.push(t),this.subscriptions.push(new w(this.scheduler.clock));var n=this.subscriptions.length-1;return p(function(){var r=e.observers.indexOf(t);e.observers.splice(r,1),e.subscriptions[n]=new w(e.subscriptions[n].subscribe,e.scheduler.clock)})}function n(n,r){t.call(this,e);var i,o,s=this;this.scheduler=n,this.messages=r,this.subscriptions=[],this.observers=[];for(var u=0,c=this.messages.length;c>u;u++)i=this.messages[u],o=i.value,function(t){n.scheduleAbsoluteWithState(null,i.time,function(){for(var e=0;s.observers.length>e;e++)t.accept(s.observers[e]);return f})}(o)}return v(n,t),n}(c),C=function(t){function e(t){var e,n,r=this;this.subscriptions.push(new w(this.scheduler.clock));for(var i=this.subscriptions.length-1,o=new d,s=0,u=this.messages.length;u>s;s++)e=this.messages[s],n=e.value,function(n){o.add(r.scheduler.scheduleRelativeWithState(null,e.time,function(){return n.accept(t),f}))}(n);return p(function(){r.subscriptions[i]=new w(r.subscriptions[i].subscribe,r.scheduler.clock),o.dispose()})}function n(n,r){t.call(this,e),this.scheduler=n,this.messages=r,this.subscriptions=[]}return v(n,t),n}(c);return n.TestScheduler=function(t){function e(){t.call(this,0,function(t,e){return t-e})}return v(e,t),e.prototype.scheduleAbsoluteWithState=function(e,n,r){return this.clock>=n&&(n=this.clock+1),t.prototype.scheduleAbsoluteWithState.call(this,e,n,r)},e.prototype.add=function(t,e){return t+e},e.prototype.toDateTimeOffset=function(t){return new Date(t).getTime()},e.prototype.toRelative=function(t){return t},e.prototype.startWithTiming=function(t,e,n,r){var i,o,s=this.createObserver();return this.scheduleAbsoluteWithState(null,e,function(){return i=t(),f}),this.scheduleAbsoluteWithState(null,n,function(){return o=i.subscribe(s),f}),this.scheduleAbsoluteWithState(null,r,function(){return o.dispose(),f}),this.start(),s},e.prototype.startWithDispose=function(t,e){return this.startWithTiming(t,m.created,m.subscribed,e)},e.prototype.startWithCreate=function(t){return this.startWithTiming(t,m.created,m.subscribed,m.disposed)},e.prototype.createHotObservable=function(){var t=i(arguments,0);return new E(this,t)},e.prototype.createColdObservable=function(){var t=i(arguments,0);return new C(this,t)},e.prototype.createObserver=function(){return new x(this)},e}(a),n});
View
7 src/core/anonymousobservable.js
@@ -1,6 +1,11 @@
+ /** @private */
var AnonymousObservable = Rx.Internals.AnonymousObservable = (function (_super) {
inherits(AnonymousObservable, _super);
+ /**
+ * @private
+ * @constructor
+ */
function AnonymousObservable(subscribe) {
function s(observer) {
@@ -28,7 +33,7 @@
return autoDetachObserver;
}
- super_.call(this, s);
+ _super.call(this, s);
}
return AnonymousObservable;
View
27 src/core/autodetachobserver.js
@@ -1,14 +1,23 @@
+ /** @private */
var AutoDetachObserver = (function (_super) {
inherits(AutoDetachObserver, _super);
+ /**
+ * @private
+ * @constructor
+ */
function AutoDetachObserver(observer) {
- AutoDetachObserver.super_.constructor.call(this);
+ _super.call(this);
this.observer = observer;
this.m = new SingleAssignmentDisposable();
}
var AutoDetachObserverPrototype = AutoDetachObserver.prototype
+ /**
+ * @private
+ * @memberOf AutoDetachObserver#
+ */
AutoDetachObserverPrototype.next = function (value) {
var noError = false;
try {
@@ -23,6 +32,10 @@
}
};
+ /**
+ * @private
+ * @memberOf AutoDetachObserver#
+ */
AutoDetachObserverPrototype.error = function (exn) {
try {
this.observer.onError(exn);
@@ -33,6 +46,10 @@
}
};
+ /**
+ * @private
+ * @memberOf AutoDetachObserver#
+ */
AutoDetachObserverPrototype.completed = function () {
try {
this.observer.onCompleted();
@@ -43,10 +60,18 @@
}
};
+ /**
+ * @private
+ * @memberOf AutoDetachObserver#
+ */
AutoDetachObserverPrototype.disposable = function (value) {
return this.m.disposable(value);
};
+ /**
+ * @private
+ * @memberOf AutoDetachObserver#
+ */
AutoDetachObserverPrototype.dispose = function () {
_super.prototype.dispose.call(this);
this.m.dispose();
View
2  src/core/concurrency/historicalscheduler.js
@@ -12,7 +12,7 @@
function HistoricalScheduler(initialClock, comparer) {
var clock = initialClock == null ? 0 : initialClock;
var cmp = comparer || defaultSubComparer;
- super_.call(this, clock, cmp);
+ _super.call(this, clock, cmp);
}
var HistoricalSchedulerProto = HistoricalScheduler.prototype;
View
8 src/core/concurrency/virtualtimescheduler.js
@@ -1,5 +1,5 @@
/** Provides a set of extension methods for virtual time scheduling. */
- root.VirtualTimeScheduler = (function () {
+ Rx.VirtualTimeScheduler = (function (_super) {
function localNow() {
return this.toDateTimeOffset(this.clock);
@@ -22,7 +22,7 @@
return disposableEmpty;
}
- inherits(VirtualTimeScheduler, Scheduler);
+ inherits(VirtualTimeScheduler, _super);
/**
* Creates a new virtual time scheduler with the specified initial clock value and absolute time comparer.
@@ -36,7 +36,7 @@
this.comparer = comparer;
this.isEnabled = false;
this.queue = new PriorityQueue(1024);
- VirtualTimeScheduler.super_.constructor.call(this, localNow, scheduleNow, scheduleRelative, scheduleAbsolute);
+ _super.call(this, localNow, scheduleNow, scheduleRelative, scheduleAbsolute);
}
var VirtualTimeSchedulerPrototype = VirtualTimeScheduler.prototype;
@@ -231,4 +231,4 @@
}
return VirtualTimeScheduler;
- }());
+ }(Scheduler));
View
2  src/core/disposables/compositedisposable.js
@@ -16,7 +16,7 @@
*
* @param {Mixed} item Disposable to add.
*/
- CompositeDisposablePrototypeadd = function (item) {
+ CompositeDisposablePrototype.add = function (item) {
if (this.isDisposed) {
item.dispose();
} else {
View
10 src/core/exports.js
@@ -1,15 +1,15 @@
// Check for AMD
if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
- window.Rx = root;
+ window.Rx = Rx;
return define(function () {
- return root;
+ return Rx;
});
} else if (freeExports) {
if (typeof module == 'object' && module && module.exports == freeExports) {
- module.exports = root;
+ module.exports = Rx;
} else {
- freeExports = root;
+ freeExports = Rx;
}
} else {
- window.Rx = root;
+ window.Rx = Rx;
}
View
2  src/core/intro.js
@@ -6,5 +6,5 @@
* @name Rx
* @type Object
*/
- var Rx = { Internals: {} };s
+ var Rx = { Internals: {} };
View
66 src/core/joins/joinobserver.js
@@ -1,10 +1,14 @@
- // Join Observer
- var JoinObserver = (function () {
+ /** @private */
+ var JoinObserver = (function (_super) {
- inherits(JoinObserver, AbstractObserver);
+ inherits(JoinObserver, _super);
+ /**
+ * @constructor
+ * @private
+ */
function JoinObserver(source, onError) {
- JoinObserver.super_.constructor.call(this);
+ _super.call(this);
this.source = source;
this.onError = onError;
this.queue = [];
@@ -13,7 +17,13 @@
this.isDisposed = false;
}
- JoinObserver.prototype.next = function (notification) {
+ var JoinObserverPrototype = JoinObserver.prototype;
+
+ /**
+ * @memberOf JoinObserver#
+ * @private
+ */
+ JoinObserverPrototype.next = function (notification) {
if (!this.isDisposed) {
if (notification.kind === 'E') {
this.onError(notification.exception);
@@ -26,28 +36,58 @@
}
}
};
- JoinObserver.prototype.error = noop;
- JoinObserver.prototype.completed = noop;
- JoinObserver.prototype.addActivePlan = function (activePlan) {
+ /**
+ * @memberOf JoinObserver#
+ * @private
+ */
+ JoinObserverPrototype.error = noop;
+
+ /**
+ * @memberOf JoinObserver#
+ * @private
+ */
+ JoinObserverPrototype.completed = noop;
+
+ /**
+ * @memberOf JoinObserver#
+ * @private
+ */
+ JoinObserverPrototype.addActivePlan = function (activePlan) {
this.activePlans.push(activePlan);
};
- JoinObserver.prototype.subscribe = function () {
+
+ /**
+ * @memberOf JoinObserver#
+ * @private
+ */
+ JoinObserverPrototype.subscribe = function () {
this.subscription.disposable(this.source.materialize().subscribe(this));
};
- JoinObserver.prototype.removeActivePlan = function (activePlan) {
+
+ /**
+ * @memberOf JoinObserver#
+ * @private
+ */
+ JoinObserverPrototype.removeActivePlan = function (activePlan) {
var idx = this.activePlans.indexOf(activePlan);
this.activePlans.splice(idx, 1);
if (this.activePlans.length === 0) {
this.dispose();
}
};
- JoinObserver.prototype.dispose = function () {
- JoinObserver.super_.dispose.call(this);
+
+ /**
+ * @memberOf JoinObserver#
+ * @private
+ */
+ JoinObserverPrototype.dispose = function () {
+ _super.prototype.dispose.call(this);
if (!this.isDisposed) {
this.isDisposed = true;
this.subscription.dispose();
}
};
+
return JoinObserver;
- } ());
+ } (AbstractObserver));
View
2  src/core/subjects/replaysubject.js
@@ -2,7 +2,7 @@
* Represents an object that is both an observable sequence as well as an observer.
* Each notification is broadcasted to all subscribed and future observers, subject to buffer trimming policies.
*/
- var ReplaySubject = Rx.ReplaySubject = (function (base) {
+ var ReplaySubject = Rx.ReplaySubject = (function (_super) {
/**
* @private
* @constructor
View
2  src/core/subjects/subject.js
@@ -2,7 +2,7 @@
* Represents an object that is both an observable sequence as well as an observer.
* Each notification is broadcasted to all subscribed observers.
*/
- var Subject = root.Subject = (function (_super) {
+ var Subject = Rx.Subject = (function (_super) {
function subscribe(observer) {
checkDisposed.call(this);
if (!this.isStopped) {
View
15 src/core/testing/coldobservable.js
@@ -1,4 +1,6 @@
- var ColdObservable = (function () {
+ /** @private */
+ var ColdObservable = (function (_super) {
+
function subscribe(observer) {
var message, notification, observable = this;
this.subscriptions.push(new Subscription(this.scheduler.clock));
@@ -20,13 +22,18 @@
});
}
- inherits(ColdObservable, Observable);
+ inherits(ColdObservable, _super);
+
+ /**
+ * @private
+ * @constructor
+ */
function ColdObservable(scheduler, messages) {
- ColdObservable.super_.constructor.call(this, subscribe);
+ _super.call(this, subscribe);
this.scheduler = scheduler;
this.messages = messages;
this.subscriptions = [];
}
return ColdObservable;
- })();
+ })(Observable);
View
15 src/core/testing/hotobservable.js
@@ -1,4 +1,6 @@
- var HotObservable = (function () {
+ /** @private */
+ var HotObservable = (function (_super) {
+
function subscribe(observer) {
var observable = this;
this.observers.push(observer);
@@ -11,9 +13,14 @@
});
}
- inherits(HotObservable, Observable);
+ inherits(HotObservable, _super);
+
+ /**
+ * @private
+ * @constructor
+ */
function HotObservable(scheduler, messages) {
- HotObservable.super_.constructor.call(this, subscribe);
+ _super.call(this, subscribe);
var message, notification, observable = this;
this.scheduler = scheduler;
this.messages = messages;
@@ -34,4 +41,4 @@
}
return HotObservable;
- })();
+ })(Observable);
View
6 src/core/testing/mockdisposable.js
@@ -1,8 +1,14 @@
+ /** @private */
var MockDisposable = root.MockDisposable = function (scheduler) {
this.scheduler = scheduler;
this.disposes = [];
this.disposes.push(this.scheduler.clock);
};
+
+ /*
+ * @memberOf MockDisposable#
+ * @prviate
+ */
MockDisposable.prototype.dispose = function () {
this.disposes.push(this.scheduler.clock);
};
View
37 src/core/testing/mockobserver.js
@@ -1,17 +1,42 @@
- var MockObserver = (function () {
- inherits(MockObserver, Observer);
+ /** @private */
+ var MockObserver = (function (_super) {
+ inherits(MockObserver, _super);
+
+ /*
+ * @constructor
+ * @prviate
+ */
function MockObserver(scheduler) {
+ _super.call(this);
this.scheduler = scheduler;
this.messages = [];
}
- MockObserver.prototype.onNext = function (value) {
+
+ var MockObserverPrototype = MockObserver.prototype;
+
+ /*
+ * @memberOf MockObserverPrototype#
+ * @prviate
+ */
+ MockObserverPrototype.onNext = function (value) {
this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnNext(value)));
};
- MockObserver.prototype.onError = function (exception) {
+
+ /*
+ * @memberOf MockObserverPrototype#
+ * @prviate
+ */
+ MockObserverPrototype.onError = function (exception) {
this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnError(exception)));
};
- MockObserver.prototype.onCompleted = function () {
+
+ /*
+ * @memberOf MockObserverPrototype#
+ * @prviate
+ */
+ MockObserverPrototype.onCompleted = function () {
this.messages.push(new Recorded(this.scheduler.clock, Notification.createOnCompleted()));
};
+
return MockObserver;
- })();
+ })(Observer);
View
23 src/core/testing/reactivetest.js
@@ -1,7 +1,15 @@
- // New predicate tests
+ /**
+ * @private
+ * @constructor
+ */
function OnNextPredicate(predicate) {
this.predicate = predicate;
};
+
+ /**
+ * @private
+ * @memberOf OnNextPredicate#
+ */
OnNextPredicate.prototype.equals = function (other) {
if (other === this) { return true; }
if (other == null) { return false; }
@@ -9,9 +17,18 @@
return this.predicate(other.value);
};
+ /**
+ * @private
+ * @constructor
+ */
function OnErrorPredicate(predicate) {
this.predicate = predicate;
};
+
+ /**
+ * @private
+ * @memberOf OnErrorPredicate#
+ */
OnErrorPredicate.prototype.equals = function (other) {
if (other === this) { return true; }
if (other == null) { return false; }
@@ -19,6 +36,10 @@
return this.predicate(other.exception);
};
+ /**
+ * @static
+ * type Object
+ */
var ReactiveTest = root.ReactiveTest = {
/** Default virtual time used for creation of observable sequences in unit tests. */
created: 100,
View
18 src/core/testing/recorded.js
@@ -1,10 +1,10 @@
/**
- * @constructor
* Creates a new object recording the production of the specified value at the given virtual time.
- *
- * @param time Virtual time the value was produced on.
- * @param value Value that was produced.
- * @param comparer An optional comparer.
+ *
+ * @constructor
+ * @param {Number} time Virtual time the value was produced on.
+ * @param {Mixed} value Value that was produced.
+ * @param {Function} comparer An optional comparer.
*/
var Recorded = root.Recorded = function (time, value, comparer) {
this.time = time;
@@ -14,8 +14,9 @@
/**
* Checks whether the given recorded object is equal to the current instance.
- * @param other Recorded object to check for equality.
- * @return true if both objects are equal; false otherwise.
+ *
+ * @param {Recorded} other Recorded object to check for equality.
+ * @returns {Boolean} true if both objects are equal; false otherwise.
*/
Recorded.prototype.equals = function (other) {
return this.time === other.time && this.comparer(this.value, other.value);
@@ -23,7 +24,8 @@
/**
* Returns a string representation of the current Recorded value.
- * @return String representation of the current Recorded value.
+ *
+ * @returns {String} String representation of the current Recorded value.
*/
Recorded.prototype.toString = function () {
return this.value.toString() + '@' + this.time;
View
11 src/core/testing/subscription.js
@@ -1,8 +1,9 @@
/**
- * @constructor
* Creates a new subscription object with the given virtual subscription and unsubscription time.
- * @param subscribe Virtual time at which the subscription occurred.
- * @param unsubscribe Virtual time at which the unsubscription occurred.
+ *
+ * @constructor
+ * @param {Number} subscribe Virtual time at which the subscription occurred.
+ * @param {Number} unsubscribe Virtual time at which the unsubscription occurred.
*/
var Subscription = root.Subscription = function (start, end) {
this.subscribe = start;
@@ -12,7 +13,7 @@
/**
* Checks whether the given subscription is equal to the current instance.
* @param other Subscription object to check for equality.
- * @return true if both objects are equal; false otherwise.
+ * @returns {Boolean} true if both objects are equal; false otherwise.
*/
Subscription.prototype.equals = function (other) {
return this.subscribe === other.subscribe && this.unsubscribe === other.unsubscribe;
@@ -20,7 +21,7 @@
/**
* Returns a string representation of the current Subscription value.
- * @return String representation of the current Subscription value.
+ * @returns {String} String representation of the current Subscription value.
*/
Subscription.prototype.toString = function () {
return '(' + this.subscribe + ', ' + this.unsubscribe === Number.MAX_VALUE ? 'Infinite' : this.unsubscribe + ')';
View
10 src/core/testing/testscheduler.js
@@ -1,10 +1,10 @@
/** Virtual time scheduler used for testing applications and libraries built using Reactive Extensions. */
- root.TestScheduler = (function () {
- inherits(TestScheduler, VirtualTimeScheduler);
+ root.TestScheduler = (function (_super) {
+ inherits(TestScheduler, _super);
/** @constructor */
function TestScheduler() {
- TestScheduler.super_.constructor.call(this, 0, function (a, b) { return a - b; });
+ _super.call(this, 0, function (a, b) { return a - b; });
}
/**
@@ -19,7 +19,7 @@
if (dueTime <= this.clock) {
dueTime = this.clock + 1;
}
- return TestScheduler.super_.scheduleAbsoluteWithState.call(this, state, dueTime, action);
+ return _super.prototype.scheduleAbsoluteWithState.call(this, state, dueTime, action);
};
/**
* Adds a relative virtual time to an absolute virtual time value.
@@ -125,4 +125,4 @@
};
return TestScheduler;
- })();
+ })(VirtualTimeScheduler);
View
18 tests/ConnectableObservableTest.js
@@ -18,17 +18,17 @@
onCompleted = root.ReactiveTest.onCompleted,
subscribe = root.ReactiveTest.subscribe;
- var ConnectableObservable = (function () {
+ var ConnectableObservable = (function (_super) {
function subscribe(observer) {
return this._o.subscribe(observer);
}
- inherits(ConnectableObservable, Observable);
+ inherits(ConnectableObservable, _super);
function ConnectableObservable(o, s) {
+ _super.call(this, subscribe);
this._o = o.multicast(s);
- ConnectableObservable.super_.constructor.call(this, subscribe);
}
ConnectableObservable.prototype.connect = function () {
@@ -40,9 +40,9 @@
};
return ConnectableObservable;
- }());
+ }(Observable));
- var MySubject = (function () {
+ var MySubject = (function (_super) {
function subscribe(observer) {
var self = this;
@@ -55,12 +55,12 @@
};
}
- inherits(MySubject, Observable);
+ inherits(MySubject, _super);
function MySubject() {
+ _super.call(this, subscribe);
this.disposeOnMap = {};
this.subscribeCount = 0;
- this.disposed = false;
- MySubject.super_.constructor.call(this, subscribe);
+ this.disposed = false;
}
MySubject.prototype.disposeOn = function (value, disposable) {
this.disposeOnMap[value] = disposable;
@@ -79,7 +79,7 @@
};
return MySubject;
- })();
+ })(Observable);
test('ConnectableObservable_Creation', function () {
var y = 0;
View
16 tests/ObservableBindingTest.js
@@ -247,7 +247,7 @@
xs.subscriptions.assertEqual(subscribe(200, 390));
});
- var MySubject = (function () {
+ var MySubject = (function (_super) {
function subscribe(observer) {
var self = this;
@@ -260,12 +260,12 @@
};
}
- inherits(MySubject, Observable);
+ inherits(MySubject, _super);
function MySubject() {
+ _super.call(this, subscribe);
this.disposeOnMap = {};
this.subscribeCount = 0;
this.disposed = false;
- MySubject.super_.constructor.call(this, subscribe);
}
MySubject.prototype.disposeOn = function (value, disposable) {
this.disposeOnMap[value] = disposable;
@@ -284,26 +284,26 @@
};
return MySubject;
- })();
+ })(Observable);
- var ConnectableObservable = (function () {
+ var ConnectableObservable = (function (_super) {
function subscribe(observer) {
return this._o.subscribe(observer);
}
- inherits(ConnectableObservable, Observable);
+ inherits(ConnectableObservable, _super);
function ConnectableObservable(o, s) {
+ _super.call(this, subscribe);
this._o = o.multicast(s);
- ConnectableObservable.super_.constructor.call(this, subscribe);
}
ConnectableObservable.prototype.connect = function () { return this._o.connect(); };
ConnectableObservable.prototype.refCount = function () { return this._o.refCount(); };
return ConnectableObservable;
- }());