Comparing version 2.1.2 to 2.1.3
@@ -251,2 +251,24 @@ module.exports = function (grunt) { | ||
all: ['tests/*.html'] | ||
}, | ||
jshint: { | ||
all: [ | ||
'rx.js', | ||
'rx.modern.js', | ||
'rx.aggregates.js', | ||
'rx.binding.js', | ||
'rx.coincidence.js', | ||
'rx.experimental.js', | ||
'rx.joinpatterns.js', | ||
'rx.testing.js', | ||
'rx.time.js' | ||
] | ||
}, | ||
watch: { | ||
scripts: { | ||
files: 'src/**/*.js', | ||
tasks: ['default'], | ||
options: { | ||
interrupt: true | ||
} | ||
} | ||
} | ||
@@ -258,4 +280,24 @@ }); | ||
grunt.loadNpmTasks('grunt-contrib-qunit'); | ||
grunt.loadNpmTasks('grunt-contrib-jshint'); | ||
grunt.loadNpmTasks('grunt-contrib-watch'); | ||
// Default task(s). | ||
grunt.registerTask('test', [ | ||
'qunit' | ||
]); | ||
grunt.registerTask('lint', [ | ||
'concat:basic', | ||
'concat:modern', | ||
'concat:aggregates', | ||
'concat:binding', | ||
'concat:coincidence', | ||
'concat:experimental', | ||
'concat:joinpatterns', | ||
'concat:time', | ||
'concat:testing', | ||
'jshint' | ||
]); | ||
// Default task | ||
grunt.registerTask('default', [ | ||
@@ -262,0 +304,0 @@ 'concat:basic', |
@@ -5,3 +5,3 @@ { | ||
"description": "Library for composing asynchronous and event-based operations in JavaScript", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"homepage": "http://rx.codeplex.com", | ||
@@ -24,11 +24,15 @@ "author": { | ||
"devDependencies": { | ||
"grunt": "~0.4.0", | ||
"grunt-contrib-jshint": "~0.1.1", | ||
"grunt-contrib-nodeunit": "~0.1.2", | ||
"grunt-cli": "*", | ||
"grunt": "~0.4.1", | ||
"grunt-contrib-jshint": "*", | ||
"grunt-contrib-uglify": "*", | ||
"grunt-contrib-concat": "*", | ||
"grunt-contrib-qunit": "*" | ||
"grunt-contrib-qunit": "*", | ||
"grunt-contrib-watch": "*" | ||
}, | ||
"keywords": [], | ||
"main": "rx.node.js" | ||
"main": "rx.node.js", | ||
"scripts": { | ||
"test": "grunt" | ||
} | ||
} |
@@ -0,1 +1,3 @@ | ||
[![Build Status](https://travis-ci.org/Reactive-Extensions/RxJS.png)](https://travis-ci.org/Reactive-Extensions/RxJS) | ||
# The Reactive Extensions for JavaScript... # | ||
@@ -19,2 +21,3 @@ *...is a set of libraries to compose asynchronous and event-based programs using observable collections and LINQ-style query operators in JavaScript* | ||
- **rx.js** - Core library | ||
- **rx.modern.js** - Core library for ES5 compliant browsers and runtimes | ||
- **rx.aggregates.js** - aggregation event processing query operations | ||
@@ -28,6 +31,66 @@ - **rx.binding.js** - binding operators including multicast, publish, publishLast, publishValue, and replay | ||
## Getting Started ## | ||
## Why RxJS? ## | ||
Coming Soon | ||
One question you may ask yourself, is why RxJS? What about Promises? Promises are good for solving asynchronous operations such as querying a service with an XMLHttpRequest, where the expected behavior is one value and then completion. The Reactive Extensions for JavaScript unifies both the world of Promises, callbacks as well as evented data such as DOM Input, Web Workers, Web Sockets. Once we have unified these concepts, this enables rich composition. | ||
To give you an idea about rich composition, we can create an autocompletion service which takes the user input from a text input and then query a service, making sure not to flood the service with calls for every key stroke, but instead allow to go at a more natural pace. | ||
Let's start with getting the user input from an input, listening to the keyup event. | ||
```js | ||
/* Only get the value from each key up */ | ||
var keyups = Rx.Observable.fromEvent(input, 'keyup') | ||
.select(function (e) { | ||
return e.target.value; | ||
}) | ||
.where(function (text) { | ||
return text.length > 2; | ||
}); | ||
/* Now throttle/debounce the input for 500ms */ | ||
var throttled = keyups | ||
.throttle(500 /* ms */); | ||
/* Now get only distinct values, so we eliminate the arrows */ | ||
var distinct = keyups | ||
.distinctUntilChanged(); | ||
``` | ||
Now, let's query Wikipedia! | ||
```js | ||
function searchWikipedia(term) { | ||
var url = 'http://en.wikipedia.org/w/api.php?action=opensearch' | ||
+ '&format=json' | ||
+ '&search=' + encodeURI(term); | ||
return Rx.Observable.getJSONPRequest(url); | ||
} | ||
``` | ||
Once that is created, now we can tie together the distinct throttled input and then query the service. In this case, we'll call select to get the value, and then calling switchLatest to ensure that we're not introducing any out of order sequence calls. We'll filter the results to make sure we get values. | ||
```js | ||
var suggestions = distinct | ||
.select(function (text) { | ||
return searchWikipedia(text); | ||
}) | ||
.switchLatest() | ||
.where(function (data) { | ||
return data.length == 2 && data[1].length > 0; | ||
}); | ||
``` | ||
Finally, we call the subscribe method on our observable sequence to start pulling data. | ||
```js | ||
suggestions.subscribe( function (data) { | ||
var results = data[1]; | ||
/* Do something with the data like binding */ | ||
}, function (e) { | ||
/* handle any errors */ | ||
}); | ||
``` | ||
And there you have it! | ||
## API Documentation ## | ||
@@ -37,3 +100,3 @@ | ||
- Observer | ||
- [Observer](https://github.com/Reactive-Extensions/RxJS/wiki/Observer) | ||
- [Observable](https://github.com/Reactive-Extensions/RxJS/wiki/Observable) | ||
@@ -86,4 +149,4 @@ | ||
npm install rxjs | ||
npm install -g rxjs | ||
npm install rx | ||
npm install -g rx | ||
@@ -90,0 +153,0 @@ Using in Node.js: |
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. | ||
(function (root, factory) { | ||
var freeExports = typeof exports == 'object' && exports && | ||
(typeof root == 'object' && root && root == root.global && (window = root), exports); | ||
var freeExports = typeof exports == 'object' && exports, | ||
freeModule = typeof module == 'object' && module && module.exports == freeExports && module, | ||
freeGlobal = typeof global == 'object' && global; | ||
if (freeGlobal.global === freeGlobal) { | ||
window = freeGlobal; | ||
} | ||
@@ -13,3 +17,3 @@ // Because of build optimizers | ||
}); | ||
} else if (typeof module == 'object' && module && module.exports == freeExports) { | ||
} else if (typeof module === 'object' && module && module.exports === freeExports) { | ||
module.exports = factory(root, module.exports, require('./rx')); | ||
@@ -80,3 +84,3 @@ } else { | ||
function firstOnly(x) { | ||
if (x.length == 0) { | ||
if (x.length === 0) { | ||
throw new Error(sequenceContainsNoElements); | ||
@@ -143,5 +147,5 @@ } | ||
var source = this; | ||
return predicate | ||
? source.where(predicate, thisArg).any() | ||
: new AnonymousObservable(function (observer) { | ||
return predicate ? | ||
source.where(predicate, thisArg).any() : | ||
new AnonymousObservable(function (observer) { | ||
return source.subscribe(function () { | ||
@@ -658,4 +662,12 @@ observer.onNext(true); | ||
return new AnonymousObservable(function (observer) { | ||
var i = 0; | ||
return source.subscribe(function (x) { | ||
if (predicate.call(thisArg, x, i, source)) { | ||
var shouldRun; | ||
try { | ||
shouldRun = predicate.call(thisArg, x, i, source); | ||
} catch(e) { | ||
observer.onError(e); | ||
return; | ||
} | ||
if (shouldRun) { | ||
observer.onNext(yieldIndex ? i : x); | ||
@@ -662,0 +674,0 @@ observer.onCompleted(); |
@@ -1,1 +0,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,r){function o(t,e){return t===e}function s(t){return t}function u(t,e){return t>e?1:t===e?0:-1}function c(t,e,n){return new w(function(i){var o=!1,s=null,u=[];return t.subscribe(function(t){var c,a;try{a=e(t)}catch(h){return i.onError(h),r}if(c=0,o)try{c=n(a,s)}catch(l){return i.onError(l),r}else o=!0,s=a;c>0&&(s=a,u=[]),c>=0&&u.push(t)},i.onError.bind(i),function(){i.onNext(u),i.onCompleted()})})}function a(t){if(0==t.length)throw Error(E);return t[0]}function h(t,e,n){return new w(function(i){var o=0,s=e.length;return t.subscribe(function(t){var u=!1;try{s>o&&(u=n(t,e[o++]))}catch(c){return i.onError(c),r}u||(i.onNext(!1),i.onCompleted())},i.onError.bind(i),function(){i.onNext(o===s),i.onCompleted()})})}function l(t,e,n,r){if(0>e)throw Error(g);return new w(function(i){var o=e;return t.subscribe(function(t){0===o&&(i.onNext(t),i.onCompleted()),o--},i.onError.bind(i),function(){n?(i.onNext(r),i.onCompleted()):i.onError(Error(g))})})}function f(t,e,n){return new w(function(r){var i=n,o=!1;return t.subscribe(function(t){o?r.onError(Error("Sequence contains more than one element")):(i=t,o=!0)},r.onError.bind(r),function(){o||e?(r.onNext(i),r.onCompleted()):r.onError(Error(E))})})}function p(t,e,n){return new w(function(r){return t.subscribe(function(t){r.onNext(t),r.onCompleted()},r.onError.bind(r),function(){e?(r.onNext(n),r.onCompleted()):r.onError(Error(E))})})}function d(t,e,n){return new w(function(r){var i=n,o=!1;return t.subscribe(function(t){i=t,o=!0},r.onError.bind(r),function(){o||e?(r.onNext(i),r.onCompleted()):r.onError(Error(E))})})}function b(t,e,n,o){return new w(function(s){return t.subscribe(function(r){e.call(n,r,i,t)?(s.onNext(o?i:r),s.onCompleted()):i++},s.onError.bind(s),function(){s.onNext(o?-1:r),s.onCompleted()})})}var v=n.Observable,m=v.prototype,y=n.CompositeDisposable,w=n.Internals.AnonymousObservable,g="Argument out of range",E="Sequence contains no elements.";return m.aggregate=function(){var t,e,n;return 2===arguments.length?(t=arguments[0],e=!0,n=arguments[1]):n=arguments[0],e?this.scan(t,n).startWith(t).finalValue():this.scan(n).finalValue()},m.reduce=function(){var t,e,n=arguments[0];return 2===arguments.length&&(e=!0,t=arguments[1]),e?this.scan(t,n).startWith(t).finalValue():this.scan(n).finalValue()},m.any=function(t,e){var n=this;return t?n.where(t,e).any():new w(function(t){return n.subscribe(function(){t.onNext(!0),t.onCompleted()},t.onError.bind(t),function(){t.onNext(!1),t.onCompleted()})})},m.some=m.any,m.isEmpty=function(){return this.any().select(function(t){return!t})},m.all=function(t,e){return this.where(function(e){return!t(e)},e).any().select(function(t){return!t})},m.every=m.all,m.contains=function(t,e){return e||(e=o),this.where(function(n){return e(n,t)}).any()},m.count=function(t){return t?this.where(t).count():this.aggregate(0,function(t){return t+1})},m.sum=function(t){return t?this.select(t).sum():this.aggregate(0,function(t,e){return t+e})},m.minBy=function(t,e){return e||(e=u),c(this,t,function(t,n){return-1*e(t,n)})},m.min=function(t){return this.minBy(s,t).select(function(t){return a(t)})},m.maxBy=function(t,e){return e||(e=u),c(this,t,e)},m.max=function(t){return this.maxBy(s,t).select(function(t){return a(t)})},m.average=function(t){return t?this.select(t).average():this.scan({sum:0,count:0},function(t,e){return{sum:t.sum+e,count:t.count+1}}).finalValue().select(function(t){return t.sum/t.count})},m.sequenceEqual=function(t,e){var n=this;return e||(e=o),Array.isArray(t)?h(n,t,e):new w(function(i){var o=!1,s=!1,u=[],c=[],a=n.subscribe(function(t){var n,o;if(c.length>0){o=c.shift();try{n=e(o,t)}catch(a){return i.onError(a),r}n||(i.onNext(!1),i.onCompleted())}else s?(i.onNext(!1),i.onCompleted()):u.push(t)},i.onError.bind(i),function(){o=!0,0===u.length&&(c.length>0?(i.onNext(!1),i.onCompleted()):s&&(i.onNext(!0),i.onCompleted()))}),h=t.subscribe(function(t){var n,s;if(u.length>0){s=u.shift();try{n=e(s,t)}catch(a){return i.onError(a),r}n||(i.onNext(!1),i.onCompleted())}else o?(i.onNext(!1),i.onCompleted()):c.push(t)},i.onError.bind(i),function(){s=!0,0===c.length&&(u.length>0?(i.onNext(!1),i.onCompleted()):o&&(i.onNext(!0),i.onCompleted()))});return new y(a,h)})},m.elementAt=function(t){return l(this,t,!1)},m.elementAtOrDefault=function(t,e){return l(this,t,!0,e)},m.single=function(t){return t?this.where(t).single():f(this,!1)},m.singleOrDefault=function(t,e){return t?this.where(t).singleOrDefault(null,e):f(this,!0,e)},m.first=function(t){return t?this.where(t).first():p(this,!1)},m.firstOrDefault=function(t,e){return t?this.where(t).firstOrDefault(null,e):p(this,!0,e)},m.last=function(t){return t?this.where(t).last():d(this,!1)},m.lastOrDefault=function(t,e){return t?this.where(t).lastOrDefault(null,e):d(this,!0,e)},m.find=function(t){return b(this,t,arguments[1],!1)},m.findIndex=function(t){return b(this,t,arguments[1],!0)},n}); | ||
(function(t,e){var n="object"==typeof exports&&exports,r=("object"==typeof module&&module&&module.exports==n&&module,"object"==typeof global&&global);r.global===r&&(window=r),"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,r){function i(t,e){return t===e}function o(t){return t}function s(t,e){return t>e?1:t===e?0:-1}function u(t,e,n){return new y(function(i){var o=!1,s=null,u=[];return t.subscribe(function(t){var c,a;try{a=e(t)}catch(h){return i.onError(h),r}if(c=0,o)try{c=n(a,s)}catch(l){return i.onError(l),r}else o=!0,s=a;c>0&&(s=a,u=[]),c>=0&&u.push(t)},i.onError.bind(i),function(){i.onNext(u),i.onCompleted()})})}function c(t){if(0===t.length)throw Error(g);return t[0]}function a(t,e,n){return new y(function(i){var o=0,s=e.length;return t.subscribe(function(t){var u=!1;try{s>o&&(u=n(t,e[o++]))}catch(c){return i.onError(c),r}u||(i.onNext(!1),i.onCompleted())},i.onError.bind(i),function(){i.onNext(o===s),i.onCompleted()})})}function h(t,e,n,r){if(0>e)throw Error(w);return new y(function(i){var o=e;return t.subscribe(function(t){0===o&&(i.onNext(t),i.onCompleted()),o--},i.onError.bind(i),function(){n?(i.onNext(r),i.onCompleted()):i.onError(Error(w))})})}function l(t,e,n){return new y(function(r){var i=n,o=!1;return t.subscribe(function(t){o?r.onError(Error("Sequence contains more than one element")):(i=t,o=!0)},r.onError.bind(r),function(){o||e?(r.onNext(i),r.onCompleted()):r.onError(Error(g))})})}function f(t,e,n){return new y(function(r){return t.subscribe(function(t){r.onNext(t),r.onCompleted()},r.onError.bind(r),function(){e?(r.onNext(n),r.onCompleted()):r.onError(Error(g))})})}function p(t,e,n){return new y(function(r){var i=n,o=!1;return t.subscribe(function(t){i=t,o=!0},r.onError.bind(r),function(){o||e?(r.onNext(i),r.onCompleted()):r.onError(Error(g))})})}function d(t,e,n,i){return new y(function(o){var s=0;return t.subscribe(function(u){var c;try{c=e.call(n,u,s,t)}catch(a){return o.onError(a),r}c?(o.onNext(i?s:u),o.onCompleted()):s++},o.onError.bind(o),function(){o.onNext(i?-1:r),o.onCompleted()})})}var b=n.Observable,v=b.prototype,m=n.CompositeDisposable,y=n.Internals.AnonymousObservable,w="Argument out of range",g="Sequence contains no elements.";return v.aggregate=function(){var t,e,n;return 2===arguments.length?(t=arguments[0],e=!0,n=arguments[1]):n=arguments[0],e?this.scan(t,n).startWith(t).finalValue():this.scan(n).finalValue()},v.reduce=function(){var t,e,n=arguments[0];return 2===arguments.length&&(e=!0,t=arguments[1]),e?this.scan(t,n).startWith(t).finalValue():this.scan(n).finalValue()},v.any=function(t,e){var n=this;return t?n.where(t,e).any():new y(function(t){return n.subscribe(function(){t.onNext(!0),t.onCompleted()},t.onError.bind(t),function(){t.onNext(!1),t.onCompleted()})})},v.some=v.any,v.isEmpty=function(){return this.any().select(function(t){return!t})},v.all=function(t,e){return this.where(function(e){return!t(e)},e).any().select(function(t){return!t})},v.every=v.all,v.contains=function(t,e){return e||(e=i),this.where(function(n){return e(n,t)}).any()},v.count=function(t){return t?this.where(t).count():this.aggregate(0,function(t){return t+1})},v.sum=function(t){return t?this.select(t).sum():this.aggregate(0,function(t,e){return t+e})},v.minBy=function(t,e){return e||(e=s),u(this,t,function(t,n){return-1*e(t,n)})},v.min=function(t){return this.minBy(o,t).select(function(t){return c(t)})},v.maxBy=function(t,e){return e||(e=s),u(this,t,e)},v.max=function(t){return this.maxBy(o,t).select(function(t){return c(t)})},v.average=function(t){return t?this.select(t).average():this.scan({sum:0,count:0},function(t,e){return{sum:t.sum+e,count:t.count+1}}).finalValue().select(function(t){return t.sum/t.count})},v.sequenceEqual=function(t,e){var n=this;return e||(e=i),Array.isArray(t)?a(n,t,e):new y(function(i){var o=!1,s=!1,u=[],c=[],a=n.subscribe(function(t){var n,o;if(c.length>0){o=c.shift();try{n=e(o,t)}catch(a){return i.onError(a),r}n||(i.onNext(!1),i.onCompleted())}else s?(i.onNext(!1),i.onCompleted()):u.push(t)},i.onError.bind(i),function(){o=!0,0===u.length&&(c.length>0?(i.onNext(!1),i.onCompleted()):s&&(i.onNext(!0),i.onCompleted()))}),h=t.subscribe(function(t){var n,s;if(u.length>0){s=u.shift();try{n=e(s,t)}catch(a){return i.onError(a),r}n||(i.onNext(!1),i.onCompleted())}else o?(i.onNext(!1),i.onCompleted()):c.push(t)},i.onError.bind(i),function(){s=!0,0===c.length&&(u.length>0?(i.onNext(!1),i.onCompleted()):o&&(i.onNext(!0),i.onCompleted()))});return new m(a,h)})},v.elementAt=function(t){return h(this,t,!1)},v.elementAtOrDefault=function(t,e){return h(this,t,!0,e)},v.single=function(t){return t?this.where(t).single():l(this,!1)},v.singleOrDefault=function(t,e){return t?this.where(t).singleOrDefault(null,e):l(this,!0,e)},v.first=function(t){return t?this.where(t).first():f(this,!1)},v.firstOrDefault=function(t,e){return t?this.where(t).firstOrDefault(null,e):f(this,!0,e)},v.last=function(t){return t?this.where(t).last():p(this,!1)},v.lastOrDefault=function(t,e){return t?this.where(t).lastOrDefault(null,e):p(this,!0,e)},v.find=function(t){return d(this,t,arguments[1],!1)},v.findIndex=function(t){return d(this,t,arguments[1],!0)},n}); |
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. | ||
(function (root, factory) { | ||
var freeExports = typeof exports == 'object' && exports && | ||
(typeof root == 'object' && root && root == root.global && (window = root), exports); | ||
var freeExports = typeof exports == 'object' && exports, | ||
freeModule = typeof module == 'object' && module && module.exports == freeExports && module, | ||
freeGlobal = typeof global == 'object' && global; | ||
if (freeGlobal.global === freeGlobal) { | ||
window = freeGlobal; | ||
} | ||
@@ -13,3 +17,3 @@ // Because of build optimizers | ||
}); | ||
} else if (typeof module == 'object' && module && module.exports == freeExports) { | ||
} else if (typeof module === 'object' && module && module.exports === freeExports) { | ||
module.exports = factory(root, module.exports, require('./rx')); | ||
@@ -16,0 +20,0 @@ } else { |
@@ -1,1 +0,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,a=n.Observer,h=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=n.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,a,{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=n.ReplaySubject=function(t){function e(t){var e=new h(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,a,{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}); | ||
(function(t,e){var n="object"==typeof exports&&exports,r=("object"==typeof module&&module&&module.exports==n&&module,"object"==typeof global&&global);r.global===r&&(window=r),"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,a=n.Observer,h=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=n.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,a,{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=n.ReplaySubject=function(t){function e(t){var e=new h(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,a,{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}); |
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. | ||
(function (root, factory) { | ||
var freeExports = typeof exports == 'object' && exports && | ||
(typeof root == 'object' && root && root == root.global && (window = root), exports); | ||
var freeExports = typeof exports == 'object' && exports, | ||
freeModule = typeof module == 'object' && module && module.exports == freeExports && module, | ||
freeGlobal = typeof global == 'object' && global; | ||
if (freeGlobal.global === freeGlobal) { | ||
window = freeGlobal; | ||
} | ||
@@ -13,3 +17,3 @@ // Because of build optimizers | ||
}); | ||
} else if (typeof module == 'object' && module && module.exports == freeExports) { | ||
} else if (typeof module === 'object' && module && module.exports === freeExports) { | ||
module.exports = factory(root, module.exports, require('./rx')); | ||
@@ -43,8 +47,7 @@ } else { | ||
function isPrime(candidate) { | ||
var num1, num2; | ||
if (candidate & 1 === 0) { | ||
return candidate === 2; | ||
} | ||
num1 = Math.sqrt(candidate); | ||
num2 = 3; | ||
var num1 = Math.sqrt(candidate), | ||
num2 = 3; | ||
while (num2 <= num1) { | ||
@@ -77,2 +80,25 @@ if (candidate % num2 === 0) { | ||
function stringHashFn(str) { | ||
var hash = 757602046; | ||
if (!str.length) { | ||
return hash; | ||
} | ||
for (var i = 0, len = str.length; i < len; i++) { | ||
var character = str.charCodeAt(i); | ||
hash = ((hash<<5)-hash)+character; | ||
hash = hash & hash; | ||
} | ||
return hash; | ||
} | ||
function numberHashFn(key) { | ||
var c2 = 0x27d4eb2d; | ||
key = (key ^ 61) ^ (key >>> 16); | ||
key = key + (key << 3); | ||
key = key ^ (key >>> 4); | ||
key = key * c2; | ||
key = key ^ (key >>> 15); | ||
return key; | ||
} | ||
var getHashCode = (function () { | ||
@@ -82,9 +108,28 @@ var uniqueIdCounter = 0; | ||
return function (obj) { | ||
var id; | ||
if (obj === undefined) | ||
if (obj == null) { | ||
throw new Error(noSuchkey); | ||
if (obj.getHashCode !== undefined) { | ||
} | ||
// Check for built-ins before tacking on our own for any object | ||
if (typeof obj === 'string') { | ||
return stringHashFn(obj); | ||
} | ||
if (typeof obj === 'number') { | ||
return numberHashFn(obj); | ||
} | ||
if (typeof obj === 'boolean') { | ||
return obj === true ? 1 : 0; | ||
} | ||
if (obj instanceof Date) { | ||
return obj.getTime(); | ||
} | ||
if (obj.getHashCode) { | ||
return obj.getHashCode(); | ||
} | ||
id = 17 * uniqueIdCounter++; | ||
var id = 17 * uniqueIdCounter++; | ||
obj.getHashCode = function () { return id; }; | ||
@@ -102,3 +147,9 @@ return id; | ||
var Dictionary = function (capacity, comparer) { | ||
this._initialize(capacity); | ||
if (capacity < 0) { | ||
throw new Error('out of range') | ||
} | ||
if (capacity > 0) { | ||
this._initialize(capacity); | ||
} | ||
this.comparer = comparer || defaultComparer; | ||
@@ -127,5 +178,6 @@ this.freeCount = 0; | ||
Dictionary.prototype._insert = function (key, value, add) { | ||
if (this.buckets === undefined) { | ||
if (!this.buckets) { | ||
this._initialize(0); | ||
} | ||
var index3; | ||
var num = getHashCode(key) & 2147483647; | ||
@@ -136,3 +188,3 @@ var index1 = num % this.buckets.length; | ||
if (add) { | ||
throw duplicatekey; | ||
throw new Error(duplicatekey); | ||
} | ||
@@ -144,3 +196,3 @@ this.entries[index2].value = value; | ||
if (this.freeCount > 0) { | ||
var index3 = this.freeList; | ||
index3 = this.freeList; | ||
this.freeList = this.entries[index3].next; | ||
@@ -162,5 +214,6 @@ --this.freeCount; | ||
}; | ||
Dictionary.prototype._resize = function () { | ||
var prime = getPrime(this.size * 2); | ||
var numArray = new Array(prime); | ||
var prime = getPrime(this.size * 2), | ||
numArray = new Array(prime); | ||
for (index = 0; index < numArray.length; ++index) { | ||
@@ -184,4 +237,5 @@ numArray[index] = -1; | ||
}; | ||
Dictionary.prototype.remove = function (key) { | ||
if (this.buckets !== undefined) { | ||
if (this.buckets) { | ||
var num = getHashCode(key) & 2147483647; | ||
@@ -211,2 +265,3 @@ var index1 = num % this.buckets.length; | ||
}; | ||
Dictionary.prototype.clear = function () { | ||
@@ -226,4 +281,5 @@ var index, len; | ||
}; | ||
Dictionary.prototype._findEntry = function (key) { | ||
if (this.buckets !== undefined) { | ||
if (this.buckets) { | ||
var num = getHashCode(key) & 2147483647; | ||
@@ -238,18 +294,18 @@ for (var index = this.buckets[num % this.buckets.length]; index >= 0; index = this.entries[index].next) { | ||
}; | ||
Dictionary.prototype.count = function () { | ||
return this.size - this.freeCount; | ||
}; | ||
Dictionary.prototype.tryGetEntry = function (key) { | ||
Dictionary.prototype.tryGetValue = function (key) { | ||
var entry = this._findEntry(key); | ||
if (entry >= 0) { | ||
return { | ||
key: this.entries[entry].key, | ||
value: this.entries[entry].value | ||
}; | ||
return this.entries[entry].value; | ||
} | ||
return undefined; | ||
}; | ||
Dictionary.prototype.getValues = function () { | ||
var index = 0, results = []; | ||
if (this.entries !== undefined) { | ||
if (this.entries) { | ||
for (var index1 = 0; index1 < this.size; index1++) { | ||
@@ -263,2 +319,3 @@ if (this.entries[index1].hashCode >= 0) { | ||
}; | ||
Dictionary.prototype.get = function (key) { | ||
@@ -271,5 +328,7 @@ var entry = this._findEntry(key); | ||
}; | ||
Dictionary.prototype.set = function (key, value) { | ||
this._insert(key, value, false); | ||
}; | ||
Dictionary.prototype.containskey = function (key) { | ||
@@ -390,112 +449,132 @@ return this._findEntry(key) >= 0; | ||
return new AnonymousObservable(function (observer) { | ||
var group = new CompositeDisposable(), | ||
r = new RefCountDisposable(group), | ||
leftId = 0, | ||
leftMap = new Dictionary(), | ||
rightId = 0, | ||
rightMap = new Dictionary(); | ||
group.add(left.subscribe(function (value) { | ||
var duration, | ||
expire, | ||
i, | ||
id = leftId++, | ||
leftValues, | ||
result, | ||
rightValues; | ||
var s = new Subject(); | ||
leftMap.add(id, s); | ||
try { | ||
result = resultSelector(value, addRef(s, r)); | ||
} catch (exception) { | ||
leftValues = leftMap.getValues(); | ||
for (i = 0; i < leftValues.length; i++) { | ||
leftValues[i].onError(exception); | ||
var nothing = function () {}; | ||
var group = new CompositeDisposable(); | ||
var r = new RefCountDisposable(group); | ||
var leftMap = new Dictionary(); | ||
var rightMap = new Dictionary(); | ||
var leftID = 0; | ||
var rightID = 0; | ||
group.add(left.subscribe( | ||
function (value) { | ||
var s = new Subject(); | ||
var id = leftID++; | ||
leftMap.add(id, s); | ||
var i, len, leftValues, rightValues; | ||
var result; | ||
try { | ||
result = resultSelector(value, addRef(s, r)); | ||
} catch (e) { | ||
leftValues = leftMap.getValues(); | ||
for (i = 0, len = leftValues.length; i < len; i++) { | ||
leftValues[i].onError(e); | ||
} | ||
observer.onError(e); | ||
return; | ||
} | ||
observer.onError(exception); | ||
return; | ||
} | ||
observer.onNext(result); | ||
rightValues = rightMap.getValues(); | ||
for (i = 0; i < rightValues.length; i++) { | ||
s.onNext(rightValues[i]); | ||
} | ||
var md = new SingleAssignmentDisposable(); | ||
group.add(md); | ||
expire = function () { | ||
if (leftMap.remove(id)) { | ||
s.onCompleted(); | ||
observer.onNext(result); | ||
rightValues = rightMap.getValues(); | ||
for (i = 0, len = rightValues.length; i < len; i++) { | ||
s.onNext(rightValues[i]); | ||
} | ||
group.remove(md); | ||
}; | ||
try { | ||
duration = leftDurationSelector(value); | ||
} catch (exception) { | ||
leftValues = leftMap.getValues(); | ||
for (i = 0; i < leftValues.length; i++) { | ||
leftValues[i].onError(exception); | ||
var md = new SingleAssignmentDisposable(); | ||
group.add(md); | ||
var expire = function () { | ||
if (leftMap.remove(id)) { | ||
s.onCompleted(); | ||
} | ||
group.remove(md); | ||
}; | ||
var duration; | ||
try { | ||
duration = leftDurationSelector(value); | ||
} catch (e) { | ||
leftValues = leftMap.getValues(); | ||
for (i = 0, len = leftMap.length; i < len; i++) { | ||
leftValues[i].onError(e); | ||
} | ||
observer.onError(e); | ||
return; | ||
} | ||
observer.onError(exception); | ||
return; | ||
} | ||
md.disposable(duration.take(1).subscribe(noop, function (exn) { | ||
leftValues = leftMap.getValues(); | ||
for (var idx = 0, len = leftValues.length; idx < len; idx++) { | ||
leftValues[idx].onError(exn); | ||
md.setDisposable(duration.take(1).subscribe( | ||
nothing, | ||
function (e) { | ||
leftValues = leftMap.getValues(); | ||
for (i = 0, len = leftValues.length; i < len; i++) { | ||
leftValues[i].onError(e); | ||
} | ||
observer.onError(e); | ||
}, | ||
expire) | ||
); | ||
}, | ||
function (e) { | ||
var leftValues = leftMap.getValues(); | ||
for (var i = 0, len = leftValues.length; i < len; i++) { | ||
leftValues[i].onError(e); | ||
} | ||
observer.onError(exn); | ||
}, function () { | ||
expire(); | ||
})); | ||
}, function (exception) { | ||
var i, leftValues; | ||
leftValues = leftMap.getValues(); | ||
for (i = 0; i < leftValues.length; i++) { | ||
leftValues[i].onError(exception); | ||
} | ||
observer.onError(exception); | ||
}, observer.onCompleted.bind(observer))); | ||
group.add(right.subscribe(function (value) { | ||
var duration, i, leftValues; | ||
var id = rightId++; | ||
rightMap.add(id, value); | ||
var md = new SingleAssignmentDisposable(); | ||
group.add(md); | ||
var expire = function () { | ||
rightMap.remove(id); | ||
group.remove(md); | ||
}; | ||
try { | ||
duration = rightDurationSelector(value); | ||
} catch (exception) { | ||
leftValues = leftMap.getValues(); | ||
for (i = 0; i < leftValues.length; i++) { | ||
leftValues[i].onError(exception); | ||
observer.onError(e); | ||
}, | ||
observer.onCompleted.bind(observer))); | ||
group.add(right.subscribe( | ||
function (value) { | ||
var leftValues, i, len; | ||
var id = rightID++; | ||
rightMap.add(id, value); | ||
var md = new SingleAssignmentDisposable(); | ||
group.add(md); | ||
var expire = function () { | ||
rightMap.remove(id); | ||
group.remove(md); | ||
}; | ||
var duration; | ||
try { | ||
duration = rightDurationSelector(value); | ||
} catch (e) { | ||
leftValues = leftMap.getValues(); | ||
for (i = 0, len = leftMap.length; i < len; i++) { | ||
leftValues[i].onError(e); | ||
} | ||
observer.onError(e); | ||
return; | ||
} | ||
observer.onError(exception); | ||
return; | ||
} | ||
md.disposable(duration.take(1).subscribe(noop, function (exn) { | ||
md.setDisposable(duration.take(1).subscribe( | ||
nothing, | ||
function (e) { | ||
leftValues = leftMap.getValues(); | ||
for (i = 0, len = leftMap.length; i < len; i++) { | ||
leftValues[i].onError(e); | ||
} | ||
observer.onError(e); | ||
}, | ||
expire) | ||
); | ||
leftValues = leftMap.getValues(); | ||
for (var idx = 0; idx < leftValues.length; idx++) { | ||
leftValues[idx].onError(exn); | ||
for (i = 0, len = leftValues.length; i < len; i++) { | ||
leftValues[i].onNext(value); | ||
} | ||
observer.onError(exn); | ||
}, function () { | ||
expire(); | ||
}, | ||
function (e) { | ||
var leftValues = leftMap.getValues(); | ||
for (var i = 0, len = leftValues.length; i < len; i++) { | ||
leftValues[i].onError(e); | ||
} | ||
observer.onError(e); | ||
})); | ||
leftValues = leftMap.getValues(); | ||
for (i = 0; i < leftValues.length; i++) { | ||
leftValues[i].onNext(value); | ||
} | ||
}, function (exception) { | ||
var i, leftValues; | ||
leftValues = leftMap.getValues(); | ||
for (i = 0; i < leftValues.length; i++) { | ||
leftValues[i].onError(exception); | ||
} | ||
observer.onError(exception); | ||
})); | ||
return r; | ||
}); | ||
}; | ||
} | ||
@@ -546,3 +625,3 @@ /** | ||
}); | ||
}; | ||
} | ||
@@ -625,5 +704,5 @@ function observableWindowWithBounaries(windowBoundaries) { | ||
}); | ||
}; | ||
} | ||
return Rx; | ||
})); |
@@ -1,1 +0,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,r){function i(){}function o(t,e){return t===e}function s(t){var e,n;if(false&t)return 2===t;for(e=Math.sqrt(t),n=3;e>=n;){if(0===t%n)return!1;n+=2}return!0}function u(t){var e,n,r;for(e=0;x.length>e;++e)if(n=x[e],n>=t)return n;for(r=1|t;x[x.length-1]>r;){if(s(r))return r;r+=2}return t}function c(){return{key:null,value:null,next:0,hashCode:0}}function a(t,e){return t.groupJoin(this,e,function(){return w()},function(t,e){return e})}function h(t){var e=this;return new g(function(n){var r=new m,i=new p,o=new d(i);return n.onNext(E(r,o)),i.add(e.subscribe(function(t){r.onNext(t)},function(t){r.onError(t),n.onError(t)},function(){r.onCompleted(),n.onCompleted()})),i.add(t.subscribe(function(){r.onCompleted(),r=new m,n.onNext(E(r,o))},function(t){r.onError(t),n.onError(t)},function(){r.onCompleted(),n.onCompleted()})),o})}function l(t){var e=this;return new g(function(n){var o,s=new v,u=new p(s),c=new d(u),a=new m;return n.onNext(E(a,c)),u.add(e.subscribe(function(t){a.onNext(t)},function(t){a.onError(t),n.onError(t)},function(){a.onCompleted(),n.onCompleted()})),o=function(){var e,u;try{u=t()}catch(h){return n.onError(h),r}e=new b,s.disposable(e),e.disposable(u.take(1).subscribe(i,function(t){a.onError(t),n.onError(t)},function(){a.onCompleted(),a=new m,n.onNext(E(a,c)),o()}))},o(),c})}var f=n.Observable,p=n.CompositeDisposable,d=n.RefCountDisposable,b=n.SingleAssignmentDisposable,v=n.SerialDisposable,m=n.Subject,y=f.prototype,w=f.empty,g=n.Internals.AnonymousObservable,E=(n.Observer.create,n.Internals.addRef),x=[1,3,7,13,31,61,127,251,509,1021,2039,4093,8191,16381,32749,65521,131071,262139,524287,1048573,2097143,4194301,8388593,16777213,33554393,67108859,134217689,268435399,536870909,1073741789,2147483647],C="no such key",D="duplicate key",A=function(){var t=0;return function(e){var n;if(e===r)throw Error(C);return e.getHashCode!==r?e.getHashCode():(n=17*t++,e.getHashCode=function(){return n},n)}}(),S=function(t,e){this._initialize(t),this.comparer=e||o,this.freeCount=0,this.size=0,this.freeList=-1};return S.prototype._initialize=function(t){var e,n=u(t);for(this.buckets=Array(n),this.entries=Array(n),e=0;n>e;e++)this.buckets[e]=-1,this.entries[e]=c();this.freeList=-1},S.prototype.count=function(){return this.size},S.prototype.add=function(t,e){return this._insert(t,e,!0)},S.prototype._insert=function(t,e,n){this.buckets===r&&this._initialize(0);for(var i=2147483647&A(t),o=i%this.buckets.length,s=this.buckets[o];s>=0;s=this.entries[s].next)if(this.entries[s].hashCode===i&&this.comparer(this.entries[s].key,t)){if(n)throw D;return this.entries[s].value=e,r}if(this.freeCount>0){var u=this.freeList;this.freeList=this.entries[u].next,--this.freeCount}else this.size===this.entries.length&&(this._resize(),o=i%this.buckets.length),u=this.size,++this.size;this.entries[u].hashCode=i,this.entries[u].next=this.buckets[o],this.entries[u].key=t,this.entries[u].value=e,this.buckets[o]=u},S.prototype._resize=function(){var t=u(2*this.size),e=Array(t);for(r=0;e.length>r;++r)e[r]=-1;var n=Array(t);for(r=0;this.size>r;++r)n[r]=this.entries[r];for(var r=this.size;t>r;++r)n[r]=c();for(var i=0;this.size>i;++i){var o=n[i].hashCode%t;n[i].next=e[o],e[o]=i}this.buckets=e,this.entries=n},S.prototype.remove=function(t){if(this.buckets!==r)for(var e=2147483647&A(t),n=e%this.buckets.length,i=-1,o=this.buckets[n];o>=0;o=this.entries[o].next){if(this.entries[o].hashCode===e&&this.comparer(this.entries[o].key,t))return 0>i?this.buckets[n]=this.entries[o].next:this.entries[i].next=this.entries[o].next,this.entries[o].hashCode=-1,this.entries[o].next=this.freeList,this.entries[o].key=null,this.entries[o].value=null,this.freeList=o,++this.freeCount,!0;i=o}return!1},S.prototype.clear=function(){var t,e;if(!(0>=this.size)){for(t=0,e=this.buckets.length;e>t;++t)this.buckets[t]=-1;for(t=0;this.size>t;++t)this.entries[t]=c();this.freeList=-1,this.size=0}},S.prototype._findEntry=function(t){if(this.buckets!==r)for(var e=2147483647&A(t),n=this.buckets[e%this.buckets.length];n>=0;n=this.entries[n].next)if(this.entries[n].hashCode===e&&this.comparer(this.entries[n].key,t))return n;return-1},S.prototype.count=function(){return this.size-this.freeCount},S.prototype.tryGetEntry=function(t){var e=this._findEntry(t);return e>=0?{key:this.entries[e].key,value:this.entries[e].value}:r},S.prototype.getValues=function(){var t=0,e=[];if(this.entries!==r)for(var n=0;this.size>n;n++)this.entries[n].hashCode>=0&&(e[t++]=this.entries[n].value);return e},S.prototype.get=function(t){var e=this._findEntry(t);if(e>=0)return this.entries[e].value;throw Error(C)},S.prototype.set=function(t,e){this._insert(t,e,!1)},S.prototype.containskey=function(t){return this._findEntry(t)>=0},y.join=function(t,e,n,o){var s=this;return new g(function(u){var c=new p,a=!1,h=0,l=new S,f=!1,d=0,v=new S;return c.add(s.subscribe(function(t){var n,s,f,p,d=h++,m=new b;l.add(d,t),c.add(m),s=function(){return l.remove(d)&&0===l.count()&&a&&u.onCompleted(),c.remove(m)};try{n=e(t)}catch(y){return u.onError(y),r}m.disposable(n.take(1).subscribe(i,u.onError.bind(u),function(){s()})),p=v.getValues();for(var w=0;p.length>w;w++){try{f=o(t,p[w])}catch(g){return u.onError(g),r}u.onNext(f)}},u.onError.bind(u),function(){a=!0,(f||0===l.count())&&u.onCompleted()})),c.add(t.subscribe(function(t){var e,s,a,h,p=d++,m=new b;v.add(p,t),c.add(m),s=function(){return v.remove(p)&&0===v.count()&&f&&u.onCompleted(),c.remove(m)};try{e=n(t)}catch(y){return u.onError(y),r}m.disposable(e.take(1).subscribe(i,u.onError.bind(u),function(){s()})),h=l.getValues();for(var w=0;h.length>w;w++){try{a=o(h[w],t)}catch(y){return u.onError(y),r}u.onNext(a)}},u.onError.bind(u),function(){f=!0,(a||0===v.count())&&u.onCompleted()})),c})},y.groupJoin=function(t,e,n,o){var s=this;return new g(function(u){var c=new p,a=new d(c),h=0,l=new S,f=0,v=new S;return c.add(s.subscribe(function(t){var n,s,f,p,d,y,w=h++,g=new m;l.add(w,g);try{d=o(t,E(g,a))}catch(x){for(p=l.getValues(),f=0;p.length>f;f++)p[f].onError(x);return u.onError(x),r}for(u.onNext(d),y=v.getValues(),f=0;y.length>f;f++)g.onNext(y[f]);var C=new b;c.add(C),s=function(){l.remove(w)&&g.onCompleted(),c.remove(C)};try{n=e(t)}catch(x){for(p=l.getValues(),f=0;p.length>f;f++)p[f].onError(x);return u.onError(x),r}C.disposable(n.take(1).subscribe(i,function(t){p=l.getValues();for(var e=0,n=p.length;n>e;e++)p[e].onError(t);u.onError(t)},function(){s()}))},function(t){var e,n;for(n=l.getValues(),e=0;n.length>e;e++)n[e].onError(t);u.onError(t)},u.onCompleted.bind(u))),c.add(t.subscribe(function(t){var e,o,s,a=f++;v.add(a,t);var h=new b;c.add(h);var p=function(){v.remove(a),c.remove(h)};try{e=n(t)}catch(d){for(s=l.getValues(),o=0;s.length>o;o++)s[o].onError(d);return u.onError(d),r}for(h.disposable(e.take(1).subscribe(i,function(t){s=l.getValues();for(var e=0;s.length>e;e++)s[e].onError(t);u.onError(t)},function(){p()})),s=l.getValues(),o=0;s.length>o;o++)s[o].onNext(t)},function(t){var e,n;for(n=l.getValues(),e=0;n.length>e;e++)n[e].onError(t);u.onError(t)})),a})},y.buffer=function(t,e){return 1===arguments.length&&"function"!=typeof arguments[0]?h.call(this,t).selectMany(function(t){return t.toArray()}):"function"==typeof t?l(t).selectMany(function(t){return t.toArray()}):a(this,t,e).selectMany(function(t){return t.toArray()})},y.window=function(t,e){return 1===arguments.length&&"function"!=typeof arguments[0]?h.call(this,t):"function"==typeof t?l.call(this,t):a.call(this,t,e)},n}); | ||
(function(t,e){var n="object"==typeof exports&&exports,r=("object"==typeof module&&module&&module.exports==n&&module,"object"==typeof global&&global);r.global===r&&(window=r),"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,r){function i(){}function o(t,e){return t===e}function s(t){if(false&t)return 2===t;for(var e=Math.sqrt(t),n=3;e>=n;){if(0===t%n)return!1;n+=2}return!0}function u(t){var e,n,r;for(e=0;D.length>e;++e)if(n=D[e],n>=t)return n;for(r=1|t;D[D.length-1]>r;){if(s(r))return r;r+=2}return t}function c(t){var e=757602046;if(!t.length)return e;for(var n=0,r=t.length;r>n;n++){var i=t.charCodeAt(n);e=(e<<5)-e+i,e&=e}return e}function a(t){var e=668265261;return t=61^t^t>>>16,t+=t<<3,t^=t>>>4,t*=e,t^=t>>>15}function h(){return{key:null,value:null,next:0,hashCode:0}}function l(t,e){return t.groupJoin(this,e,function(){return E()},function(t,e){return e})}function f(t){var e=this;return new x(function(n){var r=new w,i=new b,o=new v(i);return n.onNext(C(r,o)),i.add(e.subscribe(function(t){r.onNext(t)},function(t){r.onError(t),n.onError(t)},function(){r.onCompleted(),n.onCompleted()})),i.add(t.subscribe(function(){r.onCompleted(),r=new w,n.onNext(C(r,o))},function(t){r.onError(t),n.onError(t)},function(){r.onCompleted(),n.onCompleted()})),o})}function p(t){var e=this;return new x(function(n){var o,s=new y,u=new b(s),c=new v(u),a=new w;return n.onNext(C(a,c)),u.add(e.subscribe(function(t){a.onNext(t)},function(t){a.onError(t),n.onError(t)},function(){a.onCompleted(),n.onCompleted()})),o=function(){var e,u;try{u=t()}catch(h){return n.onError(h),r}e=new m,s.disposable(e),e.disposable(u.take(1).subscribe(i,function(t){a.onError(t),n.onError(t)},function(){a.onCompleted(),a=new w,n.onNext(C(a,c)),o()}))},o(),c})}var d=n.Observable,b=n.CompositeDisposable,v=n.RefCountDisposable,m=n.SingleAssignmentDisposable,y=n.SerialDisposable,w=n.Subject,g=d.prototype,E=d.empty,x=n.Internals.AnonymousObservable,C=(n.Observer.create,n.Internals.addRef),D=[1,3,7,13,31,61,127,251,509,1021,2039,4093,8191,16381,32749,65521,131071,262139,524287,1048573,2097143,4194301,8388593,16777213,33554393,67108859,134217689,268435399,536870909,1073741789,2147483647],A="no such key",S="duplicate key",N=function(){var t=0;return function(e){if(null==e)throw Error(A);if("string"==typeof e)return c(e);if("number"==typeof e)return a(e);if("boolean"==typeof e)return e===!0?1:0;if(e instanceof Date)return e.getTime();if(e.getHashCode)return e.getHashCode();var n=17*t++;return e.getHashCode=function(){return n},n}}(),_=function(t,e){if(0>t)throw Error("out of range");t>0&&this._initialize(t),this.comparer=e||o,this.freeCount=0,this.size=0,this.freeList=-1};return _.prototype._initialize=function(t){var e,n=u(t);for(this.buckets=Array(n),this.entries=Array(n),e=0;n>e;e++)this.buckets[e]=-1,this.entries[e]=h();this.freeList=-1},_.prototype.count=function(){return this.size},_.prototype.add=function(t,e){return this._insert(t,e,!0)},_.prototype._insert=function(t,e,n){this.buckets||this._initialize(0);for(var i,o=2147483647&N(t),s=o%this.buckets.length,u=this.buckets[s];u>=0;u=this.entries[u].next)if(this.entries[u].hashCode===o&&this.comparer(this.entries[u].key,t)){if(n)throw Error(S);return this.entries[u].value=e,r}this.freeCount>0?(i=this.freeList,this.freeList=this.entries[i].next,--this.freeCount):(this.size===this.entries.length&&(this._resize(),s=o%this.buckets.length),i=this.size,++this.size),this.entries[i].hashCode=o,this.entries[i].next=this.buckets[s],this.entries[i].key=t,this.entries[i].value=e,this.buckets[s]=i},_.prototype._resize=function(){var t=u(2*this.size),e=Array(t);for(r=0;e.length>r;++r)e[r]=-1;var n=Array(t);for(r=0;this.size>r;++r)n[r]=this.entries[r];for(var r=this.size;t>r;++r)n[r]=h();for(var i=0;this.size>i;++i){var o=n[i].hashCode%t;n[i].next=e[o],e[o]=i}this.buckets=e,this.entries=n},_.prototype.remove=function(t){if(this.buckets)for(var e=2147483647&N(t),n=e%this.buckets.length,r=-1,i=this.buckets[n];i>=0;i=this.entries[i].next){if(this.entries[i].hashCode===e&&this.comparer(this.entries[i].key,t))return 0>r?this.buckets[n]=this.entries[i].next:this.entries[r].next=this.entries[i].next,this.entries[i].hashCode=-1,this.entries[i].next=this.freeList,this.entries[i].key=null,this.entries[i].value=null,this.freeList=i,++this.freeCount,!0;r=i}return!1},_.prototype.clear=function(){var t,e;if(!(0>=this.size)){for(t=0,e=this.buckets.length;e>t;++t)this.buckets[t]=-1;for(t=0;this.size>t;++t)this.entries[t]=h();this.freeList=-1,this.size=0}},_.prototype._findEntry=function(t){if(this.buckets)for(var e=2147483647&N(t),n=this.buckets[e%this.buckets.length];n>=0;n=this.entries[n].next)if(this.entries[n].hashCode===e&&this.comparer(this.entries[n].key,t))return n;return-1},_.prototype.count=function(){return this.size-this.freeCount},_.prototype.tryGetValue=function(t){var e=this._findEntry(t);return e>=0?this.entries[e].value:r},_.prototype.getValues=function(){var t=0,e=[];if(this.entries)for(var n=0;this.size>n;n++)this.entries[n].hashCode>=0&&(e[t++]=this.entries[n].value);return e},_.prototype.get=function(t){var e=this._findEntry(t);if(e>=0)return this.entries[e].value;throw Error(A)},_.prototype.set=function(t,e){this._insert(t,e,!1)},_.prototype.containskey=function(t){return this._findEntry(t)>=0},g.join=function(t,e,n,o){var s=this;return new x(function(u){var c=new b,a=!1,h=0,l=new _,f=!1,p=0,d=new _;return c.add(s.subscribe(function(t){var n,s,f,p,b=h++,v=new m;l.add(b,t),c.add(v),s=function(){return l.remove(b)&&0===l.count()&&a&&u.onCompleted(),c.remove(v)};try{n=e(t)}catch(y){return u.onError(y),r}v.disposable(n.take(1).subscribe(i,u.onError.bind(u),function(){s()})),p=d.getValues();for(var w=0;p.length>w;w++){try{f=o(t,p[w])}catch(g){return u.onError(g),r}u.onNext(f)}},u.onError.bind(u),function(){a=!0,(f||0===l.count())&&u.onCompleted()})),c.add(t.subscribe(function(t){var e,s,a,h,b=p++,v=new m;d.add(b,t),c.add(v),s=function(){return d.remove(b)&&0===d.count()&&f&&u.onCompleted(),c.remove(v)};try{e=n(t)}catch(y){return u.onError(y),r}v.disposable(e.take(1).subscribe(i,u.onError.bind(u),function(){s()})),h=l.getValues();for(var w=0;h.length>w;w++){try{a=o(h[w],t)}catch(y){return u.onError(y),r}u.onNext(a)}},u.onError.bind(u),function(){f=!0,(a||0===d.count())&&u.onCompleted()})),c})},g.groupJoin=function(t,e,n,i){var o=this;return new x(function(s){var u=function(){},c=new b,a=new v(c),h=new _,l=new _,f=0,p=0;return c.add(o.subscribe(function(t){var n=new w,o=f++;h.add(o,n);var p,d,b,v,y;try{y=i(t,C(n,a))}catch(g){for(b=h.getValues(),p=0,d=b.length;d>p;p++)b[p].onError(g);return s.onError(g),r}for(s.onNext(y),v=l.getValues(),p=0,d=v.length;d>p;p++)n.onNext(v[p]);var E=new m;c.add(E);var x,D=function(){h.remove(o)&&n.onCompleted(),c.remove(E)};try{x=e(t)}catch(g){for(b=h.getValues(),p=0,d=h.length;d>p;p++)b[p].onError(g);return s.onError(g),r}E.setDisposable(x.take(1).subscribe(u,function(t){for(b=h.getValues(),p=0,d=b.length;d>p;p++)b[p].onError(t);s.onError(t)},D))},function(t){for(var e=h.getValues(),n=0,r=e.length;r>n;n++)e[n].onError(t);s.onError(t)},s.onCompleted.bind(s))),c.add(t.subscribe(function(t){var e,i,o,a=p++;l.add(a,t);var f=new m;c.add(f);var d,b=function(){l.remove(a),c.remove(f)};try{d=n(t)}catch(v){for(e=h.getValues(),i=0,o=h.length;o>i;i++)e[i].onError(v);return s.onError(v),r}for(f.setDisposable(d.take(1).subscribe(u,function(t){for(e=h.getValues(),i=0,o=h.length;o>i;i++)e[i].onError(t);s.onError(t)},b)),e=h.getValues(),i=0,o=e.length;o>i;i++)e[i].onNext(t)},function(t){for(var e=h.getValues(),n=0,r=e.length;r>n;n++)e[n].onError(t);s.onError(t)})),a})},g.buffer=function(t,e){return 1===arguments.length&&"function"!=typeof arguments[0]?f.call(this,t).selectMany(function(t){return t.toArray()}):"function"==typeof t?p(t).selectMany(function(t){return t.toArray()}):l(this,t,e).selectMany(function(t){return t.toArray()})},g.window=function(t,e){return 1===arguments.length&&"function"!=typeof arguments[0]?f.call(this,t):"function"==typeof t?p.call(this,t):l.call(this,t,e)},n}); |
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. | ||
(function (root, factory) { | ||
var freeExports = typeof exports == 'object' && exports && | ||
(typeof root == 'object' && root && root == root.global && (window = root), exports); | ||
var freeExports = typeof exports == 'object' && exports, | ||
freeModule = typeof module == 'object' && module && module.exports == freeExports && module, | ||
freeGlobal = typeof global == 'object' && global; | ||
if (freeGlobal.global === freeGlobal) { | ||
window = freeGlobal; | ||
} | ||
@@ -13,3 +17,3 @@ // Because of build optimizers | ||
}); | ||
} else if (typeof module == 'object' && module && module.exports == freeExports) { | ||
} else if (typeof module === 'object' && module && module.exports === freeExports) { | ||
module.exports = factory(root, module.exports, require('./rx')); | ||
@@ -16,0 +20,0 @@ } else { |
@@ -1,1 +0,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,r){function i(t,e){return 1===t.length&&Array.isArray(t[e])?t[e]:g.call(t)}function o(t,e){return new m(function(){var n;return v(function(){return t()?(n=e,!0):!1},function(){return n})})}var s=n.Observable,u=s.prototype,c=s.createWithDisposable,a=s.concat,h=s.defer,l=s.empty,f=n.Disposable.empty,p=(n.Internals.BinaryObserver,n.CompositeDisposable),d=n.SerialDisposable,b=n.SingleAssignmentDisposable,v=n.Internals.Enumerator.create,m=n.Internals.Enumerable,y=m.forEach,w=n.Scheduler.immediate,g=Array.prototype.slice;u.letBind=function(t){return t(this)},s.ifThen=function(t,e,n){return h(function(){if(n||(n=l()),n.now){var r=n;n=l(r)}return t()?e:n})},s.forIn=function(t,e){return y(t,e).concat()};var E=s.whileDo=function(t,e){return o(t,e).concat()};return u.doWhile=function(t){return a([this,E(t,this)])},s.switchCase=function(t,e,n){return h(function(){if(n||(n=l()),n.now){var i=n;n=l(i)}var o=e[t()];return o!==r?o:n})},u.expand=function(t,e){e||(e=w);var n=this;return c(function(i){var o=[],s=new d,u=new p(s),c=0,a=!1,h=function(){var n=!1;o.length>0&&(n=!a,a=!0),n&&s.setDisposable(e.scheduleRecursive(function(e){var n;if(!(o.length>0))return a=!1,r;n=o.shift();var s=new b;u.add(s),s.setDisposable(n.subscribe(function(e){i.onNext(e);var n=null;try{n=t(e)}catch(r){i.onError(r)}o.push(n),c++,h()},i.onError.bind(i),function(){u.remove(s),c--,0===c&&i.onCompleted()})),e()}))};return o.push(n),c++,h(),u})},s.forkJoin=function(){var t=i(arguments,0);return c(function(e){var n=t.length;if(0===n)return e.onCompleted(),f;for(var i=new p,o=!1,s=Array(n),u=Array(n),c=Array(n),a=0;n>a;a++)(function(a){var h=t[a];i.add(h.subscribe(function(t){o||(s[a]=!0,c[a]=t)},function(t){o=!0,e.onError(t),i.dispose()},function(){if(!o){if(!s[a])return e.onCompleted(),r;u[a]=!0;for(var t=0;n>t;t++)if(!u[t])return;o=!0,e.onNext(c),e.onCompleted()}}))})(a);return i})},u.forkJoin=function(t,e){var n=this;return c(function(i){var o,s,u=!1,c=!1,a=!1,h=!1,l=new b,f=new b;return l.setDisposable(n.subscribe(function(t){a=!0,o=t},function(t){f.dispose(),i.onError(t)},function(){if(u=!0,c)if(a)if(h){var t;try{t=e(o,s)}catch(n){return i.onError(n),r}i.onNext(t),i.onCompleted()}else i.onCompleted();else i.onCompleted()})),f.setDisposable(t.subscribe(function(t){h=!0,s=t},function(t){l.dispose(),i.onError(t)},function(){if(c=!0,u)if(a)if(h){var t;try{t=e(o,s)}catch(n){return i.onError(n),r}i.onNext(t),i.onCompleted()}else i.onCompleted();else i.onCompleted()})),new p(l,f)})},n}); | ||
(function(t,e){var n="object"==typeof exports&&exports,r=("object"==typeof module&&module&&module.exports==n&&module,"object"==typeof global&&global);r.global===r&&(window=r),"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,r){function i(t,e){return 1===t.length&&Array.isArray(t[e])?t[e]:g.call(t)}function o(t,e){return new m(function(){var n;return v(function(){return t()?(n=e,!0):!1},function(){return n})})}var s=n.Observable,u=s.prototype,c=s.createWithDisposable,a=s.concat,h=s.defer,l=s.empty,f=n.Disposable.empty,p=(n.Internals.BinaryObserver,n.CompositeDisposable),d=n.SerialDisposable,b=n.SingleAssignmentDisposable,v=n.Internals.Enumerator.create,m=n.Internals.Enumerable,y=m.forEach,w=n.Scheduler.immediate,g=Array.prototype.slice;u.letBind=function(t){return t(this)},s.ifThen=function(t,e,n){return h(function(){if(n||(n=l()),n.now){var r=n;n=l(r)}return t()?e:n})},s.forIn=function(t,e){return y(t,e).concat()};var E=s.whileDo=function(t,e){return o(t,e).concat()};return u.doWhile=function(t){return a([this,E(t,this)])},s.switchCase=function(t,e,n){return h(function(){if(n||(n=l()),n.now){var i=n;n=l(i)}var o=e[t()];return o!==r?o:n})},u.expand=function(t,e){e||(e=w);var n=this;return c(function(i){var o=[],s=new d,u=new p(s),c=0,a=!1,h=function(){var n=!1;o.length>0&&(n=!a,a=!0),n&&s.setDisposable(e.scheduleRecursive(function(e){var n;if(!(o.length>0))return a=!1,r;n=o.shift();var s=new b;u.add(s),s.setDisposable(n.subscribe(function(e){i.onNext(e);var n=null;try{n=t(e)}catch(r){i.onError(r)}o.push(n),c++,h()},i.onError.bind(i),function(){u.remove(s),c--,0===c&&i.onCompleted()})),e()}))};return o.push(n),c++,h(),u})},s.forkJoin=function(){var t=i(arguments,0);return c(function(e){var n=t.length;if(0===n)return e.onCompleted(),f;for(var i=new p,o=!1,s=Array(n),u=Array(n),c=Array(n),a=0;n>a;a++)(function(a){var h=t[a];i.add(h.subscribe(function(t){o||(s[a]=!0,c[a]=t)},function(t){o=!0,e.onError(t),i.dispose()},function(){if(!o){if(!s[a])return e.onCompleted(),r;u[a]=!0;for(var t=0;n>t;t++)if(!u[t])return;o=!0,e.onNext(c),e.onCompleted()}}))})(a);return i})},u.forkJoin=function(t,e){var n=this;return c(function(i){var o,s,u=!1,c=!1,a=!1,h=!1,l=new b,f=new b;return l.setDisposable(n.subscribe(function(t){a=!0,o=t},function(t){f.dispose(),i.onError(t)},function(){if(u=!0,c)if(a)if(h){var t;try{t=e(o,s)}catch(n){return i.onError(n),r}i.onNext(t),i.onCompleted()}else i.onCompleted();else i.onCompleted()})),f.setDisposable(t.subscribe(function(t){h=!0,s=t},function(t){l.dispose(),i.onError(t)},function(){if(c=!0,u)if(a)if(h){var t;try{t=e(o,s)}catch(n){return i.onError(n),r}i.onNext(t),i.onCompleted()}else i.onCompleted();else i.onCompleted()})),new p(l,f)})},n}); |
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. | ||
(function (root, factory) { | ||
var freeExports = typeof exports == 'object' && exports && | ||
(typeof root == 'object' && root && root == root.global && (window = root), exports); | ||
var freeExports = typeof exports == 'object' && exports, | ||
freeModule = typeof module == 'object' && module && module.exports == freeExports && module, | ||
freeGlobal = typeof global == 'object' && global; | ||
if (freeGlobal.global === freeGlobal) { | ||
window = freeGlobal; | ||
} | ||
@@ -13,3 +17,3 @@ // Because of build optimizers | ||
}); | ||
} else if (typeof module == 'object' && module && module.exports == freeExports) { | ||
} else if (typeof module === 'object' && module && module.exports === freeExports) { | ||
module.exports = factory(root, module.exports, require('./rx')); | ||
@@ -16,0 +20,0 @@ } else { |
@@ -1,1 +0,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 a=n.Observable,h=a.prototype,l=n.Internals.AnonymousObservable,f=a.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 a=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(a);n(a)});for(o=0,s=i.length;s>o;o++)i[o].addActivePlan(a);return a},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 h.and=function(t){return new o([this,t])},h.then=function(t){return new o([this]).then(t)},a.when=function(){var t=i(arguments,0);return new l(function(e){var n,r,i,o,s,u,c=[],a=new w;u=p(e.onNext.bind(e),function(t){for(var n=a.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(a,u,function(t){var e=c.indexOf(t);c.splice(e,1),0===c.length&&u.onCompleted()}))}catch(h){f(h).subscribe(e)}for(n=new b,s=a.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,r=("object"==typeof module&&module&&module.exports==n&&module,"object"==typeof global&&global);r.global===r&&(window=r),"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 a=n.Observable,h=a.prototype,l=n.Internals.AnonymousObservable,f=a.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 a=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(a);n(a)});for(o=0,s=i.length;s>o;o++)i[o].addActivePlan(a);return a},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 h.and=function(t){return new o([this,t])},h.then=function(t){return new o([this]).then(t)},a.when=function(){var t=i(arguments,0);return new l(function(e){var n,r,i,o,s,u,c=[],a=new w;u=p(e.onNext.bind(e),function(t){for(var n=a.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(a,u,function(t){var e=c.indexOf(t);c.splice(e,1),0===c.length&&u.onCompleted()}))}catch(h){f(h).subscribe(e)}for(n=new b,s=a.getValues(),r=0,i=s.length;i>r;r++)o=s[r],o.subscribe(),n.add(o);return n})},n}); |
@@ -1,2 +0,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(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 Ae(function(r){var i=new I,o=new P;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 Ae(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 Ae(function(n){return new R(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 W=function(t){this.items=Array(t),this.length=0},O=W.prototype;O.isHigherPriority=function(t,e){return 0>this.items[t].compareTo(this.items[e])},O.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)}}},O.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)}}},O.peek=function(){return this.items[0].value},O.removeAt=function(t){this.items[t]=this.items[--this.length],delete this.items[this.length],this.heapify()},O.dequeue=function(){var t=this.peek();return this.removeAt(0),t},O.enqueue=function(t){var e=this.length++;this.items[e]=new N(W.count++,t),this.percolate(e)},O.remove=function(t){for(var e=0;this.length>e;e++)if(this.items[e].value===t)return this.removeAt(e),!0;return!1},W.count=0;var R=y.CompositeDisposable=function(){this.disposables=h(arguments,0),this.isDisposed=!1,this.length=this.disposables.length},k=R.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},M=I.prototype;M.disposable=function(t){return t?this.setDisposable(t):this.getDisposable()},M.getDisposable=function(){return this.current},M.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()},M.dispose=function(){var t;this.isDisposed||(this.isDisposed=!0,t=this.current,this.current=null),t&&t.dispose()};var P=y.SerialDisposable=function(){this.isDisposed=!1,this.current=null};P.prototype.getDisposable=function(){return this.current},P.prototype.setDisposable=function(t){var e,n=this.isDisposed;n||(e=this.current,this.current=t),e&&e.dispose(),n&&t&&t.dispose()},P.prototype.disposable=function(t){return t?(this.setDisposable(t),e):this.getDisposable()},P.prototype.dispose=function(){var t;this.isDisposed||(this.isDisposed=!0,t=this.current,this.current=null),t&&t.dispose()};var L=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 V=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),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 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),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 K(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}(),z="Scheduler is not allowed to block the thread",F=V.immediate=function(){function t(t,e){return e(this,t)}function e(t,e,n){if(e>0)throw Error(z);return n(this,t)}function n(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new V(i,t,e,n)}(),B=V.currentThread=function(){function t(){o=new W(4)}function e(t,e){return this.scheduleWithRelativeAndState(t,0,e)}function n(e,n,r){var i,s=this.now()+V.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-V.now()>0;);t.isCancelled()||t.invoke()}};var s=new V(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 W(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}(V),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,G=n;(function(){function n(){if(!t.postMessage||t.importScripts)return!1;var e=!1,n=t.onmessage;return t.onmessage=function(){e=!0},t.postMessage("","*"),t.onmessage=n,e}function r(t){if("string"==typeof t.data&&t.data.substring(0,i.length)===i){var e=t.data.substring(i.length),n=o[e];n(),delete o[e]}}if(t.process!==e&&"[object process]"===Object.prototype.toString.call(t.process))U=t.process.nextTick;else if("function"==typeof t.setImmediate)U=t.setImmediate,G=t.clearImmediate;else if(n()){var i="ms.rx.schedule"+Math.random(),o={},s=0;t.addEventListener?t.addEventListener("message",r,!1):t.attachEvent("onmessage",r,!1),U=function(e){var n=s++;o[n]=e,t.postMessage(i+n,"*")}}else if(t.MessageChannel){var u=new t.MessageChannel,c={},a=0;u.port1.onmessage=function(t){var e=t.data,n=c[e];n(),delete c[e]},U=function(t){var e=a++;c[e]=t,u.port2.postMessage(e)}}else"document"in t&&"onreadystatechange"in t.document.createElement("script")?U=function(e){var n=t.document.createElement("script");n.onreadystatechange=function(){e(),n.onreadystatechange=null,n.parentNode.removeChild(n),n=null},t.document.documentElement.appendChild(n)}:(U=function(e){return t.setTimeout(e,0)},G=t.clearTimeout)})();var J=V.timeout=function(){function e(t,e){var n=this,r=new I,i=U(function(){r.isDisposed||r.setDisposable(e(n,t))});return new R(r,T(function(){G(i)}))}function n(e,n,r){var i=this,o=V.normalize(n);if(0===o)return i.scheduleWithState(e,r);var s=new I,u=t.setTimeout(function(){s.isDisposed||s.setDisposable(r(i,e))},o);return new R(s,T(function(){t.clearTimeout(u)}))}function r(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new V(i,e,n,r)}(),K=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}(V),Q=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||F,new Ae(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}(),X=Q.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 Q("N",!0);return i.value=r,i._accept=t.bind(i),i._acceptObservable=e.bind(i),i.toString=n.bind(i),i}}(),Y=Q.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 Q("E");return i.exception=r,i._accept=t.bind(i),i._acceptObservable=e.bind(i),i.toString=n.bind(i),i}}(),Z=Q.createOnCompleted=function(){function t(t,e,n){return n()}function e(t){return t.onCompleted()}function n(){return"OnCompleted()"}return function(){var r=new Q("C");return r._accept=t.bind(r),r._acceptObservable=e.bind(r),r.toString=n.bind(r),r}}(),$=y.Internals.Enumerator=function(t,e,n){this.moveNext=t,this.getCurrent=e,this.dispose=n},te=$.create=function(t,e,r){var i=!1;return r||(r=n),new $(function(){if(i)return!1;var e=t();return e||(i=!0,r()),e},function(){return e()},function(){i||(r(),i=!0)})},ee=y.Internals.Enumerable=function(){function t(t){this.getEnumerator=t}return t.prototype.concat=function(){var t=this;return new Ae(function(n){var r=t.getEnumerator(),i=!1,o=new P,s=F.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 R(o,s,T(function(){i=!0,r.dispose()}))})},t.prototype.catchException=function(){var t=this;return new Ae(function(n){var r,i=t.getEnumerator(),o=!1,s=new P,u=F.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 R(s,u,T(function(){o=!0}))})},t}(),ne=ee.repeat=function(t,n){return n===e&&(n=-1),new ee(function(){var e,r=n;return te(function(){return 0===r?!1:(r>0&&r--,e=t,!0)},function(){return e})})},re=ee.forEach=function(t,e){return e||(e=r),new ee(function(){var n,r=-1;return te(function(){return++r<t.length?(n=e(t[r],r),!0):!1},function(){return n})})},ie=y.Observer=function(){};ie.prototype.toNotifier=function(){var t=this;return function(e){return e.accept(t)}},ie.prototype.asObserver=function(){return new ce(this.onNext.bind(this),this.onError.bind(this),this.onCompleted.bind(this))},ie.prototype.checked=function(){return new ae(this)};var oe=ie.create=function(t,e,r){return t||(t=n),e||(e=c),r||(r=n),new ce(t,e,r)};ie.fromNotifier=function(t){return new ce(function(e){return t(X(e))},function(e){return t(Y(e))},function(){return t(Z())})};var se,ue=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}(ie),ce=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}(ue),ae=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}(ie),he=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 P}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}(ue),le=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}(he),fe=y.Observable=function(){function t(t){this._subscribe=t}return se=t.prototype,se.finalValue=function(){var t=this;return new Ae(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))})})},se.subscribe=se.forEach=function(t,e,n){var r;return r="object"==typeof t?t:oe(t,e,n),this._subscribe(r)},se.toArray=function(){function t(t,e){var n=t.slice(0);return n.push(e),n}return this.scan([],t).startWith([]).finalValue()},t}();fe.start=function(t,e){return pe(t,e)()};var pe=fe.toAsync=function(t,n,r){return n||(n=J),function(){var i=x.call(arguments,0),o=new Oe;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()}};se.observeOn=function(t){var e=this;return new Ae(function(n){return e.subscribe(new le(t,n))})},se.subscribeOn=function(t){var e=this;return new Ae(function(n){var r=new I,i=new P;return i.setDisposable(r),r.setDisposable(t.schedule(function(){i.setDisposable(new f(t,e.subscribe(n)))})),i})},fe.create=function(t){return new Ae(function(e){return T(t(e))})},fe.createWithDisposable=function(t){return new Ae(t)};var de=fe.defer=function(t){return new Ae(function(e){var n;try{n=t()}catch(r){return we(r).subscribe(e)}return n.subscribe(e)})},be=fe.empty=function(t){return t||(t=F),new Ae(function(e){return t.schedule(function(){e.onCompleted()})})},ve=fe.fromArray=function(t,e){return e||(e=B),new Ae(function(n){var r=0;return e.scheduleRecursive(function(e){t.length>r?(n.onNext(t[r++]),e()):n.onCompleted()})})};fe.generate=function(t,n,r,i,o){return o||(o=B),new Ae(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 me=fe.never=function(){return new Ae(function(){return j})};fe.range=function(t,e,n){return n||(n=B),new Ae(function(r){return n.scheduleRecursiveWithState(0,function(n,i){e>n?(r.onNext(t+n),i(n+1)):r.onCompleted()})})},fe.repeat=function(t,n,r){return r||(r=B),n==e&&(n=-1),ye(t,r).repeat(n)};var ye=fe.returnValue=function(t,e){return e||(e=F),new Ae(function(n){return e.schedule(function(){n.onNext(t),n.onCompleted()})})},we=fe.throwException=function(t,e){return e||(e=F),new Ae(function(n){return e.schedule(function(){n.onError(t)})})};fe.using=function(t,e){return new Ae(function(n){var r,i,o=j;try{r=t(),r&&(o=r),i=e(r)}catch(s){return new R(we(s).subscribe(n),o)}return new R(i.subscribe(n),o)})},se.amb=function(t){var e=this;return new Ae(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 R(c,a)})},fe.amb=function(){function t(t,e){return t.amb(e)}for(var e=me(),n=h(arguments,0),r=0,i=n.length;i>r;r++)e=t(e,n[r]);return e},se.catchException=function(t){return"function"==typeof t?d(this,t):ge([this,t])};var ge=fe.catchException=function(){var t=h(arguments,0);return re(t).catchException()};se.combineLatest=function(){var t=x.call(arguments);return Array.isArray(t[0])?t[0].unshift(this):t.unshift(this),Ee.apply(this,t)};var Ee=fe.combineLatest=function(){var t=x.call(arguments),n=t.pop();return Array.isArray(t[0])&&(t=t[0]),new Ae(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 R(p)})};se.concat=function(){var t=x.call(arguments,0);return t.unshift(this),xe.apply(this,t)};var xe=fe.concat=function(){var t=h(arguments,0);return re(t).concat()};se.concatObservable=se.concatAll=function(){return this.merge(1)},se.merge=function(t){if("number"!=typeof t)return Ce(this,t);var e=this;return new Ae(function(n){var r=0,i=new R,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 Ce=fe.merge=function(){var t,e;return arguments[0]?arguments[0].now?(t=arguments[0],e=x.call(arguments,1)):(t=F,e=x.call(arguments,0)):(t=F,e=x.call(arguments,1)),Array.isArray(e[0])&&(e=e[0]),ve(e,t).mergeObservable()};se.mergeObservable=se.mergeAll=function(){var t=this;return new Ae(function(e){var n=new R,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})},se.onErrorResumeNext=function(t){if(!t)throw Error("Second observable is required");return De([this,t])};var De=fe.onErrorResumeNext=function(){var t=h(arguments,0);return new Ae(function(e){var n=0,r=new P,i=F.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 R(r,i)})};se.skipUntil=function(t){var e=this;return new Ae(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 I;return i.add(o),o.setDisposable(t.subscribe(function(){r=!0,o.dispose()},n.onError.bind(n),function(){o.dispose()})),i})},se.switchLatest=function(){var t=this;return new Ae(function(e){var n=!1,r=new P,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 R(s,r)})},se.takeUntil=function(t){var e=this;return new Ae(function(r){return new R(e.subscribe(r),t.subscribe(r.onCompleted.bind(r),r.onError.bind(r),n))})},se.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 Ae(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 R(h)})},fe.zip=function(t,e){var n=t[0],r=t.slice(1);return r.push(e),n.zip.apply(n,r)},se.asObservable=function(){var t=this;return new Ae(function(e){return t.subscribe(e)})},se.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})},se.dematerialize=function(){var t=this;return new Ae(function(e){return t.subscribe(function(t){return t.accept(e)},e.onError.bind(e),e.onCompleted.bind(e))})},se.distinctUntilChanged=function(t,n){var i=this;return t||(t=r),n||(n=o),new Ae(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))})},se.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 Ae(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()})})},se.finallyAction=function(t){var e=this;return new Ae(function(n){var r=e.subscribe(n);return T(function(){try{r.dispose()}catch(e){throw e}finally{t()}})})},se.ignoreElements=function(){var t=this;return new Ae(function(e){return t.subscribe(n,e.onError.bind(e),e.onCompleted.bind(e))})},se.materialize=function(){var t=this;return new Ae(function(e){return t.subscribe(function(t){e.onNext(X(t))},function(t){e.onNext(Y(t)),e.onCompleted()},function(){e.onNext(Z()),e.onCompleted()})})},se.repeat=function(t){return ne(this,t).concat()},se.retry=function(t){return ne(this,t).catchException()},se.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 de(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})})},se.skipLast=function(t){var e=this;return new Ae(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))})},se.startWith=function(){var t,n,r=0;return arguments.length>0&&null!=arguments[0]&&arguments[0].now!==e?(n=arguments[0],r=1):n=F,t=x.call(arguments,r),re([ve(t,n),this]).concat()},se.takeLast=function(t,e){return this.takeLastBuffer(t).selectMany(function(t){return ve(t,e)})},se.takeLastBuffer=function(t){var e=this;return new Ae(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()})})},se.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 Ae(function(r){var i=new I,o=new L(i),s=0,u=[],c=function(){var t=new We;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})},se.defaultIfEmpty=function(t){var n=this;return t===e&&(t=null),new Ae(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()})})},se.distinct=function(t,n){var i=this;return t||(t=r),n||(n=u),new Ae(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))})},se.groupBy=function(t,e,n){return this.groupByUntil(t,e,function(){return me()},n)},se.groupByUntil=function(t,i,o,s){var c=this;return i||(i=r),s||(s=u),new Ae(function(r){var u={},a=new R,h=new L(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 _e(m,g,h),f=new _e(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})},se.select=function(t,n){var r=this;return new Ae(function(i){var o=0;return r.subscribe(function(s){var u;try{u=t.call(n,s,o++,r)}catch(c){return i.onError(c),e}i.onNext(u)},i.onError.bind(i),i.onCompleted.bind(i))})},se.map=se.select,se.selectMany=se.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})},se.skip=function(t){if(0>t)throw Error(g);var e=this;return new Ae(function(n){var r=t;return e.subscribe(function(t){0>=r?n.onNext(t):r--},n.onError.bind(n),n.onCompleted.bind(n))})},se.skipWhile=function(t){var n=this;return new Ae(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))})},se.take=function(t,e){if(0>t)throw Error(g);if(0===t)return be(e);var n=this;return new Ae(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))})},se.takeWhile=function(t){var n=this;return new Ae(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))})},se.where=function(t,n){var r=this;return new Ae(function(i){var o=0;return r.subscribe(function(s){var u;try{u=t.call(n,s,o++,r)}catch(c){return i.onError(c),e}u&&i.onNext(s)},i.onError.bind(i),i.onCompleted.bind(i))})},se.filter=se.where;var Ae=y.Internals.AnonymousObservable=function(t){function e(e){function n(t){var n=new Se(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}(fe),Se=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}(ue),_e=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 Ae(function(t){return new R(i.getDisposable(),r.subscribe(t))}):r}return C(n,t),n}(fe),Ne=function(t,e){this.subject=t,this.observer=e};Ne.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=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 Ne(this,t))}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.observers=[]}return C(n,t),D(n.prototype,ie,{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}(fe),Oe=y.AsyncSubject=function(t){function e(t){if(a.call(this),!this.isStopped)return this.observers.push(t),new Ne(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,ie,{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}(fe),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,ie,{onCompleted:function(){this.observer.onCompleted()},onError:function(t){this.observer.onError(t)},onNext:function(t){this.observer.onNext(t)}}),n}(fe);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); | ||
(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(x)}function h(t,e){return 1===t.length&&Array.isArray(t[e])?t[e]:C.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 M}function d(t,n){return new Se(function(r){var i=new M,o=new L;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 M,o.setDisposable(i),i.setDisposable(s.subscribe(r))},r.onCompleted.bind(r))),o})}function b(t,n){var r=this;return new Se(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,y=("object"==typeof module&&module&&module.exports==m&&module,"object"==typeof global&&global);y.global===y&&(t=y);var w={Internals:{}},g="Sequence contains no elements.",E="Argument out of range",x="Object has been disposed",C=Array.prototype.slice;({}).hasOwnProperty;var D=this.inherits=w.Internals.inherits=function(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n},A=w.Internals.addProperties=function(t){for(var e=C.call(arguments,1),n=0,r=e.length;r>n;n++){var i=e[n];for(var o in i)t[o]=i[o]}},S=w.Internals.addRef=function(t,e){return new Se(function(n){return new k(e.getDisposable(),t.subscribe(n))})};Function.prototype.bind||(Function.prototype.bind=function(t){var e=this,n=C.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(C.call(arguments)));return Object(s)===s?s:o}return e.apply(t,n.concat(C.call(arguments)))};return r});var _=Object("a"),N="a"!=_[0]||!(0 in _);Array.prototype.every||(Array.prototype.every=function(t){var e=Object(this),n=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=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 O=function(t,e){this.id=t,this.value=e};O.prototype.compareTo=function(t){var e=this.value.compareTo(t.value);return 0===e&&(e=this.id-t.id),e};var W=function(t){this.items=Array(t),this.length=0},R=W.prototype;R.isHigherPriority=function(t,e){return 0>this.items[t].compareTo(this.items[e])},R.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)}}},R.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)}}},R.peek=function(){return this.items[0].value},R.removeAt=function(t){this.items[t]=this.items[--this.length],delete this.items[this.length],this.heapify()},R.dequeue=function(){var t=this.peek();return this.removeAt(0),t},R.enqueue=function(t){var e=this.length++;this.items[e]=new O(W.count++,t),this.percolate(e)},R.remove=function(t){for(var e=0;this.length>e;e++)if(this.items[e].value===t)return this.removeAt(e),!0;return!1},W.count=0;var k=w.CompositeDisposable=function(){this.disposables=h(arguments,0),this.isDisposed=!1,this.length=this.disposables.length},j=k.prototype;j.add=function(t){this.isDisposed?t.dispose():(this.disposables.push(t),this.length++)},j.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},j.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()}},j.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()},j.contains=function(t){return-1!==this.disposables.indexOf(t)},j.toArray=function(){return this.disposables.slice(0)};var q=w.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)},I=q.empty={dispose:n},M=w.SingleAssignmentDisposable=function(){this.isDisposed=!1,this.current=null},P=M.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 L=w.SerialDisposable=function(){this.isDisposed=!1,this.current=null};L.prototype.getDisposable=function(){return this.current},L.prototype.setDisposable=function(t){var e,n=this.isDisposed;n||(e=this.current,this.current=t),e&&e.dispose(),n&&t&&t.dispose()},L.prototype.disposable=function(t){return t?(this.setDisposable(t),e):this.getDisposable()},L.prototype.dispose=function(){var t;this.isDisposed||(this.isDisposed=!0,t=this.current,this.current=null),t&&t.dispose()};var V=w.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?I: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=w.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 k,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),I});r||(i.add(s),n=!0)})};return o(n),i}function r(t,e,n){var r=e.first,i=e.second,o=new k,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),I});u||(o.add(c),i=!0)})};return s(r),o}function o(t,e){return e(),I}var s=e.prototype;return s.catchException=function(t){return new Q(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}(),F="Scheduler is not allowed to block the thread",B=z.immediate=function(){function t(t,e){return e(this,t)}function e(t,e,n){if(e>0)throw Error(F);return n(this,t)}function n(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new z(i,t,e,n)}(),H=z.currentThread=function(){function t(){o=new W(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}(),U=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 M;return this._cancel=e,e.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,t.bind(this))),e},e}();w.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(),I}function u(e,s){this.clock=e,this.comparer=s,this.isEnabled=!1,this.queue=new W(1024),t.call(this,n,r,i,o)}D(u,t);var c=u.prototype;return c.schedulePeriodicWithState=function(t,e,n){var r=new U(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(E);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(E);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(E);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),w.HistoricalScheduler=function(t){function e(e,n){var r=null==e?0:e,i=n||s;t.call(this,r,i)}D(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}(w.VirtualTimeScheduler);var G,J=n;(function(){function e(){if(!t.postMessage||t.importScripts)return!1;var e=!1,n=t.onmessage;return t.onmessage=function(){e=!0},t.postMessage("","*"),t.onmessage=n,e}function n(t){if("string"==typeof t.data&&t.data.substring(0,r.length)===r){var e=t.data.substring(r.length),n=i[e];n(),delete i[e]}}if("object"==typeof t.process&&"[object process]"===Object.prototype.toString.call(t.process))G=t.process.nextTick;else if("function"==typeof t.setImmediate)G=t.setImmediate,J=t.clearImmediate;else if(e()){var r="ms.rx.schedule"+Math.random(),i={},o=0;t.addEventListener?t.addEventListener("message",n,!1):t.attachEvent("onmessage",n,!1),G=function(e){var n=o++;i[n]=e,t.postMessage(r+n,"*")}}else if(t.MessageChannel){var s=new t.MessageChannel,u={},c=0;s.port1.onmessage=function(t){var e=t.data,n=u[e];n(),delete u[e]},G=function(t){var e=c++;u[e]=t,s.port2.postMessage(e)}}else"document"in t&&"onreadystatechange"in t.document.createElement("script")?G=function(e){var n=t.document.createElement("script");n.onreadystatechange=function(){e(),n.onreadystatechange=null,n.parentNode.removeChild(n),n=null},t.document.documentElement.appendChild(n)}:(G=function(e){return t.setTimeout(e,0)},J=t.clearTimeout)})();var K=z.timeout=function(){function e(t,e){var n=this,r=new M,i=G(function(){r.isDisposed||r.setDisposable(e(n,t))});return new k(r,T(function(){J(i)}))}function n(e,n,r){var i=this,o=z.normalize(n);if(0===o)return i.scheduleWithState(e,r);var s=new M,u=t.setTimeout(function(){s.isDisposed||s.setDisposable(r(i,e))},o);return new k(s,T(function(){t.clearTimeout(u)}))}function r(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new z(i,e,n,r)}(),Q=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 D(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 I}}},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 M;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),X=w.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||B,new Se(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}(),Y=X.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 X("N",!0);return i.value=r,i._accept=t.bind(i),i._acceptObservable=e.bind(i),i.toString=n.bind(i),i}}(),Z=X.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 X("E");return i.exception=r,i._accept=t.bind(i),i._acceptObservable=e.bind(i),i.toString=n.bind(i),i}}(),$=X.createOnCompleted=function(){function t(t,e,n){return n()}function e(t){return t.onCompleted()}function n(){return"OnCompleted()"}return function(){var r=new X("C");return r._accept=t.bind(r),r._acceptObservable=e.bind(r),r.toString=n.bind(r),r}}(),te=w.Internals.Enumerator=function(t,e,n){this.moveNext=t,this.getCurrent=e,this.dispose=n},ee=te.create=function(t,e,r){var i=!1;return r||(r=n),new te(function(){if(i)return!1;var e=t();return e||(i=!0,r()),e},function(){return e()},function(){i||(r(),i=!0)})},ne=w.Internals.Enumerable=function(){function t(t){this.getEnumerator=t}return t.prototype.concat=function(){var t=this;return new Se(function(n){var r=t.getEnumerator(),i=!1,o=new L,s=B.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 M;o.setDisposable(h),h.setDisposable(s.subscribe(n.onNext.bind(n),n.onError.bind(n),function(){t()}))}});return new k(o,s,T(function(){i=!0,r.dispose()}))})},t.prototype.catchException=function(){var t=this;return new Se(function(n){var r,i=t.getEnumerator(),o=!1,s=new L,u=B.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 M;s.setDisposable(l),l.setDisposable(u.subscribe(n.onNext.bind(n),function(e){r=e,t()},n.onCompleted.bind(n)))}});return new k(s,u,T(function(){o=!0}))})},t}(),re=ne.repeat=function(t,n){return n===e&&(n=-1),new ne(function(){var e,r=n;return ee(function(){return 0===r?!1:(r>0&&r--,e=t,!0)},function(){return e})})},ie=ne.forEach=function(t,e){return e||(e=r),new ne(function(){var n,r=-1;return ee(function(){return++r<t.length?(n=e(t[r],r),!0):!1},function(){return n})})},oe=w.Observer=function(){};oe.prototype.toNotifier=function(){var t=this;return function(e){return e.accept(t)}},oe.prototype.asObserver=function(){return new ae(this.onNext.bind(this),this.onError.bind(this),this.onCompleted.bind(this))},oe.prototype.checked=function(){return new he(this)};var se=oe.create=function(t,e,r){return t||(t=n),e||(e=c),r||(r=n),new ae(t,e,r)};oe.fromNotifier=function(t){return new ae(function(e){return t(Y(e))},function(e){return t(Z(e))},function(){return t($())})};var ue,ce=w.Internals.AbstractObserver=function(t){function e(){this.isStopped=!1,t.call(this)}return D(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}(oe),ae=w.AnonymousObserver=function(t){function e(e,n,r){t.call(this),this._onNext=e,this._onError=n,this._onCompleted=r}return D(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}(ce),he=function(t){function e(e){t.call(this),this._observer=e,this._state=0}D(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}(oe),le=w.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 L}return D(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}(ce),fe=function(t){function e(){t.apply(this,arguments)}return D(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}(le),pe=w.Observable=function(){function t(t){this._subscribe=t}return ue=t.prototype,ue.finalValue=function(){var t=this;return new Se(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(g))})})},ue.subscribe=ue.forEach=function(t,e,n){var r;return r="object"==typeof t?t:se(t,e,n),this._subscribe(r)},ue.toArray=function(){function t(t,e){var n=t.slice(0);return n.push(e),n}return this.scan([],t).startWith([]).finalValue()},t}();pe.start=function(t,e){return de(t,e)()};var de=pe.toAsync=function(t,n,r){return n||(n=K),function(){var i=C.call(arguments,0),o=new Re;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()}};ue.observeOn=function(t){var e=this;return new Se(function(n){return e.subscribe(new fe(t,n))})},ue.subscribeOn=function(t){var e=this;return new Se(function(n){var r=new M,i=new L;return i.setDisposable(r),r.setDisposable(t.schedule(function(){i.setDisposable(new f(t,e.subscribe(n)))})),i})},pe.create=function(t){return new Se(function(e){return T(t(e))})},pe.createWithDisposable=function(t){return new Se(t)};var be=pe.defer=function(t){return new Se(function(e){var n;try{n=t()}catch(r){return ge(r).subscribe(e)}return n.subscribe(e)})},ve=pe.empty=function(t){return t||(t=B),new Se(function(e){return t.schedule(function(){e.onCompleted()})})},me=pe.fromArray=function(t,e){return e||(e=H),new Se(function(n){var r=0;return e.scheduleRecursive(function(e){t.length>r?(n.onNext(t[r++]),e()):n.onCompleted()})})};pe.generate=function(t,n,r,i,o){return o||(o=H),new Se(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 ye=pe.never=function(){return new Se(function(){return I})};pe.range=function(t,e,n){return n||(n=H),new Se(function(r){return n.scheduleRecursiveWithState(0,function(n,i){e>n?(r.onNext(t+n),i(n+1)):r.onCompleted()})})},pe.repeat=function(t,e,n){return n||(n=H),null==e&&(e=-1),we(t,n).repeat(e)};var we=pe.returnValue=function(t,e){return e||(e=B),new Se(function(n){return e.schedule(function(){n.onNext(t),n.onCompleted()})})},ge=pe.throwException=function(t,e){return e||(e=B),new Se(function(n){return e.schedule(function(){n.onError(t)})})};pe.using=function(t,e){return new Se(function(n){var r,i,o=I;try{r=t(),r&&(o=r),i=e(r)}catch(s){return new k(ge(s).subscribe(n),o)}return new k(i.subscribe(n),o)})},ue.amb=function(t){var e=this;return new Se(function(n){function r(){o||(o=s,a.dispose())}function i(){o||(o=u,c.dispose())}var o,s="L",u="R",c=new M,a=new M;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 k(c,a)})},pe.amb=function(){function t(t,e){return t.amb(e)}for(var e=ye(),n=h(arguments,0),r=0,i=n.length;i>r;r++)e=t(e,n[r]);return e},ue.catchException=function(t){return"function"==typeof t?d(this,t):Ee([this,t])};var Ee=pe.catchException=function(){var t=h(arguments,0);return ie(t).catchException()};ue.combineLatest=function(){var t=C.call(arguments);return Array.isArray(t[0])?t[0].unshift(this):t.unshift(this),xe.apply(this,t)};var xe=pe.combineLatest=function(){var t=C.call(arguments),n=t.pop();return Array.isArray(t[0])&&(t=t[0]),new Se(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 M,p[e].setDisposable(t[e].subscribe(function(t){f[e]=t,i(e)},r.onError.bind(r),function(){o(e)}))})(d);return new k(p)})};ue.concat=function(){var t=C.call(arguments,0);return t.unshift(this),Ce.apply(this,t)};var Ce=pe.concat=function(){var t=h(arguments,0);return ie(t).concat()};ue.concatObservable=ue.concatAll=function(){return this.merge(1)},ue.merge=function(t){if("number"!=typeof t)return De(this,t);var e=this;return new Se(function(n){var r=0,i=new k,o=!1,s=[],u=function(t){var e=new M;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 De=pe.merge=function(){var t,e;return arguments[0]?arguments[0].now?(t=arguments[0],e=C.call(arguments,1)):(t=B,e=C.call(arguments,0)):(t=B,e=C.call(arguments,1)),Array.isArray(e[0])&&(e=e[0]),me(e,t).mergeObservable()};ue.mergeObservable=ue.mergeAll=function(){var t=this;return new Se(function(e){var n=new k,r=!1,i=new M;return n.add(i),i.setDisposable(t.subscribe(function(t){var i=new M;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})},ue.onErrorResumeNext=function(t){if(!t)throw Error("Second observable is required");return Ae([this,t])};var Ae=pe.onErrorResumeNext=function(){var t=h(arguments,0);return new Se(function(e){var n=0,r=new L,i=B.scheduleRecursive(function(i){var o,s;t.length>n?(o=t[n++],s=new M,r.setDisposable(s),s.setDisposable(o.subscribe(e.onNext.bind(e),function(){i()},function(){i()}))):e.onCompleted()});return new k(r,i)})};ue.skipUntil=function(t){var e=this;return new Se(function(n){var r=!1,i=new k(e.subscribe(function(t){r&&n.onNext(t)},n.onError.bind(n),function(){r&&n.onCompleted()})),o=new M;return i.add(o),o.setDisposable(t.subscribe(function(){r=!0,o.dispose()},n.onError.bind(n),function(){o.dispose()})),i})},ue.switchLatest=function(){var t=this;return new Se(function(e){var n=!1,r=new L,i=!1,o=0,s=t.subscribe(function(t){var s=new M,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 k(s,r)})},ue.takeUntil=function(t){var e=this;return new Se(function(r){return new k(e.subscribe(r),t.subscribe(r.onCompleted.bind(r),r.onError.bind(r),n))})},ue.zip=function(){if(Array.isArray(arguments[0]))return b.apply(this,arguments);var t=this,n=C.call(arguments),i=n.pop();return n.unshift(t),new Se(function(o){function s(t){a[t]=!0,a.every(function(t){return t})&&o.onCompleted()}for(var u=n.length,c=l(u,function(){return[]}),a=l(u,function(){return!1}),h=function(n){var s,u;if(c.every(function(t){return t.length>0})){try{u=c.map(function(t){return t.shift()}),s=i.apply(t,u)}catch(h){return o.onError(h),e}o.onNext(s)}else a.filter(function(t,e){return e!==n}).every(r)&&o.onCompleted()},f=Array(u),p=0;u>p;p++)(function(t){f[t]=new M,f[t].setDisposable(n[t].subscribe(function(e){c[t].push(e),h(t)},o.onError.bind(o),function(){s(t)}))})(p);return new k(f)})},pe.zip=function(){var t=C.call(arguments,0),e=t.shift();return e.zip.apply(e,t)},pe.zipArray=function(){var t=C.call(arguments);return new Se(function(n){function i(t){if(u.every(function(t){return t.length>0})){var i=u.map(function(t){return t.shift()});n.onNext(i)}else if(c.filter(function(e,n){return n!==t}).every(r))return n.onCompleted(),e}function o(t){return c[t]=!0,c.every(r)?(n.onCompleted(),e):e}for(var s=t.length,u=l(s,function(){return[]}),c=l(s,function(){return!1}),a=Array(s),h=0;s>h;h++)(function(e){a[e]=new M,a[e].setDisposable(t[e].subscribe(function(t){u[e].push(t),i(e)},n.onError.bind(n),function(){o(e)}))})(h);var f=new k(a);return f.add(T(function(){for(var t=0,e=u.length;e>t;t++)u[t]=[]})),f})},ue.asObservable=function(){var t=this;return new Se(function(e){return t.subscribe(e)})},ue.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})},ue.dematerialize=function(){var t=this;return new Se(function(e){return t.subscribe(function(t){return t.accept(e)},e.onError.bind(e),e.onCompleted.bind(e))})},ue.distinctUntilChanged=function(t,n){var i=this;return t||(t=r),n||(n=o),new Se(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))})},ue.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 Se(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()})})},ue.finallyAction=function(t){var e=this;return new Se(function(n){var r=e.subscribe(n);return T(function(){try{r.dispose()}catch(e){throw e}finally{t()}})})},ue.ignoreElements=function(){var t=this; | ||
return new Se(function(e){return t.subscribe(n,e.onError.bind(e),e.onCompleted.bind(e))})},ue.materialize=function(){var t=this;return new Se(function(e){return t.subscribe(function(t){e.onNext(Y(t))},function(t){e.onNext(Z(t)),e.onCompleted()},function(){e.onNext($()),e.onCompleted()})})},ue.repeat=function(t){return re(this,t).concat()},ue.retry=function(t){return re(this,t).catchException()},ue.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 be(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})})},ue.skipLast=function(t){var e=this;return new Se(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))})},ue.startWith=function(){var t,e,n=0;return arguments.length&&"now"in Object(arguments[0])?(e=arguments[0],n=1):e=B,t=C.call(arguments,n),ie([me(t,e),this]).concat()},ue.takeLast=function(t,e){return this.takeLastBuffer(t).selectMany(function(t){return me(t,e)})},ue.takeLastBuffer=function(t){var e=this;return new Se(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()})})},ue.windowWithCount=function(t,e){var n=this;if(0>=t)throw Error(E);if(null==e&&(e=t),0>=e)throw Error(E);return new Se(function(r){var i=new M,o=new V(i),s=0,u=[],c=function(){var t=new We;u.push(t),r.onNext(S(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})},ue.defaultIfEmpty=function(t){var n=this;return t===e&&(t=null),new Se(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()})})},ue.distinct=function(t,n){var i=this;return t||(t=r),n||(n=u),new Se(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))})},ue.groupBy=function(t,e,n){return this.groupByUntil(t,e,function(){return ye()},n)},ue.groupByUntil=function(t,i,o,s){var c=this;return i||(i=r),s||(s=u),new Se(function(r){var u={},a=new k,h=new V(a);return a.add(c.subscribe(function(c){var l,f,p,d,b,v,m,y,w,g;try{v=t(c),m=s(v)}catch(E){for(g in u)u[g].onError(E);return r.onError(E),e}d=!1;try{w=u[m],w||(w=new We,u[m]=w,d=!0)}catch(E){for(g in u)u[g].onError(E);return r.onError(E),e}if(d){b=new Ne(v,w,h),f=new Ne(v,w);try{l=o(f)}catch(E){for(g in u)u[g].onError(E);return r.onError(E),e}r.onNext(b),y=new M,a.add(y);var x=function(){m in u&&(delete u[m],w.onCompleted()),a.remove(y)};y.setDisposable(l.take(1).subscribe(n,function(t){for(g in u)u[g].onError(t);r.onError(t)},function(){x()}))}try{p=i(c)}catch(E){for(g in u)u[g].onError(E);return r.onError(E),e}w.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})},ue.select=function(t,n){var r=this;return new Se(function(i){var o=0;return r.subscribe(function(s){var u;try{u=t.call(n,s,o++,r)}catch(c){return i.onError(c),e}i.onNext(u)},i.onError.bind(i),i.onCompleted.bind(i))})},ue.map=ue.select,ue.selectMany=ue.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})},ue.skip=function(t){if(0>t)throw Error(E);var e=this;return new Se(function(n){var r=t;return e.subscribe(function(t){0>=r?n.onNext(t):r--},n.onError.bind(n),n.onCompleted.bind(n))})},ue.skipWhile=function(t){var n=this;return new Se(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))})},ue.take=function(t,e){if(0>t)throw Error(E);if(0===t)return ve(e);var n=this;return new Se(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))})},ue.takeWhile=function(t){var n=this;return new Se(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))})},ue.where=function(t,n){var r=this;return new Se(function(i){var o=0;return r.subscribe(function(s){var u;try{u=t.call(n,s,o++,r)}catch(c){return i.onError(c),e}u&&i.onNext(s)},i.onError.bind(i),i.onCompleted.bind(i))})},ue.filter=ue.where;var Se=w.Internals.AnonymousObservable=function(t){function n(r){function i(t){var e=new _e(t);if(H.scheduleRequired())H.schedule(function(){try{e.disposable(r(e))}catch(t){if(!e.fail(t))throw t}});else try{e.disposable(r(e))}catch(n){if(!e.fail(n))throw n}return e}return this instanceof n?(t.call(this,i),e):new n(r)}return D(n,t),n}(pe),_e=function(t){function e(e){t.call(this),this.observer=e,this.m=new M}D(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}(ce),Ne=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 Se(function(t){return new k(i.getDisposable(),r.subscribe(t))}):r}return D(n,t),n}(pe),Oe=function(t,e){this.subject=t,this.observer=e};Oe.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=w.Subject=function(t){function e(t){return a.call(this),this.isStopped?this.exception?(t.onError(this.exception),I):(t.onCompleted(),I):(this.observers.push(t),new Oe(this,t))}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.observers=[]}return D(n,t),A(n.prototype,oe,{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 ke(t,e)},n}(pe),Re=w.AsyncSubject=function(t){function e(t){if(a.call(this),!this.isStopped)return this.observers.push(t),new Oe(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(),I}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.value=null,this.hasValue=!1,this.observers=[],this.exception=null}return D(n,t),A(n.prototype,oe,{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}(pe),ke=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 D(n,t),A(n.prototype,oe,{onCompleted:function(){this.observer.onCompleted()},onError:function(t){this.observer.onError(t)},onNext:function(t){this.observer.onNext(t)}}),n}(pe);return"function"==typeof define&&"object"==typeof define.amd&&define.amd?(t.Rx=w,define(function(){return w})):(m?"object"==typeof module&&module&&module.exports==m?module.exports=w:m=w:t.Rx=w,e)})(this); |
@@ -1,2 +0,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(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 Ce(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 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 W(e.getDisposable(),t.subscribe(n))})},S=function(t,e){this.id=t,this.value=e};S.prototype.compareTo=function(t){var e=this.value.compareTo(t.value);return 0===e&&(e=this.id-t.id),e};var _=function(t){this.items=Array(t),this.length=0},N=_.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},_.count=0;var W=y.CompositeDisposable=function(){this.disposables=h(arguments,0),this.isDisposed=!1,this.length=this.disposables.length},R=W.prototype;R.add=function(t){this.isDisposed?t.dispose():(this.disposables.push(t),this.length++)},R.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},R.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()}},R.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()},R.contains=function(t){return-1!==this.disposables.indexOf(t)},R.toArray=function(){return this.disposables.slice(0)};var O=y.Disposable=function(t){this.isDisposed=!1,this.action=t};O.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var k=O.create=function(t){return new O(t)},q=O.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 M=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 W,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 W,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 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 k(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}(),L="Scheduler is not allowed to block the thread",V=M.immediate=function(){function t(t,e){return e(this,t)}function e(t,e,n){if(e>0)throw Error(L);return n(this,t)}function n(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new M(i,t,e,n)}(),z=M.currentThread=function(){function t(){o=new _(4)}function e(t,e){return this.scheduleWithRelativeAndState(t,0,e)}function n(e,n,r){var i,s=this.now()+M.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-M.now()>0;);t.isCancelled()||t.invoke()}};var s=new M(i,e,n,r);return s.scheduleRequired=function(){return null===o},s.ensureTrampoline=function(t){return null===o?this.schedule(t):t()},s}(),B=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 _(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 B(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}(M),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 F,H=n;(function(){function n(){if(!t.postMessage||t.importScripts)return!1;var e=!1,n=t.onmessage;return t.onmessage=function(){e=!0},t.postMessage("","*"),t.onmessage=n,e}function r(t){if("string"==typeof t.data&&t.data.substring(0,i.length)===i){var e=t.data.substring(i.length),n=o[e];n(),delete o[e]}}if(t.process!==e&&"[object process]"===Object.prototype.toString.call(t.process))F=t.process.nextTick;else if("function"==typeof t.setImmediate)F=t.setImmediate,H=t.clearImmediate;else if(n()){var i="ms.rx.schedule"+Math.random(),o={},s=0;t.addEventListener?t.addEventListener("message",r,!1):t.attachEvent("onmessage",r,!1),F=function(e){var n=s++;o[n]=e,t.postMessage(i+n,"*")}}else if(t.MessageChannel){var u=new t.MessageChannel,c={},a=0;u.port1.onmessage=function(t){var e=t.data,n=c[e];n(),delete c[e]},F=function(t){var e=a++;c[e]=t,u.port2.postMessage(e)}}else"document"in t&&"onreadystatechange"in t.document.createElement("script")?F=function(e){var n=t.document.createElement("script");n.onreadystatechange=function(){e(),n.onreadystatechange=null,n.parentNode.removeChild(n),n=null},t.document.documentElement.appendChild(n)}:(F=function(e){return t.setTimeout(e,0)},H=t.clearTimeout)})();var U=M.timeout=function(){function e(t,e){var n=this,r=new T,i=F(function(){r.isDisposed||r.setDisposable(e(n,t))});return new W(r,k(function(){H(i)}))}function n(e,n,r){var i=this,o=M.normalize(n);if(0===o)return i.scheduleWithState(e,r);var s=new T,u=t.setTimeout(function(){s.isDisposed||s.setDisposable(r(i,e))},o);return new W(s,k(function(){t.clearTimeout(u)}))}function r(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new M(i,e,n,r)}(),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 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}(M),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||V,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 I,s=V.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 W(o,s,k(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 I,u=V.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 W(s,u,k(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 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}(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 T,i=new I;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 k(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=V),new Ce(function(e){return t.schedule(function(){e.onCompleted()})})},de=he.fromArray=function(t,e){return e||(e=z),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=z),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 q})};he.range=function(t,e,n){return n||(n=z),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=z),n==e&&(n=-1),ve(t,r).repeat(n)};var ve=he.returnValue=function(t,e){return e||(e=V),new Ce(function(n){return e.schedule(function(){n.onNext(t),n.onCompleted()})})},me=he.throwException=function(t,e){return e||(e=V),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=q;try{r=t(),r&&(o=r),i=e(r)}catch(s){return new W(me(s).subscribe(n),o)}return new W(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 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 W(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 T,p[e].setDisposable(t[e].subscribe(function(t){f[e]=t,i(e)},r.onError.bind(r),function(){o(e)}))})(d);return new W(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 W,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 Ee=he.merge=function(){var t,e;return arguments[0]?arguments[0].now?(t=arguments[0],e=x.call(arguments,1)):(t=V,e=x.call(arguments,0)):(t=V,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 W,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})},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 I,i=V.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 W(r,i)})};ie.skipUntil=function(t){var e=this;return new Ce(function(n){var r=!1,i=new W(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})},ie.switchLatest=function(){var t=this;return new Ce(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 W(s,r)})},ie.takeUntil=function(t){var e=this;return new Ce(function(r){return new W(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 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 W(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 k(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=V,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 T,o=new P(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 W,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 _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 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})},ie.select=function(t,n){var r=this;return new Ce(function(i){var o=0;return r.subscribe(function(s){var u;try{u=t.call(n,s,o++,r)}catch(c){return i.onError(c),e}i.onNext(u)},i.onError.bind(i),i.onCompleted.bind(i))})},ie.map=ie.select,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=function(t,n){var r=this;return new Ce(function(i){var o=0;return r.subscribe(function(s){var u;try{u=t.call(n,s,o++,r)}catch(c){return i.onError(c),e}u&&i.onNext(s)},i.onError.bind(i),i.onCompleted.bind(i))})},ie.filter=ie.where;var Ce=y.Internals.AnonymousObservable=function(t){function e(e){function n(t){var n=new De(t);if(z.scheduleRequired())z.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 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}(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 W(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),q):(t.onCompleted(),q):(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 We(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(),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,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),We=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); | ||
(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(x)}function h(t,e){return 1===t.length&&Array.isArray(t[e])?t[e]:C.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 j}function d(t,n){return new De(function(r){var i=new j,o=new P;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 j,o.setDisposable(i),i.setDisposable(s.subscribe(r))},r.onCompleted.bind(r))),o})}function b(t,n){var r=this;return new De(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,y=("object"==typeof module&&module&&module.exports==m&&module,"object"==typeof global&&global);y.global===y&&(t=y);var w={Internals:{}},g="Sequence contains no elements.",E="Argument out of range",x="Object has been disposed",C=Array.prototype.slice;({}).hasOwnProperty;var D=this.inherits=w.Internals.inherits=function(t,e){function n(){this.constructor=t}n.prototype=e.prototype,t.prototype=new n},A=w.Internals.addProperties=function(t){for(var e=C.call(arguments,1),n=0,r=e.length;r>n;n++){var i=e[n];for(var o in i)t[o]=i[o]}},S=w.Internals.addRef=function(t,e){return new De(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 N=function(t){this.items=Array(t),this.length=0},W=N.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.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},N.count=0;var R=w.CompositeDisposable=function(){this.disposables=h(arguments,0),this.isDisposed=!1,this.length=this.disposables.length},O=R.prototype;O.add=function(t){this.isDisposed?t.dispose():(this.disposables.push(t),this.length++)},O.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},O.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()}},O.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()},O.contains=function(t){return-1!==this.disposables.indexOf(t)},O.toArray=function(){return this.disposables.slice(0)};var k=w.Disposable=function(t){this.isDisposed=!1,this.action=t};k.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var q=k.create=function(t){return new k(t)},T=k.empty={dispose:n},j=w.SingleAssignmentDisposable=function(){this.isDisposed=!1,this.current=null},I=j.prototype;I.disposable=function(t){return t?this.setDisposable(t):this.getDisposable()},I.getDisposable=function(){return this.current},I.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()},I.dispose=function(){var t;this.isDisposed||(this.isDisposed=!0,t=this.current,this.current=null),t&&t.dispose()};var P=w.SerialDisposable=function(){this.isDisposed=!1,this.current=null};P.prototype.getDisposable=function(){return this.current},P.prototype.setDisposable=function(t){var e,n=this.isDisposed;n||(e=this.current,this.current=t),e&&e.dispose(),n&&t&&t.dispose()},P.prototype.disposable=function(t){return t?(this.setDisposable(t),e):this.getDisposable()},P.prototype.dispose=function(){var t;this.isDisposed||(this.isDisposed=!0,t=this.current,this.current=null),t&&t.dispose()};var M=w.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?T: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 L=w.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),T});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),T});u||(o.add(c),i=!0)})};return s(r),o}function o(t,e){return e(),T}var s=e.prototype;return s.catchException=function(t){return new J(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 q(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",z=L.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 L(i,t,e,n)}(),B=L.currentThread=function(){function t(){o=new N(4)}function e(t,e){return this.scheduleWithRelativeAndState(t,0,e)}function n(e,n,r){var i,s=this.now()+L.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-L.now()>0;);t.isCancelled()||t.invoke()}};var s=new L(i,e,n,r);return s.scheduleRequired=function(){return null===o},s.ensureTrampoline=function(t){return null===o?this.schedule(t):t()},s}(),F=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 j;return this._cancel=e,e.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,t.bind(this))),e},e}();w.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(),T}function u(e,s){this.clock=e,this.comparer=s,this.isEnabled=!1,this.queue=new N(1024),t.call(this,n,r,i,o)}D(u,t);var c=u.prototype;return c.schedulePeriodicWithState=function(t,e,n){var r=new F(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(E);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(E);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(E);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}(L),w.HistoricalScheduler=function(t){function e(e,n){var r=null==e?0:e,i=n||s;t.call(this,r,i)}D(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}(w.VirtualTimeScheduler);var H,U=n;(function(){function e(){if(!t.postMessage||t.importScripts)return!1;var e=!1,n=t.onmessage;return t.onmessage=function(){e=!0},t.postMessage("","*"),t.onmessage=n,e}function n(t){if("string"==typeof t.data&&t.data.substring(0,r.length)===r){var e=t.data.substring(r.length),n=i[e];n(),delete i[e]}}if("object"==typeof t.process&&"[object process]"===Object.prototype.toString.call(t.process))H=t.process.nextTick;else if("function"==typeof t.setImmediate)H=t.setImmediate,U=t.clearImmediate;else if(e()){var r="ms.rx.schedule"+Math.random(),i={},o=0;t.addEventListener?t.addEventListener("message",n,!1):t.attachEvent("onmessage",n,!1),H=function(e){var n=o++;i[n]=e,t.postMessage(r+n,"*")}}else if(t.MessageChannel){var s=new t.MessageChannel,u={},c=0;s.port1.onmessage=function(t){var e=t.data,n=u[e];n(),delete u[e]},H=function(t){var e=c++;u[e]=t,s.port2.postMessage(e)}}else"document"in t&&"onreadystatechange"in t.document.createElement("script")?H=function(e){var n=t.document.createElement("script");n.onreadystatechange=function(){e(),n.onreadystatechange=null,n.parentNode.removeChild(n),n=null},t.document.documentElement.appendChild(n)}:(H=function(e){return t.setTimeout(e,0)},U=t.clearTimeout)})();var G=L.timeout=function(){function e(t,e){var n=this,r=new j,i=H(function(){r.isDisposed||r.setDisposable(e(n,t))});return new R(r,q(function(){U(i)}))}function n(e,n,r){var i=this,o=L.normalize(n);if(0===o)return i.scheduleWithState(e,r);var s=new j,u=t.setTimeout(function(){s.isDisposed||s.setDisposable(r(i,e))},o);return new R(s,q(function(){t.clearTimeout(u)}))}function r(t,e,n){return this.scheduleWithRelativeAndState(t,e-this.now(),n)}return new L(i,e,n,r)}(),J=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 D(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 T}}},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 j;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}(L),K=w.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||z,new De(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}(),Q=K.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 K("N",!0);return i.value=r,i._accept=t.bind(i),i._acceptObservable=e.bind(i),i.toString=n.bind(i),i}}(),X=K.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 K("E");return i.exception=r,i._accept=t.bind(i),i._acceptObservable=e.bind(i),i.toString=n.bind(i),i}}(),Y=K.createOnCompleted=function(){function t(t,e,n){return n()}function e(t){return t.onCompleted()}function n(){return"OnCompleted()"}return function(){var r=new K("C");return r._accept=t.bind(r),r._acceptObservable=e.bind(r),r.toString=n.bind(r),r}}(),Z=w.Internals.Enumerator=function(t,e,n){this.moveNext=t,this.getCurrent=e,this.dispose=n},$=Z.create=function(t,e,r){var i=!1;return r||(r=n),new Z(function(){if(i)return!1;var e=t();return e||(i=!0,r()),e},function(){return e()},function(){i||(r(),i=!0)})},te=w.Internals.Enumerable=function(){function t(t){this.getEnumerator=t}return t.prototype.concat=function(){var t=this;return new De(function(n){var r=t.getEnumerator(),i=!1,o=new P,s=z.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 j;o.setDisposable(h),h.setDisposable(s.subscribe(n.onNext.bind(n),n.onError.bind(n),function(){t()}))}});return new R(o,s,q(function(){i=!0,r.dispose()}))})},t.prototype.catchException=function(){var t=this;return new De(function(n){var r,i=t.getEnumerator(),o=!1,s=new P,u=z.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 j;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,q(function(){o=!0}))})},t}(),ee=te.repeat=function(t,n){return n===e&&(n=-1),new te(function(){var e,r=n;return $(function(){return 0===r?!1:(r>0&&r--,e=t,!0)},function(){return e})})},ne=te.forEach=function(t,e){return e||(e=r),new te(function(){var n,r=-1;return $(function(){return++r<t.length?(n=e(t[r],r),!0):!1},function(){return n})})},re=w.Observer=function(){};re.prototype.toNotifier=function(){var t=this;return function(e){return e.accept(t)}},re.prototype.asObserver=function(){return new ue(this.onNext.bind(this),this.onError.bind(this),this.onCompleted.bind(this))},re.prototype.checked=function(){return new ce(this)};var ie=re.create=function(t,e,r){return t||(t=n),e||(e=c),r||(r=n),new ue(t,e,r)};re.fromNotifier=function(t){return new ue(function(e){return t(Q(e))},function(e){return t(X(e))},function(){return t(Y())})};var oe,se=w.Internals.AbstractObserver=function(t){function e(){this.isStopped=!1,t.call(this)}return D(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}(re),ue=w.AnonymousObserver=function(t){function e(e,n,r){t.call(this),this._onNext=e,this._onError=n,this._onCompleted=r}return D(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}(se),ce=function(t){function e(e){t.call(this),this._observer=e,this._state=0}D(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}(re),ae=w.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 P}return D(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}(se),he=function(t){function e(){t.apply(this,arguments)}return D(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}(ae),le=w.Observable=function(){function t(t){this._subscribe=t}return oe=t.prototype,oe.finalValue=function(){var t=this;return new De(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(g))})})},oe.subscribe=oe.forEach=function(t,e,n){var r;return r="object"==typeof t?t:ie(t,e,n),this._subscribe(r)},oe.toArray=function(){function t(t,e){var n=t.slice(0);return n.push(e),n}return this.scan([],t).startWith([]).finalValue()},t}();le.start=function(t,e){return fe(t,e)()};var fe=le.toAsync=function(t,n,r){return n||(n=G),function(){var i=C.call(arguments,0),o=new We;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()}};oe.observeOn=function(t){var e=this;return new De(function(n){return e.subscribe(new he(t,n))})},oe.subscribeOn=function(t){var e=this;return new De(function(n){var r=new j,i=new P;return i.setDisposable(r),r.setDisposable(t.schedule(function(){i.setDisposable(new f(t,e.subscribe(n)))})),i})},le.create=function(t){return new De(function(e){return q(t(e))})},le.createWithDisposable=function(t){return new De(t)};var pe=le.defer=function(t){return new De(function(e){var n;try{n=t()}catch(r){return ye(r).subscribe(e)}return n.subscribe(e)})},de=le.empty=function(t){return t||(t=z),new De(function(e){return t.schedule(function(){e.onCompleted()})})},be=le.fromArray=function(t,e){return e||(e=B),new De(function(n){var r=0;return e.scheduleRecursive(function(e){t.length>r?(n.onNext(t[r++]),e()):n.onCompleted()})})};le.generate=function(t,n,r,i,o){return o||(o=B),new De(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 ve=le.never=function(){return new De(function(){return T})};le.range=function(t,e,n){return n||(n=B),new De(function(r){return n.scheduleRecursiveWithState(0,function(n,i){e>n?(r.onNext(t+n),i(n+1)):r.onCompleted()})})},le.repeat=function(t,e,n){return n||(n=B),null==e&&(e=-1),me(t,n).repeat(e)};var me=le.returnValue=function(t,e){return e||(e=z),new De(function(n){return e.schedule(function(){n.onNext(t),n.onCompleted()})})},ye=le.throwException=function(t,e){return e||(e=z),new De(function(n){return e.schedule(function(){n.onError(t)})})};le.using=function(t,e){return new De(function(n){var r,i,o=T;try{r=t(),r&&(o=r),i=e(r)}catch(s){return new R(ye(s).subscribe(n),o)}return new R(i.subscribe(n),o)})},oe.amb=function(t){var e=this;return new De(function(n){function r(){o||(o=s,a.dispose())}function i(){o||(o=u,c.dispose())}var o,s="L",u="R",c=new j,a=new j;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)})},le.amb=function(){function t(t,e){return t.amb(e)}for(var e=ve(),n=h(arguments,0),r=0,i=n.length;i>r;r++)e=t(e,n[r]);return e},oe.catchException=function(t){return"function"==typeof t?d(this,t):we([this,t])};var we=le.catchException=function(){var t=h(arguments,0);return ne(t).catchException()};oe.combineLatest=function(){var t=C.call(arguments);return Array.isArray(t[0])?t[0].unshift(this):t.unshift(this),ge.apply(this,t)};var ge=le.combineLatest=function(){var t=C.call(arguments),n=t.pop();return Array.isArray(t[0])&&(t=t[0]),new De(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 j,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)})};oe.concat=function(){var t=C.call(arguments,0);return t.unshift(this),Ee.apply(this,t)};var Ee=le.concat=function(){var t=h(arguments,0);return ne(t).concat()};oe.concatObservable=oe.concatAll=function(){return this.merge(1)},oe.merge=function(t){if("number"!=typeof t)return xe(this,t);var e=this;return new De(function(n){var r=0,i=new R,o=!1,s=[],u=function(t){var e=new j;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 xe=le.merge=function(){var t,e;return arguments[0]?arguments[0].now?(t=arguments[0],e=C.call(arguments,1)):(t=z,e=C.call(arguments,0)):(t=z,e=C.call(arguments,1)),Array.isArray(e[0])&&(e=e[0]),be(e,t).mergeObservable()};oe.mergeObservable=oe.mergeAll=function(){var t=this;return new De(function(e){var n=new R,r=!1,i=new j;return n.add(i),i.setDisposable(t.subscribe(function(t){var i=new j;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})},oe.onErrorResumeNext=function(t){if(!t)throw Error("Second observable is required");return Ce([this,t])};var Ce=le.onErrorResumeNext=function(){var t=h(arguments,0);return new De(function(e){var n=0,r=new P,i=z.scheduleRecursive(function(i){var o,s;t.length>n?(o=t[n++],s=new j,r.setDisposable(s),s.setDisposable(o.subscribe(e.onNext.bind(e),function(){i()},function(){i()}))):e.onCompleted()});return new R(r,i)})};oe.skipUntil=function(t){var e=this;return new De(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 j;return i.add(o),o.setDisposable(t.subscribe(function(){r=!0,o.dispose()},n.onError.bind(n),function(){o.dispose()})),i})},oe.switchLatest=function(){var t=this;return new De(function(e){var n=!1,r=new P,i=!1,o=0,s=t.subscribe(function(t){var s=new j,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)})},oe.takeUntil=function(t){var e=this;return new De(function(r){return new R(e.subscribe(r),t.subscribe(r.onCompleted.bind(r),r.onError.bind(r),n))})},oe.zip=function(){if(Array.isArray(arguments[0]))return b.apply(this,arguments);var t=this,n=C.call(arguments),i=n.pop();return n.unshift(t),new De(function(o){function s(t){a[t]=!0,a.every(function(t){return t})&&o.onCompleted()}for(var u=n.length,c=l(u,function(){return[]}),a=l(u,function(){return!1}),h=function(n){var s,u;if(c.every(function(t){return t.length>0})){try{u=c.map(function(t){return t.shift()}),s=i.apply(t,u)}catch(h){return o.onError(h),e}o.onNext(s)}else a.filter(function(t,e){return e!==n}).every(r)&&o.onCompleted()},f=Array(u),p=0;u>p;p++)(function(t){f[t]=new j,f[t].setDisposable(n[t].subscribe(function(e){c[t].push(e),h(t)},o.onError.bind(o),function(){s(t)}))})(p);return new R(f)})},le.zip=function(){var t=C.call(arguments,0),e=t.shift();return e.zip.apply(e,t)},le.zipArray=function(){var t=C.call(arguments);return new De(function(n){function i(t){if(u.every(function(t){return t.length>0})){var i=u.map(function(t){return t.shift()});n.onNext(i)}else if(c.filter(function(e,n){return n!==t}).every(r))return n.onCompleted(),e}function o(t){return c[t]=!0,c.every(r)?(n.onCompleted(),e):e}for(var s=t.length,u=l(s,function(){return[]}),c=l(s,function(){return!1}),a=Array(s),h=0;s>h;h++)(function(e){a[e]=new j,a[e].setDisposable(t[e].subscribe(function(t){u[e].push(t),i(e)},n.onError.bind(n),function(){o(e)}))})(h);var f=new R(a);return f.add(q(function(){for(var t=0,e=u.length;e>t;t++)u[t]=[]})),f})},oe.asObservable=function(){var t=this;return new De(function(e){return t.subscribe(e)})},oe.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})},oe.dematerialize=function(){var t=this;return new De(function(e){return t.subscribe(function(t){return t.accept(e)},e.onError.bind(e),e.onCompleted.bind(e))})},oe.distinctUntilChanged=function(t,n){var i=this;return t||(t=r),n||(n=o),new De(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))})},oe.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 De(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()})})},oe.finallyAction=function(t){var e=this;return new De(function(n){var r=e.subscribe(n);return q(function(){try{r.dispose()}catch(e){throw e}finally{t()}})})},oe.ignoreElements=function(){var t=this;return new De(function(e){return t.subscribe(n,e.onError.bind(e),e.onCompleted.bind(e))})},oe.materialize=function(){var t=this;return new De(function(e){return t.subscribe(function(t){e.onNext(Q(t))},function(t){e.onNext(X(t)),e.onCompleted()},function(){e.onNext(Y()),e.onCompleted()})})},oe.repeat=function(t){return ee(this,t).concat()},oe.retry=function(t){return ee(this,t).catchException()},oe.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 pe(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})})},oe.skipLast=function(t){var e=this;return new De(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))})},oe.startWith=function(){var t,e,n=0;return arguments.length&&"now"in Object(arguments[0])?(e=arguments[0],n=1):e=z,t=C.call(arguments,n),ne([be(t,e),this]).concat()},oe.takeLast=function(t,e){return this.takeLastBuffer(t).selectMany(function(t){return be(t,e)})},oe.takeLastBuffer=function(t){var e=this;return new De(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()})})},oe.windowWithCount=function(t,e){var n=this;if(0>=t)throw Error(E);if(null==e&&(e=t),0>=e)throw Error(E);return new De(function(r){var i=new j,o=new M(i),s=0,u=[],c=function(){var t=new Ne;u.push(t),r.onNext(S(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})},oe.defaultIfEmpty=function(t){var n=this;return t===e&&(t=null),new De(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()})})},oe.distinct=function(t,n){var i=this;return t||(t=r),n||(n=u),new De(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))})},oe.groupBy=function(t,e,n){return this.groupByUntil(t,e,function(){return ve()},n)},oe.groupByUntil=function(t,i,o,s){var c=this;return i||(i=r),s||(s=u),new De(function(r){var u={},a=new R,h=new M(a);return a.add(c.subscribe(function(c){var l,f,p,d,b,v,m,y,w,g;try{v=t(c),m=s(v)}catch(E){for(g in u)u[g].onError(E);return r.onError(E),e}d=!1;try{w=u[m],w||(w=new Ne,u[m]=w,d=!0)}catch(E){for(g in u)u[g].onError(E);return r.onError(E),e}if(d){b=new Se(v,w,h),f=new Se(v,w);try{l=o(f)}catch(E){for(g in u)u[g].onError(E);return r.onError(E),e}r.onNext(b),y=new j,a.add(y);var x=function(){m in u&&(delete u[m],w.onCompleted()),a.remove(y)};y.setDisposable(l.take(1).subscribe(n,function(t){for(g in u)u[g].onError(t);r.onError(t)},function(){x()}))}try{p=i(c)}catch(E){for(g in u)u[g].onError(E);return r.onError(E),e}w.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})},oe.select=function(t,n){var r=this;return new De(function(i){var o=0;return r.subscribe(function(s){var u;try{u=t.call(n,s,o++,r)}catch(c){return i.onError(c),e}i.onNext(u)},i.onError.bind(i),i.onCompleted.bind(i))})},oe.map=oe.select,oe.selectMany=oe.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})},oe.skip=function(t){if(0>t)throw Error(E);var e=this;return new De(function(n){var r=t;return e.subscribe(function(t){0>=r?n.onNext(t):r--},n.onError.bind(n),n.onCompleted.bind(n))})},oe.skipWhile=function(t){var n=this;return new De(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))})},oe.take=function(t,e){if(0>t)throw Error(E);if(0===t)return de(e);var n=this;return new De(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))})},oe.takeWhile=function(t){var n=this;return new De(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))})},oe.where=function(t,n){var r=this;return new De(function(i){var o=0;return r.subscribe(function(s){var u;try{u=t.call(n,s,o++,r)}catch(c){return i.onError(c),e}u&&i.onNext(s)},i.onError.bind(i),i.onCompleted.bind(i))})},oe.filter=oe.where;var De=w.Internals.AnonymousObservable=function(t){function n(r){function i(t){var e=new Ae(t);if(B.scheduleRequired())B.schedule(function(){try{e.disposable(r(e))}catch(t){if(!e.fail(t))throw t}});else try{e.disposable(r(e))}catch(n){if(!e.fail(n))throw n}return e}return this instanceof n?(t.call(this,i),e):new n(r)}return D(n,t),n}(le),Ae=function(t){function e(e){t.call(this),this.observer=e,this.m=new j}D(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}(se),Se=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 De(function(t){return new R(i.getDisposable(),r.subscribe(t))}):r}return D(n,t),n}(le),_e=function(t,e){this.subject=t,this.observer=e};_e.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 Ne=w.Subject=function(t){function e(t){return a.call(this),this.isStopped?this.exception?(t.onError(this.exception),T):(t.onCompleted(),T):(this.observers.push(t),new _e(this,t))}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.observers=[]}return D(n,t),A(n.prototype,re,{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}(le),We=w.AsyncSubject=function(t){function e(t){if(a.call(this),!this.isStopped)return this.observers.push(t),new _e(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(),T}function n(){t.call(this,e),this.isDisposed=!1,this.isStopped=!1,this.value=null,this.hasValue=!1,this.observers=[],this.exception=null}return D(n,t),A(n.prototype,re,{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}(le),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 D(n,t),A(n.prototype,re,{onCompleted:function(){this.observer.onCompleted()},onError:function(t){this.observer.onError(t)},onNext:function(t){this.observer.onNext(t)}}),n}(le);return"function"==typeof define&&"object"==typeof define.amd&&define.amd?(t.Rx=w,define(function(){return w})):(m?"object"==typeof module&&module&&module.exports==m?module.exports=w:m=w:t.Rx=w,e)})(this); |
@@ -1,2 +0,2 @@ | ||
var Rx = require('./rx.modern'); | ||
var Rx = require('./rx'); | ||
require('./rx.aggregates'); | ||
@@ -3,0 +3,0 @@ require('./rx.binding'); |
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. | ||
(function (root, factory) { | ||
var freeExports = typeof exports == 'object' && exports && | ||
(typeof root == 'object' && root && root == root.global && (window = root), exports); | ||
var freeExports = typeof exports == 'object' && exports, | ||
freeModule = typeof module == 'object' && module && module.exports == freeExports && module, | ||
freeGlobal = typeof global == 'object' && global; | ||
if (freeGlobal.global === freeGlobal) { | ||
window = freeGlobal; | ||
} | ||
@@ -13,3 +17,3 @@ // Because of build optimizers | ||
}); | ||
} else if (typeof module == 'object' && module && module.exports == freeExports) { | ||
} else if (typeof module === 'object' && module && module.exports === freeExports) { | ||
module.exports = factory(root, module.exports, require('./rx')); | ||
@@ -16,0 +20,0 @@ } else { |
@@ -1,1 +0,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,a=n.Notification,h=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,a.createOnNext(e))},onError:function(t,e){return"function"==typeof e?new y(t,new s(e)):new y(t,a.createOnError(e))},onCompleted:function(t){return new y(t,a.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 E=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,a.createOnNext(t)))},n.onError=function(t){this.messages.push(new y(this.scheduler.clock,a.createOnError(t)))},n.onCompleted=function(){this.messages.push(new y(this.scheduler.clock,a.createOnCompleted()))},e}(u),x=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 x(this,t)},e.prototype.createColdObservable=function(){var t=i(arguments,0);return new C(this,t)},e.prototype.createObserver=function(){return new E(this)},e}(h),n}); | ||
(function(t,e){var n="object"==typeof exports&&exports,r=("object"==typeof module&&module&&module.exports==n&&module,"object"==typeof global&&global);r.global===r&&(window=r),"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,a=n.Notification,h=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,a.createOnNext(e))},onError:function(t,e){return"function"==typeof e?new y(t,new s(e)):new y(t,a.createOnError(e))},onCompleted:function(t){return new y(t,a.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 E=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,a.createOnNext(t)))},n.onError=function(t){this.messages.push(new y(this.scheduler.clock,a.createOnError(t)))},n.onCompleted=function(){this.messages.push(new y(this.scheduler.clock,a.createOnCompleted()))},e}(u),x=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 x(this,t)},e.prototype.createColdObservable=function(){var t=i(arguments,0);return new C(this,t)},e.prototype.createObserver=function(){return new E(this)},e}(h),n}); |
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. | ||
(function (root, factory) { | ||
var freeExports = typeof exports == 'object' && exports && | ||
(typeof root == 'object' && root && root == root.global && (window = root), exports); | ||
var freeExports = typeof exports == 'object' && exports, | ||
freeModule = typeof module == 'object' && module && module.exports == freeExports && module, | ||
freeGlobal = typeof global == 'object' && global; | ||
if (freeGlobal.global === freeGlobal) { | ||
window = freeGlobal; | ||
} | ||
@@ -13,3 +17,3 @@ // Because of build optimizers | ||
}); | ||
} else if (typeof module == 'object' && module && module.exports == freeExports) { | ||
} else if (typeof module === 'object' && module && module.exports === freeExports) { | ||
module.exports = factory(root, module.exports, require('./rx')); | ||
@@ -65,3 +69,3 @@ } else { | ||
}); | ||
}; | ||
} | ||
@@ -76,3 +80,3 @@ function observableTimerTimeSpan(dueTime, scheduler) { | ||
}); | ||
}; | ||
} | ||
@@ -91,3 +95,3 @@ function observableTimerTimeSpanAndPeriod(dueTime, period, scheduler) { | ||
}); | ||
}; | ||
} | ||
@@ -217,3 +221,3 @@ /** | ||
}); | ||
}; | ||
} | ||
@@ -592,5 +596,5 @@ function observableDelayDate(dueTime, scheduler) { | ||
sampler.subscribe(sampleSubscribe, observer.onError.bind(observer), sampleSubscribe) | ||
) | ||
); | ||
}); | ||
}; | ||
} | ||
@@ -597,0 +601,0 @@ /** |
@@ -1,1 +0,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,r){function i(t,e){return new p(function(n){return e.scheduleWithAbsolute(t,function(){n.onNext(0),n.onCompleted()})})}function o(t,e,n){var r=A(e);return new p(function(e){var i=0,o=t;return n.scheduleRecursiveWithAbsolute(o,function(t){var s;r>0&&(s=n.now(),o+=r,s>=o&&(o=s+r)),e.onNext(i++),t(o)})})}function s(t,e){var n=A(t);return new p(function(t){return e.scheduleWithRelative(n,function(){t.onNext(0),t.onCompleted()})})}function u(t,e,n){return t===e?new p(function(t){return n.schedulePeriodicWithState(0,e,function(e){return t.onNext(e),e+1})}):d(function(){return o(n.now()+t,e,n)})}function c(t,e){var n=this;return new p(function(r){var i,o=!1,s=new g,u=null,c=[],a=!1;return i=n.materialize().timestamp(e).subscribe(function(n){var i,h;"E"===n.value.kind?(c=[],c.push(n),u=n.value.exception,h=!a):(c.push({value:n.value,timestamp:n.timestamp+t}),h=!o,o=!0),h&&(null!==u?r.onError(u):(i=new w,s.disposable(i),i.disposable(e.scheduleRecursiveWithRelative(t,function(t){var n,i,s,h;if(null===u){a=!0;do s=null,c.length>0&&0>=c[0].timestamp-e.now()&&(s=c.shift().value),null!==s&&s.accept(r);while(null!==s);h=!1,i=0,c.length>0?(h=!0,i=Math.max(0,c[0].timestamp-e.now())):o=!1,n=u,a=!1,null!==n?r.onError(n):h&&t(i)}}))))}),new x(i,s)})}function a(t,e){var n=this;return d(function(){var r=t-e.now();return c.call(n,r,e)})}function h(t,e){return new p(function(n){function r(){s&&(s=!1,n.onNext(o)),i&&n.onCompleted()}var i,o,s;return new x(t.subscribe(function(t){s=!0,o=t},n.onError.bind(n),function(){i=!0}),e.subscribe(r,n.onError.bind(n),r))})}var l=n.Observable,f=l.prototype,p=n.Internals.AnonymousObservable,d=l.defer,b=l.empty,v=l.throwException,m=l.fromArray,y=n.Scheduler.timeout,w=n.SingleAssignmentDisposable,g=n.SerialDisposable,x=n.CompositeDisposable,E=n.RefCountDisposable,C=n.Subject,D=(n.Internals.BinaryObserver,n.Internals.addRef),A=n.Scheduler.normalize,N=l.interval=function(t,e){return e||(e=y),u(t,t,e)},S=l.timer=function(t,e,n){var c;return n||(n=y),e!==r&&"number"==typeof e?c=e:e!==r&&"object"==typeof e&&(n=e),t instanceof Date&&c===r?i(t.getTime(),n):t instanceof Date&&c!==r?(c=e,o(t.getTime(),c,n)):c===r?s(t,n):u(t,c,n)};return f.delay=function(t,e){return e||(e=y),t instanceof Date?a.call(this,t.getTime(),e):c.call(this,t,e)},f.throttle=function(t,e){e||(e=y);var n=this;return new p(function(r){var i,o=new g,s=!1,u=0,c=null;return i=n.subscribe(function(n){var i,a;s=!0,c=n,u++,i=u,a=new w,o.disposable(a),a.disposable(e.scheduleWithRelative(t,function(){s&&u===i&&r.onNext(c),s=!1}))},function(t){o.dispose(),r.onError(t),s=!1,u++},function(){o.dispose(),s&&r.onNext(c),r.onCompleted(),s=!1,u++}),new x(i,o)})},f.windowWithTime=function(t,e,n){var i,o=this;return e===r&&(i=t),n===r&&(n=y),"number"==typeof e?i=e:"object"==typeof e&&(i=t,n=e),new p(function(e){var r,s,u,c=i,a=t,h=[],l=new g,f=0;return s=new x(l),u=new E(s),r=function(){var t,o,s,p,d;s=new w,l.disposable(s),o=!1,t=!1,a===c?(o=!0,t=!0):c>a?o=!0:t=!0,p=o?a:c,d=p-f,f=p,o&&(a+=i),t&&(c+=i),s.disposable(n.scheduleWithRelative(d,function(){var n;t&&(n=new C,h.push(n),e.onNext(D(n,u))),o&&(n=h.shift(),n.onCompleted()),r()}))},h.push(new C),e.onNext(D(h[0],u)),r(),s.add(o.subscribe(function(t){var e,n;for(e=0;h.length>e;e++)n=h[e],n.onNext(t)},function(t){var n,r;for(n=0;h.length>n;n++)r=h[n],r.onError(t);e.onError(t)},function(){var t,n;for(t=0;h.length>t;t++)n=h[t],n.onCompleted();e.onCompleted()})),u})},f.windowWithTimeOrCount=function(t,e,n){var r=this;return n||(n=y),new p(function(i){var o,s,u,c,a=0,h=new g,l=0;return s=new x(h),u=new E(s),o=function(e){var r=new w;h.disposable(r),r.disposable(n.scheduleWithRelative(t,function(){var t;e===l&&(a=0,t=++l,c.onCompleted(),c=new C,i.onNext(D(c,u)),o(t))}))},c=new C,i.onNext(D(c,u)),o(0),s.add(r.subscribe(function(t){var n=0,r=!1;c.onNext(t),a++,a===e&&(r=!0,a=0,n=++l,c.onCompleted(),c=new C,i.onNext(D(c,u))),r&&o(n)},function(t){c.onError(t),i.onError(t)},function(){c.onCompleted(),i.onCompleted()})),u})},f.bufferWithTime=function(t,e,n){var i;return e===r&&(i=t),n||(n=y),"number"==typeof e?i=e:"object"==typeof e&&(i=t,n=e),this.windowWithTime(t,i,n).selectMany(function(t){return t.toArray()})},f.bufferWithTimeOrCount=function(t,e,n){return n||(n=y),this.windowWithTimeOrCount(t,e,n).selectMany(function(t){return t.toArray()})},f.timeInterval=function(t){var e=this;return t||(t=y),d(function(){var n=t.now();return e.select(function(e){var r=t.now(),i=r-n;return n=r,{value:e,interval:i}})})},f.timestamp=function(t){return t||(t=y),this.select(function(e){return{value:e,timestamp:t.now()}})},f.sample=function(t,e){return e||(e=y),"number"==typeof t?h(this,N(t,e)):h(this,t)},f.timeout=function(t,e,n){var r,i=this;return e||(e=v(Error("Timeout"))),n||(n=y),r=t instanceof Date?function(t,e){n.scheduleWithAbsolute(t,e)}:function(t,e){n.scheduleWithRelative(t,e)},new p(function(n){var o,s=0,u=new w,c=new g,a=!1,h=new g;return c.disposable(u),o=function(){var i=s;h.disposable(r(t,function(){a=s===i;var t=a;t&&c.disposable(e.subscribe(n))}))},o(),u.disposable(i.subscribe(function(t){var e=!a;e&&(s++,n.onNext(t),o())},function(t){var e=!a;e&&(s++,n.onError(t))},function(){var t=!a;t&&(s++,n.onCompleted())})),new x(c,h)})},l.generateWithAbsoluteTime=function(t,e,n,i,o,s){return s||(s=y),new p(function(u){var c,a,h=!0,l=!1,f=t;return s.scheduleRecursiveWithAbsolute(s.now(),function(t){l&&u.onNext(c);try{h?h=!1:f=n(f),l=e(f),l&&(c=i(f),a=o(f))}catch(s){return u.onError(s),r}l?t(a):u.onCompleted()})})},l.generateWithRelativeTime=function(t,e,n,i,o,s){return s||(s=y),new p(function(u){var c,a,h=!0,l=!1,f=t;return s.scheduleRecursiveWithRelative(0,function(t){l&&u.onNext(c);try{h?h=!1:f=n(f),l=e(f),l&&(c=i(f),a=o(f))}catch(s){return u.onError(s),r}l?t(a):u.onCompleted()})})},f.delaySubscription=function(t,e){return e||(e=y),this.delayWithSelector(S(t,e),function(){return b()})},f.delayWithSelector=function(t,e){var n,i,o=this;return"function"==typeof t?i=t:(n=t,i=e),new p(function(t){var e=new x,s=!1,u=function(){s&&0===e.length&&t.onCompleted()},c=new g,a=function(){c.setDisposable(o.subscribe(function(n){var o;try{o=i(n)}catch(s){return t.onError(s),r}var c=new w;e.add(c),c.setDisposable(o.subscribe(function(){t.onNext(n),e.remove(c),u()},t.onError.bind(t),function(){t.onNext(n),e.remove(c),u()}))},t.onError.bind(t),function(){s=!0,c.dispose(),u()}))};return n?c.setDisposable(n.subscribe(function(){a()},t.onError.bind(t),function(){a()})):a(),new x(c,e)})},f.timeoutWithSelector=function(t,e,n){t||(t=observableNever()),n||(n=v(Error("Timeout")));var i=this;return new p(function(o){var s=new g,u=new g,c=new w;s.setDisposable(c);var a=0,h=!1,l=function(t){var e=a,r=function(){return a===e},i=new w;u.setDisposable(i),i.setDisposable(t.subscribe(function(){r()&&s.setDisposable(n.subscribe(o)),i.dispose()},function(t){r()&&o.onError(t)},function(){r()&&s.setDisposable(n.subscribe(o))}))};l(t);var f=function(){var t=!h;return t&&a++,t};return c.setDisposable(i.subscribe(function(t){if(f()){o.onNext(t);var n;try{n=e(t)}catch(i){return o.onError(i),r}l(n)}},function(t){f()&&o.onError(t)},function(){f()&&o.onCompleted()})),new x(s,u)})},f.throttleWithSelector=function(t){var e=this;return new p(function(n){var i,o=!1,s=new g,u=0,c=e.subscribe(function(e){var c;try{c=t(e)}catch(a){return n.onError(a),r}o=!0,i=e,u++;var h=u,l=new w;s.setDisposable(l),l.setDisposable(c.subscribe(function(){o&&u===h&&n.onNext(i),o=!1,l.dispose()},n.onError.bind(n),function(){o&&u===h&&n.onNext(i),o=!1,l.dispose()}))},function(t){s.dispose(),n.onError(t),o=!1,u++},function(){s.dispose(),o&&n.onNext(i),n.onCompleted(),o=!1,u++});return new x(c,s)})},f.skipLastWithTime=function(t,e){e||(e=y);var n=this;return new p(function(r){var i=[];return n.subscribe(function(n){var o=e.now();for(i.push({interval:o,value:n});i.length>0&&o-i[0].interval>=t;)r.onNext(i.shift().value)},r.onError.bind(r),function(){for(var n=e.now();i.length>0&&n-i[0].interval>=t;)r.onNext(i.shift().value);r.onCompleted()})})},f.takeLastWithTime=function(t,e,n){return this.takeLastBufferWithTime(t,e).selectMany(function(t){return m(t,n)})},f.takeLastBufferWithTime=function(t,e){var n=this;return e||(e=y),new p(function(r){var i=[];return n.subscribe(function(n){var r=e.now();for(i.push({interval:r,value:n});i.length>0&&r-i[0].interval>=t;)i.shift()},r.onError.bind(r),function(){for(var n=e.now(),o=[];i.length>0;){var s=i.shift();t>=n-s.interval&&o.push(s.value)}r.onNext(o),r.onCompleted()})})},f.takeWithTime=function(t,e){var n=this;return e||(e=y),new p(function(r){var i=e.scheduleWithRelative(t,function(){r.onCompleted()});return new x(i,n.subscribe(r))})},f.skipWithTime=function(t,e){var n=this;return e||(e=y),new p(function(r){var i=!1,o=e.scheduleWithRelative(t,function(){i=!0}),s=n.subscribe(function(t){i&&r.onNext(t)},r.onError.bind(r),r.onCompleted.bind(r));return new x(o,s)})},f.skipUntilWithTime=function(t,e){e||(e=y);var n=this;return new p(function(r){var i=!1,o=e.scheduleWithAbsolute(t,function(){i=!0}),s=n.subscribe(function(t){i&&r.onNext(t)},r.onError.bind(r),r.onCompleted.bind(r));return new x(o,s)})},f.takeUntilWithTime=function(t,e){e||(e=y);var n=this;return new p(function(r){return new x(e.scheduleWithAbsolute(t,function(){r.onCompleted()}),n.subscribe(r))})},n}); | ||
(function(t,e){var n="object"==typeof exports&&exports,r=("object"==typeof module&&module&&module.exports==n&&module,"object"==typeof global&&global);r.global===r&&(window=r),"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,r){function i(t,e){return new p(function(n){return e.scheduleWithAbsolute(t,function(){n.onNext(0),n.onCompleted()})})}function o(t,e,n){var r=A(e);return new p(function(e){var i=0,o=t;return n.scheduleRecursiveWithAbsolute(o,function(t){var s;r>0&&(s=n.now(),o+=r,s>=o&&(o=s+r)),e.onNext(i++),t(o)})})}function s(t,e){var n=A(t);return new p(function(t){return e.scheduleWithRelative(n,function(){t.onNext(0),t.onCompleted()})})}function u(t,e,n){return t===e?new p(function(t){return n.schedulePeriodicWithState(0,e,function(e){return t.onNext(e),e+1})}):d(function(){return o(n.now()+t,e,n)})}function c(t,e){var n=this;return new p(function(r){var i,o=!1,s=new g,u=null,c=[],a=!1;return i=n.materialize().timestamp(e).subscribe(function(n){var i,h;"E"===n.value.kind?(c=[],c.push(n),u=n.value.exception,h=!a):(c.push({value:n.value,timestamp:n.timestamp+t}),h=!o,o=!0),h&&(null!==u?r.onError(u):(i=new w,s.disposable(i),i.disposable(e.scheduleRecursiveWithRelative(t,function(t){var n,i,s,h;if(null===u){a=!0;do s=null,c.length>0&&0>=c[0].timestamp-e.now()&&(s=c.shift().value),null!==s&&s.accept(r);while(null!==s);h=!1,i=0,c.length>0?(h=!0,i=Math.max(0,c[0].timestamp-e.now())):o=!1,n=u,a=!1,null!==n?r.onError(n):h&&t(i)}}))))}),new x(i,s)})}function a(t,e){var n=this;return d(function(){var r=t-e.now();return c.call(n,r,e)})}function h(t,e){return new p(function(n){function r(){s&&(s=!1,n.onNext(o)),i&&n.onCompleted()}var i,o,s;return new x(t.subscribe(function(t){s=!0,o=t},n.onError.bind(n),function(){i=!0}),e.subscribe(r,n.onError.bind(n),r))})}var l=n.Observable,f=l.prototype,p=n.Internals.AnonymousObservable,d=l.defer,b=l.empty,v=l.throwException,m=l.fromArray,y=n.Scheduler.timeout,w=n.SingleAssignmentDisposable,g=n.SerialDisposable,x=n.CompositeDisposable,E=n.RefCountDisposable,C=n.Subject,D=(n.Internals.BinaryObserver,n.Internals.addRef),A=n.Scheduler.normalize,N=l.interval=function(t,e){return e||(e=y),u(t,t,e)},S=l.timer=function(t,e,n){var c;return n||(n=y),e!==r&&"number"==typeof e?c=e:e!==r&&"object"==typeof e&&(n=e),t instanceof Date&&c===r?i(t.getTime(),n):t instanceof Date&&c!==r?(c=e,o(t.getTime(),c,n)):c===r?s(t,n):u(t,c,n)};return f.delay=function(t,e){return e||(e=y),t instanceof Date?a.call(this,t.getTime(),e):c.call(this,t,e)},f.throttle=function(t,e){e||(e=y);var n=this;return new p(function(r){var i,o=new g,s=!1,u=0,c=null;return i=n.subscribe(function(n){var i,a;s=!0,c=n,u++,i=u,a=new w,o.disposable(a),a.disposable(e.scheduleWithRelative(t,function(){s&&u===i&&r.onNext(c),s=!1}))},function(t){o.dispose(),r.onError(t),s=!1,u++},function(){o.dispose(),s&&r.onNext(c),r.onCompleted(),s=!1,u++}),new x(i,o)})},f.windowWithTime=function(t,e,n){var i,o=this;return e===r&&(i=t),n===r&&(n=y),"number"==typeof e?i=e:"object"==typeof e&&(i=t,n=e),new p(function(e){var r,s,u,c=i,a=t,h=[],l=new g,f=0;return s=new x(l),u=new E(s),r=function(){var t,o,s,p,d;s=new w,l.disposable(s),o=!1,t=!1,a===c?(o=!0,t=!0):c>a?o=!0:t=!0,p=o?a:c,d=p-f,f=p,o&&(a+=i),t&&(c+=i),s.disposable(n.scheduleWithRelative(d,function(){var n;t&&(n=new C,h.push(n),e.onNext(D(n,u))),o&&(n=h.shift(),n.onCompleted()),r()}))},h.push(new C),e.onNext(D(h[0],u)),r(),s.add(o.subscribe(function(t){var e,n;for(e=0;h.length>e;e++)n=h[e],n.onNext(t)},function(t){var n,r;for(n=0;h.length>n;n++)r=h[n],r.onError(t);e.onError(t)},function(){var t,n;for(t=0;h.length>t;t++)n=h[t],n.onCompleted();e.onCompleted()})),u})},f.windowWithTimeOrCount=function(t,e,n){var r=this;return n||(n=y),new p(function(i){var o,s,u,c,a=0,h=new g,l=0;return s=new x(h),u=new E(s),o=function(e){var r=new w;h.disposable(r),r.disposable(n.scheduleWithRelative(t,function(){var t;e===l&&(a=0,t=++l,c.onCompleted(),c=new C,i.onNext(D(c,u)),o(t))}))},c=new C,i.onNext(D(c,u)),o(0),s.add(r.subscribe(function(t){var n=0,r=!1;c.onNext(t),a++,a===e&&(r=!0,a=0,n=++l,c.onCompleted(),c=new C,i.onNext(D(c,u))),r&&o(n)},function(t){c.onError(t),i.onError(t)},function(){c.onCompleted(),i.onCompleted()})),u})},f.bufferWithTime=function(t,e,n){var i;return e===r&&(i=t),n||(n=y),"number"==typeof e?i=e:"object"==typeof e&&(i=t,n=e),this.windowWithTime(t,i,n).selectMany(function(t){return t.toArray()})},f.bufferWithTimeOrCount=function(t,e,n){return n||(n=y),this.windowWithTimeOrCount(t,e,n).selectMany(function(t){return t.toArray()})},f.timeInterval=function(t){var e=this;return t||(t=y),d(function(){var n=t.now();return e.select(function(e){var r=t.now(),i=r-n;return n=r,{value:e,interval:i}})})},f.timestamp=function(t){return t||(t=y),this.select(function(e){return{value:e,timestamp:t.now()}})},f.sample=function(t,e){return e||(e=y),"number"==typeof t?h(this,N(t,e)):h(this,t)},f.timeout=function(t,e,n){var r,i=this;return e||(e=v(Error("Timeout"))),n||(n=y),r=t instanceof Date?function(t,e){n.scheduleWithAbsolute(t,e)}:function(t,e){n.scheduleWithRelative(t,e)},new p(function(n){var o,s=0,u=new w,c=new g,a=!1,h=new g;return c.disposable(u),o=function(){var i=s;h.disposable(r(t,function(){a=s===i;var t=a;t&&c.disposable(e.subscribe(n))}))},o(),u.disposable(i.subscribe(function(t){var e=!a;e&&(s++,n.onNext(t),o())},function(t){var e=!a;e&&(s++,n.onError(t))},function(){var t=!a;t&&(s++,n.onCompleted())})),new x(c,h)})},l.generateWithAbsoluteTime=function(t,e,n,i,o,s){return s||(s=y),new p(function(u){var c,a,h=!0,l=!1,f=t;return s.scheduleRecursiveWithAbsolute(s.now(),function(t){l&&u.onNext(c);try{h?h=!1:f=n(f),l=e(f),l&&(c=i(f),a=o(f))}catch(s){return u.onError(s),r}l?t(a):u.onCompleted()})})},l.generateWithRelativeTime=function(t,e,n,i,o,s){return s||(s=y),new p(function(u){var c,a,h=!0,l=!1,f=t;return s.scheduleRecursiveWithRelative(0,function(t){l&&u.onNext(c);try{h?h=!1:f=n(f),l=e(f),l&&(c=i(f),a=o(f))}catch(s){return u.onError(s),r}l?t(a):u.onCompleted()})})},f.delaySubscription=function(t,e){return e||(e=y),this.delayWithSelector(S(t,e),function(){return b()})},f.delayWithSelector=function(t,e){var n,i,o=this;return"function"==typeof t?i=t:(n=t,i=e),new p(function(t){var e=new x,s=!1,u=function(){s&&0===e.length&&t.onCompleted()},c=new g,a=function(){c.setDisposable(o.subscribe(function(n){var o;try{o=i(n)}catch(s){return t.onError(s),r}var c=new w;e.add(c),c.setDisposable(o.subscribe(function(){t.onNext(n),e.remove(c),u()},t.onError.bind(t),function(){t.onNext(n),e.remove(c),u()}))},t.onError.bind(t),function(){s=!0,c.dispose(),u()}))};return n?c.setDisposable(n.subscribe(function(){a()},t.onError.bind(t),function(){a()})):a(),new x(c,e)})},f.timeoutWithSelector=function(t,e,n){t||(t=observableNever()),n||(n=v(Error("Timeout")));var i=this;return new p(function(o){var s=new g,u=new g,c=new w;s.setDisposable(c);var a=0,h=!1,l=function(t){var e=a,r=function(){return a===e},i=new w;u.setDisposable(i),i.setDisposable(t.subscribe(function(){r()&&s.setDisposable(n.subscribe(o)),i.dispose()},function(t){r()&&o.onError(t)},function(){r()&&s.setDisposable(n.subscribe(o))}))};l(t);var f=function(){var t=!h;return t&&a++,t};return c.setDisposable(i.subscribe(function(t){if(f()){o.onNext(t);var n;try{n=e(t)}catch(i){return o.onError(i),r}l(n)}},function(t){f()&&o.onError(t)},function(){f()&&o.onCompleted()})),new x(s,u)})},f.throttleWithSelector=function(t){var e=this;return new p(function(n){var i,o=!1,s=new g,u=0,c=e.subscribe(function(e){var c;try{c=t(e)}catch(a){return n.onError(a),r}o=!0,i=e,u++;var h=u,l=new w;s.setDisposable(l),l.setDisposable(c.subscribe(function(){o&&u===h&&n.onNext(i),o=!1,l.dispose()},n.onError.bind(n),function(){o&&u===h&&n.onNext(i),o=!1,l.dispose()}))},function(t){s.dispose(),n.onError(t),o=!1,u++},function(){s.dispose(),o&&n.onNext(i),n.onCompleted(),o=!1,u++});return new x(c,s)})},f.skipLastWithTime=function(t,e){e||(e=y);var n=this;return new p(function(r){var i=[];return n.subscribe(function(n){var o=e.now();for(i.push({interval:o,value:n});i.length>0&&o-i[0].interval>=t;)r.onNext(i.shift().value)},r.onError.bind(r),function(){for(var n=e.now();i.length>0&&n-i[0].interval>=t;)r.onNext(i.shift().value);r.onCompleted()})})},f.takeLastWithTime=function(t,e,n){return this.takeLastBufferWithTime(t,e).selectMany(function(t){return m(t,n)})},f.takeLastBufferWithTime=function(t,e){var n=this;return e||(e=y),new p(function(r){var i=[];return n.subscribe(function(n){var r=e.now();for(i.push({interval:r,value:n});i.length>0&&r-i[0].interval>=t;)i.shift()},r.onError.bind(r),function(){for(var n=e.now(),o=[];i.length>0;){var s=i.shift();t>=n-s.interval&&o.push(s.value)}r.onNext(o),r.onCompleted()})})},f.takeWithTime=function(t,e){var n=this;return e||(e=y),new p(function(r){var i=e.scheduleWithRelative(t,function(){r.onCompleted()});return new x(i,n.subscribe(r))})},f.skipWithTime=function(t,e){var n=this;return e||(e=y),new p(function(r){var i=!1,o=e.scheduleWithRelative(t,function(){i=!0}),s=n.subscribe(function(t){i&&r.onNext(t)},r.onError.bind(r),r.onCompleted.bind(r));return new x(o,s)})},f.skipUntilWithTime=function(t,e){e||(e=y);var n=this;return new p(function(r){var i=!1,o=e.scheduleWithAbsolute(t,function(){i=!0}),s=n.subscribe(function(t){i&&r.onNext(t)},r.onError.bind(r),r.onCompleted.bind(r));return new x(o,s)})},f.takeUntilWithTime=function(t,e){e||(e=y);var n=this;return new p(function(r){return new x(e.scheduleWithAbsolute(t,function(){r.onCompleted()}),n.subscribe(r))})},n}); |
@@ -10,2 +10,5 @@ /** @private */ | ||
function AnonymousObservable(subscribe) { | ||
if (!(this instanceof AnonymousObservable)) { | ||
return new AnonymousObservable(subscribe); | ||
} | ||
@@ -12,0 +15,0 @@ function s(observer) { |
@@ -15,3 +15,3 @@ /** @private */ | ||
var AutoDetachObserverPrototype = AutoDetachObserver.prototype | ||
var AutoDetachObserverPrototype = AutoDetachObserver.prototype; | ||
@@ -18,0 +18,0 @@ /** |
@@ -51,3 +51,3 @@ /** @private */ | ||
CatchScheduler.prototype._getRecursiveWrapper = function (scheduler) { | ||
if (!this._recursiveOriginal !== scheduler) { | ||
if (this._recursiveOriginal !== scheduler) { | ||
this._recursiveOriginal = scheduler; | ||
@@ -54,0 +54,0 @@ var wrapper = this._clone(scheduler); |
@@ -17,3 +17,3 @@ | ||
if (typeof window.process !== 'undefined' && Object.prototype.toString.call(window.process) === '[object process]') { | ||
if (typeof window.process === 'object' && Object.prototype.toString.call(window.process) === '[object process]') { | ||
scheduleMethod = window.process.nextTick; | ||
@@ -20,0 +20,0 @@ } else if (typeof window.setImmediate === 'function') { |
@@ -142,3 +142,3 @@ /** Provides a set of extension methods for virtual time scheduling. */ | ||
} | ||
} while (this.isEnabled) | ||
} while (this.isEnabled); | ||
this.clock = time; | ||
@@ -232,5 +232,5 @@ } | ||
return si.disposable; | ||
} | ||
}; | ||
return VirtualTimeScheduler; | ||
}(Scheduler)); |
@@ -7,8 +7,7 @@ // Real Dictionary | ||
function isPrime(candidate) { | ||
var num1, num2; | ||
if (candidate & 1 === 0) { | ||
return candidate === 2; | ||
} | ||
num1 = Math.sqrt(candidate); | ||
num2 = 3; | ||
var num1 = Math.sqrt(candidate), | ||
num2 = 3; | ||
while (num2 <= num1) { | ||
@@ -41,2 +40,25 @@ if (candidate % num2 === 0) { | ||
function stringHashFn(str) { | ||
var hash = 757602046; | ||
if (!str.length) { | ||
return hash; | ||
} | ||
for (var i = 0, len = str.length; i < len; i++) { | ||
var character = str.charCodeAt(i); | ||
hash = ((hash<<5)-hash)+character; | ||
hash = hash & hash; | ||
} | ||
return hash; | ||
} | ||
function numberHashFn(key) { | ||
var c2 = 0x27d4eb2d; | ||
key = (key ^ 61) ^ (key >>> 16); | ||
key = key + (key << 3); | ||
key = key ^ (key >>> 4); | ||
key = key * c2; | ||
key = key ^ (key >>> 15); | ||
return key; | ||
} | ||
var getHashCode = (function () { | ||
@@ -46,9 +68,28 @@ var uniqueIdCounter = 0; | ||
return function (obj) { | ||
var id; | ||
if (obj === undefined) | ||
if (obj == null) { | ||
throw new Error(noSuchkey); | ||
if (obj.getHashCode !== undefined) { | ||
} | ||
// Check for built-ins before tacking on our own for any object | ||
if (typeof obj === 'string') { | ||
return stringHashFn(obj); | ||
} | ||
if (typeof obj === 'number') { | ||
return numberHashFn(obj); | ||
} | ||
if (typeof obj === 'boolean') { | ||
return obj === true ? 1 : 0; | ||
} | ||
if (obj instanceof Date) { | ||
return obj.getTime(); | ||
} | ||
if (obj.getHashCode) { | ||
return obj.getHashCode(); | ||
} | ||
id = 17 * uniqueIdCounter++; | ||
var id = 17 * uniqueIdCounter++; | ||
obj.getHashCode = function () { return id; }; | ||
@@ -66,3 +107,9 @@ return id; | ||
var Dictionary = function (capacity, comparer) { | ||
this._initialize(capacity); | ||
if (capacity < 0) { | ||
throw new Error('out of range') | ||
} | ||
if (capacity > 0) { | ||
this._initialize(capacity); | ||
} | ||
this.comparer = comparer || defaultComparer; | ||
@@ -91,5 +138,6 @@ this.freeCount = 0; | ||
Dictionary.prototype._insert = function (key, value, add) { | ||
if (this.buckets === undefined) { | ||
if (!this.buckets) { | ||
this._initialize(0); | ||
} | ||
var index3; | ||
var num = getHashCode(key) & 2147483647; | ||
@@ -100,3 +148,3 @@ var index1 = num % this.buckets.length; | ||
if (add) { | ||
throw duplicatekey; | ||
throw new Error(duplicatekey); | ||
} | ||
@@ -108,3 +156,3 @@ this.entries[index2].value = value; | ||
if (this.freeCount > 0) { | ||
var index3 = this.freeList; | ||
index3 = this.freeList; | ||
this.freeList = this.entries[index3].next; | ||
@@ -126,5 +174,6 @@ --this.freeCount; | ||
}; | ||
Dictionary.prototype._resize = function () { | ||
var prime = getPrime(this.size * 2); | ||
var numArray = new Array(prime); | ||
var prime = getPrime(this.size * 2), | ||
numArray = new Array(prime); | ||
for (index = 0; index < numArray.length; ++index) { | ||
@@ -148,4 +197,5 @@ numArray[index] = -1; | ||
}; | ||
Dictionary.prototype.remove = function (key) { | ||
if (this.buckets !== undefined) { | ||
if (this.buckets) { | ||
var num = getHashCode(key) & 2147483647; | ||
@@ -175,2 +225,3 @@ var index1 = num % this.buckets.length; | ||
}; | ||
Dictionary.prototype.clear = function () { | ||
@@ -190,4 +241,5 @@ var index, len; | ||
}; | ||
Dictionary.prototype._findEntry = function (key) { | ||
if (this.buckets !== undefined) { | ||
if (this.buckets) { | ||
var num = getHashCode(key) & 2147483647; | ||
@@ -202,18 +254,18 @@ for (var index = this.buckets[num % this.buckets.length]; index >= 0; index = this.entries[index].next) { | ||
}; | ||
Dictionary.prototype.count = function () { | ||
return this.size - this.freeCount; | ||
}; | ||
Dictionary.prototype.tryGetEntry = function (key) { | ||
Dictionary.prototype.tryGetValue = function (key) { | ||
var entry = this._findEntry(key); | ||
if (entry >= 0) { | ||
return { | ||
key: this.entries[entry].key, | ||
value: this.entries[entry].value | ||
}; | ||
return this.entries[entry].value; | ||
} | ||
return undefined; | ||
}; | ||
Dictionary.prototype.getValues = function () { | ||
var index = 0, results = []; | ||
if (this.entries !== undefined) { | ||
if (this.entries) { | ||
for (var index1 = 0; index1 < this.size; index1++) { | ||
@@ -227,2 +279,3 @@ if (this.entries[index1].hashCode >= 0) { | ||
}; | ||
Dictionary.prototype.get = function (key) { | ||
@@ -235,7 +288,9 @@ var entry = this._findEntry(key); | ||
}; | ||
Dictionary.prototype.set = function (key, value) { | ||
this._insert(key, value, false); | ||
}; | ||
Dictionary.prototype.containskey = function (key) { | ||
return this._findEntry(key) >= 0; | ||
}; |
@@ -100,5 +100,5 @@ // Utilities | ||
n = Number(arguments[1]); | ||
if (n != n) { | ||
if (n !== n) { | ||
n = 0; | ||
} else if (n != 0 && n != Infinity && n != -Infinity) { | ||
} else if (n !== 0 && n != Infinity && n !== -Infinity) { | ||
n = (n > 0 || -1) * Math.floor(Math.abs(n)); | ||
@@ -105,0 +105,0 @@ } |
(function (window, undefined) { | ||
var freeExports = typeof exports == 'object' && exports && | ||
(typeof global == 'object' && global && global == global.global && (window = global), exports); | ||
var freeExports = typeof exports == 'object' && exports, | ||
freeModule = typeof module == 'object' && module && module.exports == freeExports && module, | ||
freeGlobal = typeof global == 'object' && global; | ||
if (freeGlobal.global === freeGlobal) { | ||
window = freeGlobal; | ||
} | ||
/** | ||
@@ -6,0 +11,0 @@ * @name Rx |
@@ -39,3 +39,3 @@ function extremaBy(source, keySelector, comparer) { | ||
function firstOnly(x) { | ||
if (x.length == 0) { | ||
if (x.length === 0) { | ||
throw new Error(sequenceContainsNoElements); | ||
@@ -102,5 +102,5 @@ } | ||
var source = this; | ||
return predicate | ||
? source.where(predicate, thisArg).any() | ||
: new AnonymousObservable(function (observer) { | ||
return predicate ? | ||
source.where(predicate, thisArg).any() : | ||
new AnonymousObservable(function (observer) { | ||
return source.subscribe(function () { | ||
@@ -617,4 +617,12 @@ observer.onNext(true); | ||
return new AnonymousObservable(function (observer) { | ||
var i = 0; | ||
return source.subscribe(function (x) { | ||
if (predicate.call(thisArg, x, i, source)) { | ||
var shouldRun; | ||
try { | ||
shouldRun = predicate.call(thisArg, x, i, source); | ||
} catch(e) { | ||
observer.onError(e); | ||
return; | ||
} | ||
if (shouldRun) { | ||
observer.onNext(yieldIndex ? i : x); | ||
@@ -621,0 +629,0 @@ observer.onCompleted(); |
@@ -112,112 +112,132 @@ /** | ||
return new AnonymousObservable(function (observer) { | ||
var group = new CompositeDisposable(), | ||
r = new RefCountDisposable(group), | ||
leftId = 0, | ||
leftMap = new Dictionary(), | ||
rightId = 0, | ||
rightMap = new Dictionary(); | ||
group.add(left.subscribe(function (value) { | ||
var duration, | ||
expire, | ||
i, | ||
id = leftId++, | ||
leftValues, | ||
result, | ||
rightValues; | ||
var s = new Subject(); | ||
leftMap.add(id, s); | ||
try { | ||
result = resultSelector(value, addRef(s, r)); | ||
} catch (exception) { | ||
leftValues = leftMap.getValues(); | ||
for (i = 0; i < leftValues.length; i++) { | ||
leftValues[i].onError(exception); | ||
var nothing = function () {}; | ||
var group = new CompositeDisposable(); | ||
var r = new RefCountDisposable(group); | ||
var leftMap = new Dictionary(); | ||
var rightMap = new Dictionary(); | ||
var leftID = 0; | ||
var rightID = 0; | ||
group.add(left.subscribe( | ||
function (value) { | ||
var s = new Subject(); | ||
var id = leftID++; | ||
leftMap.add(id, s); | ||
var i, len, leftValues, rightValues; | ||
var result; | ||
try { | ||
result = resultSelector(value, addRef(s, r)); | ||
} catch (e) { | ||
leftValues = leftMap.getValues(); | ||
for (i = 0, len = leftValues.length; i < len; i++) { | ||
leftValues[i].onError(e); | ||
} | ||
observer.onError(e); | ||
return; | ||
} | ||
observer.onError(exception); | ||
return; | ||
} | ||
observer.onNext(result); | ||
rightValues = rightMap.getValues(); | ||
for (i = 0; i < rightValues.length; i++) { | ||
s.onNext(rightValues[i]); | ||
} | ||
var md = new SingleAssignmentDisposable(); | ||
group.add(md); | ||
expire = function () { | ||
if (leftMap.remove(id)) { | ||
s.onCompleted(); | ||
observer.onNext(result); | ||
rightValues = rightMap.getValues(); | ||
for (i = 0, len = rightValues.length; i < len; i++) { | ||
s.onNext(rightValues[i]); | ||
} | ||
group.remove(md); | ||
}; | ||
try { | ||
duration = leftDurationSelector(value); | ||
} catch (exception) { | ||
leftValues = leftMap.getValues(); | ||
for (i = 0; i < leftValues.length; i++) { | ||
leftValues[i].onError(exception); | ||
var md = new SingleAssignmentDisposable(); | ||
group.add(md); | ||
var expire = function () { | ||
if (leftMap.remove(id)) { | ||
s.onCompleted(); | ||
} | ||
group.remove(md); | ||
}; | ||
var duration; | ||
try { | ||
duration = leftDurationSelector(value); | ||
} catch (e) { | ||
leftValues = leftMap.getValues(); | ||
for (i = 0, len = leftMap.length; i < len; i++) { | ||
leftValues[i].onError(e); | ||
} | ||
observer.onError(e); | ||
return; | ||
} | ||
observer.onError(exception); | ||
return; | ||
} | ||
md.disposable(duration.take(1).subscribe(noop, function (exn) { | ||
leftValues = leftMap.getValues(); | ||
for (var idx = 0, len = leftValues.length; idx < len; idx++) { | ||
leftValues[idx].onError(exn); | ||
md.setDisposable(duration.take(1).subscribe( | ||
nothing, | ||
function (e) { | ||
leftValues = leftMap.getValues(); | ||
for (i = 0, len = leftValues.length; i < len; i++) { | ||
leftValues[i].onError(e); | ||
} | ||
observer.onError(e); | ||
}, | ||
expire) | ||
); | ||
}, | ||
function (e) { | ||
var leftValues = leftMap.getValues(); | ||
for (var i = 0, len = leftValues.length; i < len; i++) { | ||
leftValues[i].onError(e); | ||
} | ||
observer.onError(exn); | ||
}, function () { | ||
expire(); | ||
})); | ||
}, function (exception) { | ||
var i, leftValues; | ||
leftValues = leftMap.getValues(); | ||
for (i = 0; i < leftValues.length; i++) { | ||
leftValues[i].onError(exception); | ||
} | ||
observer.onError(exception); | ||
}, observer.onCompleted.bind(observer))); | ||
group.add(right.subscribe(function (value) { | ||
var duration, i, leftValues; | ||
var id = rightId++; | ||
rightMap.add(id, value); | ||
var md = new SingleAssignmentDisposable(); | ||
group.add(md); | ||
var expire = function () { | ||
rightMap.remove(id); | ||
group.remove(md); | ||
}; | ||
try { | ||
duration = rightDurationSelector(value); | ||
} catch (exception) { | ||
leftValues = leftMap.getValues(); | ||
for (i = 0; i < leftValues.length; i++) { | ||
leftValues[i].onError(exception); | ||
observer.onError(e); | ||
}, | ||
observer.onCompleted.bind(observer))); | ||
group.add(right.subscribe( | ||
function (value) { | ||
var leftValues, i, len; | ||
var id = rightID++; | ||
rightMap.add(id, value); | ||
var md = new SingleAssignmentDisposable(); | ||
group.add(md); | ||
var expire = function () { | ||
rightMap.remove(id); | ||
group.remove(md); | ||
}; | ||
var duration; | ||
try { | ||
duration = rightDurationSelector(value); | ||
} catch (e) { | ||
leftValues = leftMap.getValues(); | ||
for (i = 0, len = leftMap.length; i < len; i++) { | ||
leftValues[i].onError(e); | ||
} | ||
observer.onError(e); | ||
return; | ||
} | ||
observer.onError(exception); | ||
return; | ||
} | ||
md.disposable(duration.take(1).subscribe(noop, function (exn) { | ||
md.setDisposable(duration.take(1).subscribe( | ||
nothing, | ||
function (e) { | ||
leftValues = leftMap.getValues(); | ||
for (i = 0, len = leftMap.length; i < len; i++) { | ||
leftValues[i].onError(e); | ||
} | ||
observer.onError(e); | ||
}, | ||
expire) | ||
); | ||
leftValues = leftMap.getValues(); | ||
for (var idx = 0; idx < leftValues.length; idx++) { | ||
leftValues[idx].onError(exn); | ||
for (i = 0, len = leftValues.length; i < len; i++) { | ||
leftValues[i].onNext(value); | ||
} | ||
observer.onError(exn); | ||
}, function () { | ||
expire(); | ||
}, | ||
function (e) { | ||
var leftValues = leftMap.getValues(); | ||
for (var i = 0, len = leftValues.length; i < len; i++) { | ||
leftValues[i].onError(e); | ||
} | ||
observer.onError(e); | ||
})); | ||
leftValues = leftMap.getValues(); | ||
for (i = 0; i < leftValues.length; i++) { | ||
leftValues[i].onNext(value); | ||
} | ||
}, function (exception) { | ||
var i, leftValues; | ||
leftValues = leftMap.getValues(); | ||
for (i = 0; i < leftValues.length; i++) { | ||
leftValues[i].onError(exception); | ||
} | ||
observer.onError(exception); | ||
})); | ||
return r; | ||
}); | ||
}; | ||
} | ||
@@ -268,3 +288,3 @@ /** | ||
}); | ||
}; | ||
} | ||
@@ -347,2 +367,2 @@ function observableWindowWithBounaries(windowBoundaries) { | ||
}); | ||
}; | ||
} |
@@ -200,3 +200,3 @@ /** | ||
scheduler || (scheduler = currentThreadScheduler); | ||
if (repeatCount == undefined) { | ||
if (repeatCount == null) { | ||
repeatCount = -1; | ||
@@ -203,0 +203,0 @@ } |
@@ -220,3 +220,3 @@ | ||
})); | ||
})(idx); | ||
}(idx)); | ||
} | ||
@@ -571,2 +571,3 @@ | ||
isDone = arrayInitialize(n, function () { return false; }); | ||
var next = function (i) { | ||
@@ -583,3 +584,3 @@ var res, queuedValues; | ||
observer.onNext(res); | ||
} else if (isDone.filter(function (x, j) { return j !== i; }).every(function (x) { return x; })) { | ||
} else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) { | ||
observer.onCompleted(); | ||
@@ -618,12 +619,67 @@ } | ||
* @memberOf Observable | ||
* @param {Array} sources Observable sources. | ||
* @param arguments Observable sources. | ||
* @param {Function} resultSelector Function to invoke for each series of elements at corresponding indexes in the sources. | ||
* @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function. | ||
*/ | ||
Observable.zip = function (sources, resultSelector) { | ||
var first = sources[0], | ||
rest = sources.slice(1); | ||
rest.push(resultSelector); | ||
return first.zip.apply(first, rest); | ||
Observable.zip = function () { | ||
var args = slice.call(arguments, 0), | ||
first = args.shift(); | ||
return first.zip.apply(first, args); | ||
}; | ||
/** | ||
* Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes. | ||
* | ||
* @static | ||
* @memberOf Observable | ||
* @param arguments Observable sources. | ||
* @returns {Observable} An observable sequence containing lists of elements at corresponding indexes. | ||
*/ | ||
Observable.zipArray = function () { | ||
var sources = slice.call(arguments); | ||
return new AnonymousObservable(function (observer) { | ||
var n = sources.length, | ||
queues = arrayInitialize(n, function () { return []; }), | ||
isDone = arrayInitialize(n, function () { return false; }); | ||
function next(i) { | ||
if (queues.every(function (x) { return x.length > 0; })) { | ||
var res = queues.map(function (x) { return x.shift(); }); | ||
observer.onNext(res); | ||
} else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) { | ||
observer.onCompleted(); | ||
return; | ||
} | ||
}; | ||
function done(i) { | ||
isDone[i] = true; | ||
if (isDone.every(identity)) { | ||
observer.onCompleted(); | ||
return; | ||
} | ||
} | ||
var subscriptions = new Array(n); | ||
for (var idx = 0; idx < n; idx++) { | ||
(function (i) { | ||
subscriptions[i] = new SingleAssignmentDisposable(); | ||
subscriptions[i].setDisposable(sources[i].subscribe(function (x) { | ||
queues[i].push(x); | ||
next(i); | ||
}, observer.onError.bind(observer), function () { | ||
done(i); | ||
})); | ||
})(idx); | ||
} | ||
var compositeDisposable = new CompositeDisposable(subscriptions); | ||
compositeDisposable.add(disposableCreate(function () { | ||
for (var qIdx = 0, qLen = queues.length; qIdx < qLen; qIdx++) { | ||
queues[qIdx] = []; | ||
} | ||
})); | ||
return compositeDisposable; | ||
}); | ||
}; | ||
@@ -313,3 +313,3 @@ /** | ||
var values, scheduler, start = 0; | ||
if (arguments.length > 0 && arguments[0] != null && arguments[0].now !== undefined) { | ||
if (!!arguments.length && 'now' in Object(arguments[0])) { | ||
scheduler = arguments[0]; | ||
@@ -316,0 +316,0 @@ start = 1; |
@@ -121,3 +121,3 @@ /** | ||
groupDisposable.add(source.subscribe(function (x) { | ||
var duration, durationGroup, element, expire, fireNewMapEntry, group, key, serializedKey, md, writer, w; | ||
var duration, durationGroup, element, fireNewMapEntry, group, key, serializedKey, md, writer, w; | ||
try { | ||
@@ -163,3 +163,3 @@ key = keySelector(x); | ||
groupDisposable.add(md); | ||
expire = function () { | ||
var expire = function () { | ||
if (serializedKey in map) { | ||
@@ -166,0 +166,0 @@ delete map[serializedKey]; |
@@ -27,3 +27,3 @@ function observableTimerDate(dueTime, scheduler) { | ||
}); | ||
}; | ||
} | ||
@@ -38,3 +38,3 @@ function observableTimerTimeSpan(dueTime, scheduler) { | ||
}); | ||
}; | ||
} | ||
@@ -53,3 +53,3 @@ function observableTimerTimeSpanAndPeriod(dueTime, period, scheduler) { | ||
}); | ||
}; | ||
} | ||
@@ -179,3 +179,3 @@ /** | ||
}); | ||
}; | ||
} | ||
@@ -554,5 +554,5 @@ function observableDelayDate(dueTime, scheduler) { | ||
sampler.subscribe(sampleSubscribe, observer.onError.bind(observer), sampleSubscribe) | ||
) | ||
); | ||
}); | ||
}; | ||
} | ||
@@ -559,0 +559,0 @@ /** |
@@ -74,5 +74,5 @@ var observableProto; | ||
return this.scan([], accumulator).startWith([]).finalValue(); | ||
} | ||
}; | ||
return Observable; | ||
})(); |
(function (root, factory) { | ||
var freeExports = typeof exports == 'object' && exports && | ||
(typeof root == 'object' && root && root == root.global && (window = root), exports); | ||
var freeExports = typeof exports == 'object' && exports, | ||
freeModule = typeof module == 'object' && module && module.exports == freeExports && module, | ||
freeGlobal = typeof global == 'object' && global; | ||
if (freeGlobal.global === freeGlobal) { | ||
window = freeGlobal; | ||
} | ||
@@ -11,3 +15,3 @@ // Because of build optimizers | ||
}); | ||
} else if (typeof module == 'object' && module && module.exports == freeExports) { | ||
} else if (typeof module === 'object' && module && module.exports === freeExports) { | ||
module.exports = factory(root, module.exports, require('./rx')); | ||
@@ -14,0 +18,0 @@ } else { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
201
1572359
7
147
30304
2
1