rxjs-rails 2.3.22 → 2.3.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rxjs/rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/rx.aggregates.js +178 -146
  4. data/vendor/assets/javascripts/rx.aggregates.min.js +1 -1
  5. data/vendor/assets/javascripts/rx.all.compat.js +1706 -1156
  6. data/vendor/assets/javascripts/rx.all.compat.min.js +4 -4
  7. data/vendor/assets/javascripts/rx.all.js +1529 -1125
  8. data/vendor/assets/javascripts/rx.all.min.js +4 -3
  9. data/vendor/assets/javascripts/rx.async.compat.js +15 -79
  10. data/vendor/assets/javascripts/rx.async.compat.min.js +1 -1
  11. data/vendor/assets/javascripts/rx.async.js +15 -79
  12. data/vendor/assets/javascripts/rx.async.min.js +1 -1
  13. data/vendor/assets/javascripts/rx.backpressure.js +38 -15
  14. data/vendor/assets/javascripts/rx.backpressure.min.js +1 -1
  15. data/vendor/assets/javascripts/rx.binding.js +42 -54
  16. data/vendor/assets/javascripts/rx.binding.min.js +1 -1
  17. data/vendor/assets/javascripts/rx.coincidence.js +6 -6
  18. data/vendor/assets/javascripts/rx.coincidence.min.js +1 -1
  19. data/vendor/assets/javascripts/rx.compat.js +1234 -828
  20. data/vendor/assets/javascripts/rx.compat.min.js +2 -2
  21. data/vendor/assets/javascripts/rx.experimental.js +12 -6
  22. data/vendor/assets/javascripts/rx.experimental.min.js +1 -1
  23. data/vendor/assets/javascripts/rx.joinpatterns.js +15 -11
  24. data/vendor/assets/javascripts/rx.joinpatterns.min.js +1 -1
  25. data/vendor/assets/javascripts/rx.js +1159 -791
  26. data/vendor/assets/javascripts/rx.lite.compat.js +1264 -920
  27. data/vendor/assets/javascripts/rx.lite.compat.min.js +2 -2
  28. data/vendor/assets/javascripts/rx.lite.extras.js +99 -27
  29. data/vendor/assets/javascripts/rx.lite.extras.min.js +1 -1
  30. data/vendor/assets/javascripts/rx.lite.js +1192 -886
  31. data/vendor/assets/javascripts/rx.lite.min.js +2 -2
  32. data/vendor/assets/javascripts/rx.min.js +2 -2
  33. data/vendor/assets/javascripts/rx.testing.js +64 -63
  34. data/vendor/assets/javascripts/rx.testing.min.js +1 -1
  35. data/vendor/assets/javascripts/rx.time.js +32 -35
  36. data/vendor/assets/javascripts/rx.time.min.js +1 -1
  37. metadata +3 -3
@@ -1,4 +1,4 @@
1
1
  /* Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.*/
2
- (function(a){function b(){if(this.isDisposed)throw new Error(fb)}function c(a,b){if(gb&&b.stack&&"object"==typeof a&&null!==a&&a.stack&&-1===a.stack.indexOf(kb)){for(var c=[],e=b;e;e=e.source)e.stack&&c.unshift(e.stack);c.unshift(a.stack);var f=c.join("\n"+kb+"\n");a.stack=d(f)}}function d(a){for(var b=a.split("\n"),c=[],d=0,g=b.length;g>d;d++){var h=b[d];e(h)||f(h)||!h||c.push(h)}return c.join("\n")}function e(a){var b=h(a);if(!b)return!1;var c=b[0],d=b[1];return c===ib&&d>=jb&&bd>=d}function f(a){return-1!==a.indexOf("(module.js:")||-1!==a.indexOf("(node.js:")}function g(){if(gb)try{throw new Error}catch(a){var b=a.stack.split("\n"),c=b[0].indexOf("@")>0?b[1]:b[2],d=h(c);if(!d)return;return ib=d[0],d[1]}}function h(a){var b=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(a);if(b)return[b[1],Number(b[2])];var c=/at ([^ ]+):(\d+):(?:\d+)$/.exec(a);if(c)return[c[1],Number(c[2])];var d=/.*@(.+):(\d+)$/.exec(a);return d?[d[1],Number(d[2])]:void 0}function i(a){var b=typeof a;return a&&("function"==b||"object"==b)||!1}function j(a){var b=[];if(!i(a))return b;Kb.nonEnumArgs&&a.length&&Lb(a)&&(a=Nb.call(a));var c=Kb.enumPrototypes&&"function"==typeof a,d=Kb.enumErrorProps&&(a===Eb||a instanceof Error);for(var e in a)c&&"prototype"==e||d&&("message"==e||"name"==e)||b.push(e);if(Kb.nonEnumShadows&&a!==Fb){var f=a.constructor,g=-1,h=Ib.length;if(a===(f&&f.prototype))var j=a===Gb?Ab:a===Eb?vb:Bb.call(a),k=Jb[j];for(;++g<h;)e=Ib[g],k&&k[e]||!Cb.call(a,e)||b.push(e)}return b}function k(a,b,c){for(var d=-1,e=c(a),f=e.length;++d<f;){var g=e[d];if(b(a[g],g,a)===!1)break}return a}function l(a,b){return k(a,b,j)}function m(a){return"function"!=typeof a.toString&&"string"==typeof(a+"")}function n(a,b,c,d){if(a===b)return 0!==a||1/a==1/b;var e=typeof a,f=typeof b;if(a===a&&(null==a||null==b||"function"!=e&&"object"!=e&&"function"!=f&&"object"!=f))return!1;var g=Bb.call(a),h=Bb.call(b);if(g==rb&&(g=yb),h==rb&&(h=yb),g!=h)return!1;switch(g){case tb:case ub:return+a==+b;case xb:return a!=+a?b!=+b:0==a?1/a==1/b:a==+b;case zb:case Ab:return a==String(b)}var i=g==sb;if(!i){if(g!=yb||!Kb.nodeClass&&(m(a)||m(b)))return!1;var j=!Kb.argsObject&&Lb(a)?Object:a.constructor,k=!Kb.argsObject&&Lb(b)?Object:b.constructor;if(!(j==k||Cb.call(a,"constructor")&&Cb.call(b,"constructor")||db(j)&&j instanceof j&&db(k)&&k instanceof k||!("constructor"in a&&"constructor"in b)))return!1}c||(c=[]),d||(d=[]);for(var o=c.length;o--;)if(c[o]==a)return d[o]==b;var p=0,q=!0;if(c.push(a),d.push(b),i){if(o=a.length,p=b.length,q=p==o)for(;p--;){var r=b[p];if(!(q=n(a[p],r,c,d)))break}}else l(b,function(b,e,f){return Cb.call(f,e)?(p++,q=Cb.call(a,e)&&n(a[e],b,c,d)):void 0}),q&&l(a,function(a,b,c){return Cb.call(c,b)?q=--p>-1:void 0});return c.pop(),d.pop(),q}function o(a,b){return 1===a.length&&Array.isArray(a[b])?a[b]:Nb.call(a)}function p(a,b){for(var c=new Array(a),d=0;a>d;d++)c[d]=b();return c}function q(a,b){this.id=a,this.value=b}function r(){this._s=s}function t(){this._s=s,this._l=s.length,this._i=0}function u(a){this._a=a}function v(a){this._a=a,this._l=z(a),this._i=0}function w(a){return"number"==typeof a&&R.isFinite(a)}function x(b){var c,d=b[lb];if(!d&&"string"==typeof b)return c=new r(b),c[lb]();if(!d&&b.length!==a)return c=new u(b),c[lb]();if(!d)throw new TypeError("Object is not iterable");return b[lb]()}function y(a){var b=+a;return 0===b?b:isNaN(b)?b:0>b?-1:1}function z(a){var b=+a.length;return isNaN(b)?0:0!==b&&w(b)?(b=y(b)*Math.floor(Math.abs(b)),0>=b?0:b>Bc?Bc:b):b}function A(a,b){return Y(a)||(a=ec),new Vc(function(c){var d=0,e=b.length;return a.scheduleRecursive(function(a){e>d?(c.onNext(b[d++]),a()):c.onCompleted()})})}function B(a,b){return new Vc(function(c){var d=new Zb,e=new $b;return e.setDisposable(d),d.setDisposable(a.subscribe(c.onNext.bind(c),function(a){var d,f;try{f=b(a)}catch(g){return void c.onError(g)}cb(f)&&(f=Oc(f)),d=new Zb,e.setDisposable(d),d.setDisposable(f.subscribe(c))},c.onCompleted.bind(c))),e},a)}function C(a,b){var c=this;return new Vc(function(d){var e=0,f=a.length;return c.subscribe(function(c){if(f>e){var g,h=a[e++];try{g=b(c,h)}catch(i){return void d.onError(i)}d.onNext(g)}else d.onCompleted()},d.onError.bind(d),d.onCompleted.bind(d))},c)}function D(a,b,c){return a.map(function(d,e){var f=b.call(c,d,e,a);return cb(f)&&(f=Oc(f)),(ob(f)||nb(f))&&(f=Cc(f)),f}).concatAll()}function E(a,b,c){return a.map(function(d,e){var f=b.call(c,d,e,a);return cb(f)&&(f=Oc(f)),(ob(f)||nb(f))&&(f=Cc(f)),f}).mergeAll()}function F(a){var b=function(){this.cancelBubble=!0},c=function(){if(this.bubbledKeyCode=this.keyCode,this.ctrlKey)try{this.keyCode=0}catch(a){}this.defaultPrevented=!0,this.returnValue=!1,this.modified=!0};if(a||(a=R.event),!a.target)switch(a.target=a.target||a.srcElement,"mouseover"==a.type&&(a.relatedTarget=a.fromElement),"mouseout"==a.type&&(a.relatedTarget=a.toElement),a.stopPropagation||(a.stopPropagation=b,a.preventDefault=c),a.type){case"keypress":var d="charCode"in a?a.charCode:a.keyCode;10==d?(d=0,a.keyCode=13):13==d||27==d?d=0:3==d&&(d=99),a.charCode=d,a.keyChar=a.charCode?String.fromCharCode(a.charCode):""}return a}function G(a,b,c){if(a.addEventListener)return a.addEventListener(b,c,!1),Xb(function(){a.removeEventListener(b,c,!1)});if(a.attachEvent){var d=function(a){c(F(a))};return a.attachEvent("on"+b,d),Xb(function(){a.detachEvent("on"+b,d)})}return a["on"+b]=c,Xb(function(){a["on"+b]=null})}function H(a,b,c){var d=new Ub;if("[object NodeList]"===Object.prototype.toString.call(a))for(var e=0,f=a.length;f>e;e++)d.add(H(a.item(e),b,c));else a&&d.add(G(a,b,c));return d}function I(a,b){return new Vc(function(c){return b.scheduleWithAbsolute(a,function(){c.onNext(0),c.onCompleted()})})}function J(a,b,c){return new Vc(function(d){var e=0,f=a,g=bc(b);return c.scheduleRecursiveWithAbsolute(f,function(a){if(g>0){var b=c.now();f+=g,b>=f&&(f=b+g)}d.onNext(e++),a(f)})})}function K(a,b){return new Vc(function(c){return b.scheduleWithRelative(bc(a),function(){c.onNext(0),c.onCompleted()})})}function L(a,b,c){return a===b?new Vc(function(a){return c.schedulePeriodicWithState(0,b,function(b){return a.onNext(b),b+1})}):zc(function(){return J(c.now()+a,b,c)})}function M(a,b,c){return new Vc(function(d){var e,f=!1,g=new $b,h=null,i=[],j=!1;return e=a.materialize().timestamp(c).subscribe(function(a){var e,k;"E"===a.value.kind?(i=[],i.push(a),h=a.value.exception,k=!j):(i.push({value:a.value,timestamp:a.timestamp+b}),k=!f,f=!0),k&&(null!==h?d.onError(h):(e=new Zb,g.setDisposable(e),e.setDisposable(c.scheduleRecursiveWithRelative(b,function(a){var b,e,g,k;if(null===h){j=!0;do g=null,i.length>0&&i[0].timestamp-c.now()<=0&&(g=i.shift().value),null!==g&&g.accept(d);while(null!==g);k=!1,e=0,i.length>0?(k=!0,e=Math.max(0,i[0].timestamp-c.now())):f=!1,b=h,j=!1,null!==b?d.onError(b):k&&a(e)}}))))}),new Ub(e,g)},a)}function N(a,b,c){return zc(function(){return M(a,b-c.now(),c)})}function O(a,b){return new Vc(function(c){function d(){g&&(g=!1,c.onNext(f)),e&&c.onCompleted()}var e,f,g;return new Ub(a.subscribe(function(a){g=!0,f=a},c.onError.bind(c),function(){e=!0}),b.subscribe(d,c.onError.bind(c),d))},a)}function P(a,b,c){return new Vc(function(d){function e(a,b){j[b]=a;var e;if(g[b]=!0,h||(h=g.every(Z))){if(f)return void d.onError(f);try{e=c.apply(null,j)}catch(k){return void d.onError(k)}d.onNext(e)}i&&j[1]&&d.onCompleted()}var f,g=[!1,!1],h=!1,i=!1,j=new Array(2);return new Ub(a.subscribe(function(a){e(a,0)},function(a){j[1]?d.onError(a):f=a},function(){i=!0,j[1]&&d.onCompleted()}),b.subscribe(function(a){e(a,1)},d.onError.bind(d),function(){i=!0,e(!0,1)}))},a)}var Q={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},R=Q[typeof window]&&window||this,S=Q[typeof exports]&&exports&&!exports.nodeType&&exports,T=Q[typeof module]&&module&&!module.nodeType&&module,U=T&&T.exports===S&&S,V=Q[typeof global]&&global;!V||V.global!==V&&V.window!==V||(R=V);var W={internals:{},config:{Promise:R.Promise},helpers:{}},X=W.helpers.noop=function(){},Y=(W.helpers.notDefined=function(a){return"undefined"==typeof a},W.helpers.isScheduler=function(a){return a instanceof W.Scheduler}),Z=W.helpers.identity=function(a){return a},$=(W.helpers.pluck=function(a){return function(b){return b[a]}},W.helpers.just=function(a){return function(){return a}},W.helpers.defaultNow=function(){return Date.now?Date.now:function(){return+new Date}}()),_=W.helpers.defaultComparer=function(a,b){return Mb(a,b)},ab=W.helpers.defaultSubComparer=function(a,b){return a>b?1:b>a?-1:0},bb=(W.helpers.defaultKeySerializer=function(a){return a.toString()},W.helpers.defaultError=function(a){throw a}),cb=W.helpers.isPromise=function(a){return!!a&&"function"==typeof a.then},db=(W.helpers.asArray=function(){return Array.prototype.slice.call(arguments)},W.helpers.not=function(a){return!a},W.helpers.isFunction=function(){var a=function(a){return"function"==typeof a||!1};return a(/x/)&&(a=function(a){return"function"==typeof a&&"[object Function]"==Bb.call(a)}),a}()),eb="Argument out of range",fb="Object has been disposed";W.config.longStackSupport=!1;var gb=!1;try{throw new Error}catch(hb){gb=!!hb.stack}var ib,jb=g(),kb="From previous event:",lb="function"==typeof Symbol&&Symbol.iterator||"_es6shim_iterator_";R.Set&&"function"==typeof(new R.Set)["@@iterator"]&&(lb="@@iterator");var mb=W.doneEnumerator={done:!0,value:a},nb=W.helpers.isIterable=function(b){return b[lb]!==a},ob=W.helpers.isArrayLike=function(b){return b&&b.length!==a};W.helpers.iterator=lb;var pb,qb=W.helpers.deprecate=function(){},rb="[object Arguments]",sb="[object Array]",tb="[object Boolean]",ub="[object Date]",vb="[object Error]",wb="[object Function]",xb="[object Number]",yb="[object Object]",zb="[object RegExp]",Ab="[object String]",Bb=Object.prototype.toString,Cb=Object.prototype.hasOwnProperty,Db=Bb.call(arguments)==rb,Eb=Error.prototype,Fb=Object.prototype,Gb=String.prototype,Hb=Fb.propertyIsEnumerable;Hb||(Hb=Fb.propertyIsEnumerable=function(a){for(var b in this)if(b===a)return!0;return!1});try{pb=!(Bb.call(document)==yb&&!({toString:0}+""))}catch(hb){pb=!0}var Ib=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Jb={};Jb[sb]=Jb[ub]=Jb[xb]={constructor:!0,toLocaleString:!0,toString:!0,valueOf:!0},Jb[tb]=Jb[Ab]={constructor:!0,toString:!0,valueOf:!0},Jb[vb]=Jb[wb]=Jb[zb]={constructor:!0,toString:!0},Jb[yb]={constructor:!0};var Kb={};!function(){var a=function(){this.x=1},b=[];a.prototype={valueOf:1,y:1};for(var c in new a)b.push(c);for(c in arguments);Kb.enumErrorProps=Hb.call(Eb,"message")||Hb.call(Eb,"name"),Kb.enumPrototypes=Hb.call(a,"prototype"),Kb.nonEnumArgs=0!=c,Kb.nonEnumShadows=!/valueOf/.test(b)}(1);var Lb=function(a){return a&&"object"==typeof a?Bb.call(a)==rb:!1};Db||(Lb=function(a){return a&&"object"==typeof a?Cb.call(a,"callee"):!1});{var Mb=W.internals.isEqual=function(a,b){return n(a,b,[],[])},Nb=Array.prototype.slice,Ob=({}.hasOwnProperty,this.inherits=W.internals.inherits=function(a,b){function c(){this.constructor=a}c.prototype=b.prototype,a.prototype=new c}),Pb=W.internals.addProperties=function(a){for(var b=Nb.call(arguments,1),c=0,d=b.length;d>c;c++){var e=b[c];for(var f in e)a[f]=e[f]}};W.internals.addRef=function(a,b){return new Vc(function(c){return new Ub(b.getDisposable(),a.subscribe(c))})}}Function.prototype.bind||(Function.prototype.bind=function(a){var b=this,c=Nb.call(arguments,1),d=function(){function e(){}if(this instanceof d){e.prototype=b.prototype;var f=new e,g=b.apply(f,c.concat(Nb.call(arguments)));return Object(g)===g?g:f}return b.apply(a,c.concat(Nb.call(arguments)))};return d}),Array.prototype.forEach||(Array.prototype.forEach=function(a,b){var c,d;if(null==this)throw new TypeError(" this is null or not defined");var e=Object(this),f=e.length>>>0;if("function"!=typeof a)throw new TypeError(a+" is not a function");for(arguments.length>1&&(c=b),d=0;f>d;){var g;d in e&&(g=e[d],a.call(c,g,d,e)),d++}});var Qb=Object("a"),Rb="a"!=Qb[0]||!(0 in Qb);Array.prototype.every||(Array.prototype.every=function(a){var b=Object(this),c=Rb&&{}.toString.call(this)==Ab?this.split(""):b,d=c.length>>>0,e=arguments[1];if({}.toString.call(a)!=wb)throw new TypeError(a+" is not a function");for(var f=0;d>f;f++)if(f in c&&!a.call(e,c[f],f,b))return!1;return!0}),Array.prototype.map||(Array.prototype.map=function(a){var b=Object(this),c=Rb&&{}.toString.call(this)==Ab?this.split(""):b,d=c.length>>>0,e=Array(d),f=arguments[1];if({}.toString.call(a)!=wb)throw new TypeError(a+" is not a function");for(var g=0;d>g;g++)g in c&&(e[g]=a.call(f,c[g],g,b));return e}),Array.prototype.filter||(Array.prototype.filter=function(a){for(var b,c=[],d=new Object(this),e=0,f=d.length>>>0;f>e;e++)b=d[e],e in d&&a.call(arguments[1],b,e,d)&&c.push(b);return c}),Array.isArray||(Array.isArray=function(a){return{}.toString.call(a)==sb}),Array.prototype.indexOf||(Array.prototype.indexOf=function(a){var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=0;if(arguments.length>1&&(d=Number(arguments[1]),d!==d?d=0:0!==d&&1/0!=d&&d!==-1/0&&(d=(d>0||-1)*Math.floor(Math.abs(d)))),d>=c)return-1;for(var e=d>=0?d:Math.max(c-Math.abs(d),0);c>e;e++)if(e in b&&b[e]===a)return e;return-1}),q.prototype.compareTo=function(a){var b=this.value.compareTo(a.value);return 0===b&&(b=this.id-a.id),b};var Sb=W.internals.PriorityQueue=function(a){this.items=new Array(a),this.length=0},Tb=Sb.prototype;Tb.isHigherPriority=function(a,b){return this.items[a].compareTo(this.items[b])<0},Tb.percolate=function(a){if(!(a>=this.length||0>a)){var b=a-1>>1;if(!(0>b||b===a)&&this.isHigherPriority(a,b)){var c=this.items[a];this.items[a]=this.items[b],this.items[b]=c,this.percolate(b)}}},Tb.heapify=function(a){if(+a||(a=0),!(a>=this.length||0>a)){var b=2*a+1,c=2*a+2,d=a;if(b<this.length&&this.isHigherPriority(b,d)&&(d=b),c<this.length&&this.isHigherPriority(c,d)&&(d=c),d!==a){var e=this.items[a];this.items[a]=this.items[d],this.items[d]=e,this.heapify(d)}}},Tb.peek=function(){return this.items[0].value},Tb.removeAt=function(a){this.items[a]=this.items[--this.length],delete this.items[this.length],this.heapify()},Tb.dequeue=function(){var a=this.peek();return this.removeAt(0),a},Tb.enqueue=function(a){var b=this.length++;this.items[b]=new q(Sb.count++,a),this.percolate(b)},Tb.remove=function(a){for(var b=0;b<this.length;b++)if(this.items[b].value===a)return this.removeAt(b),!0;return!1},Sb.count=0;var Ub=W.CompositeDisposable=function(){this.disposables=o(arguments,0),this.isDisposed=!1,this.length=this.disposables.length},Vb=Ub.prototype;Vb.add=function(a){this.isDisposed?a.dispose():(this.disposables.push(a),this.length++)},Vb.remove=function(a){var b=!1;if(!this.isDisposed){var c=this.disposables.indexOf(a);-1!==c&&(b=!0,this.disposables.splice(c,1),this.length--,a.dispose())}return b},Vb.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var a=this.disposables.slice(0);this.disposables=[],this.length=0;for(var b=0,c=a.length;c>b;b++)a[b].dispose()}},Vb.toArray=function(){return this.disposables.slice(0)};var Wb=W.Disposable=function(a){this.isDisposed=!1,this.action=a||X};Wb.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var Xb=Wb.create=function(a){return new Wb(a)},Yb=Wb.empty={dispose:X},Zb=W.SingleAssignmentDisposable=function(){function a(){this.isDisposed=!1,this.current=null}var b=a.prototype;return b.getDisposable=function(){return this.current},b.setDisposable=function(a){var b,c=this.isDisposed;c||(b=this.current,this.current=a),b&&b.dispose(),c&&a&&a.dispose()},b.dispose=function(){var a;this.isDisposed||(this.isDisposed=!0,a=this.current,this.current=null),a&&a.dispose()},a}(),$b=W.SerialDisposable=Zb,_b=(W.RefCountDisposable=function(){function a(a){this.disposable=a,this.disposable.count++,this.isInnerDisposed=!1}function b(a){this.underlyingDisposable=a,this.isDisposed=!1,this.isPrimaryDisposed=!1,this.count=0}return a.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()))},b.prototype.dispose=function(){this.isDisposed||this.isPrimaryDisposed||(this.isPrimaryDisposed=!0,0===this.count&&(this.isDisposed=!0,this.underlyingDisposable.dispose()))},b.prototype.getDisposable=function(){return this.isDisposed?Yb:new a(this)},b}(),W.internals.ScheduledItem=function(a,b,c,d,e){this.scheduler=a,this.state=b,this.action=c,this.dueTime=d,this.comparer=e||ab,this.disposable=new Zb});_b.prototype.invoke=function(){this.disposable.setDisposable(this.invokeCore())},_b.prototype.compareTo=function(a){return this.comparer(this.dueTime,a.dueTime)},_b.prototype.isCancelled=function(){return this.disposable.isDisposed},_b.prototype.invokeCore=function(){return this.action(this.scheduler,this.state)};var ac=W.Scheduler=function(){function a(a,b,c,d){this.now=a,this._schedule=b,this._scheduleRelative=c,this._scheduleAbsolute=d}function b(a,b){return b(),Yb}var c=a.prototype;return c.schedule=function(a){return this._schedule(a,b)},c.scheduleWithState=function(a,b){return this._schedule(a,b)},c.scheduleWithRelative=function(a,c){return this._scheduleRelative(c,a,b)},c.scheduleWithRelativeAndState=function(a,b,c){return this._scheduleRelative(a,b,c)},c.scheduleWithAbsolute=function(a,c){return this._scheduleAbsolute(c,a,b)},c.scheduleWithAbsoluteAndState=function(a,b,c){return this._scheduleAbsolute(a,b,c)},a.now=$,a.normalize=function(a){return 0>a&&(a=0),a},a}(),bc=ac.normalize;!function(a){function b(a,b){var c=b.first,d=b.second,e=new Ub,f=function(b){d(b,function(b){var c=!1,d=!1,g=a.scheduleWithState(b,function(a,b){return c?e.remove(g):d=!0,f(b),Yb});d||(e.add(g),c=!0)})};return f(c),e}function c(a,b,c){var d=b.first,e=b.second,f=new Ub,g=function(b){e(b,function(b,d){var e=!1,h=!1,i=a[c].call(a,b,d,function(a,b){return e?f.remove(i):h=!0,g(b),Yb});h||(f.add(i),e=!0)})};return g(d),f}function d(a,b){a(function(c){b(a,c)})}a.scheduleRecursive=function(a){return this.scheduleRecursiveWithState(a,function(a,b){a(function(){b(a)})})},a.scheduleRecursiveWithState=function(a,c){return this.scheduleWithState({first:a,second:c},b)},a.scheduleRecursiveWithRelative=function(a,b){return this.scheduleRecursiveWithRelativeAndState(b,a,d)},a.scheduleRecursiveWithRelativeAndState=function(a,b,d){return this._scheduleRelative({first:a,second:d},b,function(a,b){return c(a,b,"scheduleWithRelativeAndState")})},a.scheduleRecursiveWithAbsolute=function(a,b){return this.scheduleRecursiveWithAbsoluteAndState(b,a,d)},a.scheduleRecursiveWithAbsoluteAndState=function(a,b,d){return this._scheduleAbsolute({first:a,second:d},b,function(a,b){return c(a,b,"scheduleWithAbsoluteAndState")})}}(ac.prototype),function(){ac.prototype.schedulePeriodic=function(a,b){return this.schedulePeriodicWithState(null,a,b)},ac.prototype.schedulePeriodicWithState=function(a,b,c){if("undefined"==typeof R.setInterval)throw new Error("Periodic scheduling not supported.");var d=a,e=R.setInterval(function(){d=c(d)},b);return Xb(function(){R.clearInterval(e)})}}(ac.prototype);var cc,dc=ac.immediate=function(){function a(a,b){return b(this,a)}function b(a,b,c){for(var d=bc(b);d-this.now()>0;);return c(this,a)}function c(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}return new ac($,a,b,c)}(),ec=ac.currentThread=function(){function a(a){for(var b;a.length>0;)if(b=a.dequeue(),!b.isCancelled()){for(;b.dueTime-ac.now()>0;);b.isCancelled()||b.invoke()}}function b(a,b){return this.scheduleWithRelativeAndState(a,0,b)}function c(b,c,d){var f=this.now()+ac.normalize(c),g=new _b(this,b,d,f);if(e)e.enqueue(g);else{e=new Sb(4),e.enqueue(g);try{a(e)}catch(h){throw h}finally{e=null}}return g.disposable}function d(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}var e,f=new ac($,b,c,d);return f.scheduleRequired=function(){return!e},f.ensureTrampoline=function(a){e?a():this.schedule(a)},f}(),fc=(W.internals.SchedulePeriodicRecursive=function(){function a(a,b){b(0,this._period);try{this._state=this._action(this._state)}catch(c){throw this._cancel.dispose(),c}}function b(a,b,c,d){this._scheduler=a,this._state=b,this._period=c,this._action=d}return b.prototype.start=function(){var b=new Zb;return this._cancel=b,b.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,a.bind(this))),b},b}(),X),gc=function(){var a,b=X;if("WScript"in this)a=function(a,b){WScript.Sleep(b),a()};else{if(!R.setTimeout)throw new Error("No concurrency detected!");a=R.setTimeout,b=R.clearTimeout}return{setTimeout:a,clearTimeout:b}}(),hc=gc.setTimeout,ic=gc.clearTimeout;!function(){function a(){if(!R.postMessage||R.importScripts)return!1;var a=!1,b=R.onmessage;return R.onmessage=function(){a=!0},R.postMessage("","*"),R.onmessage=b,a}var b=RegExp("^"+String(Bb).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),c="function"==typeof(c=V&&U&&V.setImmediate)&&!b.test(c)&&c,d="function"==typeof(d=V&&U&&V.clearImmediate)&&!b.test(d)&&d;if("function"==typeof c)cc=c,fc=d;else if("undefined"!=typeof process&&"[object process]"==={}.toString.call(process))cc=process.nextTick;else if(a()){var e="ms.rx.schedule"+Math.random(),f={},g=0,h=function(a){if("string"==typeof a.data&&a.data.substring(0,e.length)===e){var b=a.data.substring(e.length),c=f[b];c(),delete f[b]}};R.addEventListener?R.addEventListener("message",h,!1):R.attachEvent("onmessage",h,!1),cc=function(a){var b=g++;f[b]=a,R.postMessage(e+b,"*")}}else if(R.MessageChannel){var i=new R.MessageChannel,j={},k=0;i.port1.onmessage=function(a){var b=a.data,c=j[b];c(),delete j[b]},cc=function(a){var b=k++;j[b]=a,i.port2.postMessage(b)}}else"document"in R&&"onreadystatechange"in R.document.createElement("script")?cc=function(a){var b=R.document.createElement("script");b.onreadystatechange=function(){a(),b.onreadystatechange=null,b.parentNode.removeChild(b),b=null},R.document.documentElement.appendChild(b)}:(cc=function(a){return hc(a,0)},fc=ic)}();var jc=ac.timeout=function(){function a(a,b){var c=this,d=new Zb,e=cc(function(){d.isDisposed||d.setDisposable(b(c,a))});return new Ub(d,Xb(function(){fc(e)}))}function b(a,b,c){var d=this,e=ac.normalize(b);if(0===e)return d.scheduleWithState(a,c);var f=new Zb,g=hc(function(){f.isDisposed||f.setDisposable(c(d,a))},e);return new Ub(f,Xb(function(){ic(g)}))}function c(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}return new ac($,a,b,c)}(),kc=W.Notification=function(){function a(a,b){this.hasValue=null==b?!1:b,this.kind=a}return a.prototype.accept=function(a,b,c){return a&&"object"==typeof a?this._acceptObservable(a):this._accept(a,b,c)},a.prototype.toObservable=function(a){var b=this;return Y(a)||(a=dc),new Vc(function(c){return a.schedule(function(){b._acceptObservable(c),"N"===b.kind&&c.onCompleted()})})},a}(),lc=kc.createOnNext=function(){function a(a){return a(this.value)}function b(a){return a.onNext(this.value)}function c(){return"OnNext("+this.value+")"}return function(d){var e=new kc("N",!0);return e.value=d,e._accept=a,e._acceptObservable=b,e.toString=c,e}}(),mc=kc.createOnError=function(){function a(a,b){return b(this.exception)}function b(a){return a.onError(this.exception)}function c(){return"OnError("+this.exception+")"}return function(d){var e=new kc("E");return e.exception=d,e._accept=a,e._acceptObservable=b,e.toString=c,e}}(),nc=kc.createOnCompleted=function(){function a(a,b,c){return c()}function b(a){return a.onCompleted()}function c(){return"OnCompleted()"}return function(){var d=new kc("C");return d._accept=a,d._acceptObservable=b,d.toString=c,d}}(),oc=W.internals.Enumerator=function(a){this._next=a};oc.prototype.next=function(){return this._next()},oc.prototype[lb]=function(){return this};var pc=W.internals.Enumerable=function(a){this._iterator=a};pc.prototype[lb]=function(){return this._iterator()},pc.prototype.concat=function(){var a=this;return new Vc(function(b){var c;try{c=a[lb]()}catch(d){return void b.onError(d)}var e,f=new $b,g=dc.scheduleRecursive(function(a){var d;if(!e){try{d=c.next()}catch(g){return void b.onError(g)}if(d.done)return void b.onCompleted();var h=d.value;cb(h)&&(h=Oc(h));var i=new Zb;f.setDisposable(i),i.setDisposable(h.subscribe(b.onNext.bind(b),b.onError.bind(b),function(){a()}))}});return new Ub(f,g,Xb(function(){e=!0}))})},pc.prototype.catchError=function(){var a=this;return new Vc(function(b){var c;try{c=a[lb]()}catch(d){return void b.onError(d)}var e,f,g=new $b,h=dc.scheduleRecursive(function(a){if(!e){var d;try{d=c.next()}catch(h){return void b.onError(h)}if(d.done)return void(f?b.onError(f):b.onCompleted());var i=d.value;cb(i)&&(i=Oc(i));var j=new Zb;g.setDisposable(j),j.setDisposable(i.subscribe(b.onNext.bind(b),function(b){f=b,a()},b.onCompleted.bind(b)))}});return new Ub(g,h,Xb(function(){e=!0}))})};var qc=pc.repeat=function(a,b){return null==b&&(b=-1),new pc(function(){var c=b;return new oc(function(){return 0===c?mb:(c>0&&c--,{done:!1,value:a})})})},rc=pc.of=function(a,b,c){return b||(b=Z),new pc(function(){var d=-1;return new oc(function(){return++d<a.length?{done:!1,value:b.call(c,a[d],d,a)}:mb})})},sc=W.Observer=function(){};sc.prototype.toNotifier=function(){var a=this;return function(b){return b.accept(a)}},sc.prototype.asObserver=function(){return new wc(this.onNext.bind(this),this.onError.bind(this),this.onCompleted.bind(this))};var tc=sc.create=function(a,b,c){return a||(a=X),b||(b=bb),c||(c=X),new wc(a,b,c)};sc.fromNotifier=function(a,b){return new wc(function(c){return a.call(b,lc(c))},function(c){return a.call(b,mc(c))},function(){return a.call(b,nc())})};var uc,vc=W.internals.AbstractObserver=function(a){function b(){this.isStopped=!1,a.call(this)}return Ob(b,a),b.prototype.onNext=function(a){this.isStopped||this.next(a)},b.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.error(a))},b.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.completed())},b.prototype.dispose=function(){this.isStopped=!0},b.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.error(a),!0)},b}(sc),wc=W.AnonymousObserver=function(a){function b(b,c,d){a.call(this),this._onNext=b,this._onError=c,this._onCompleted=d}return Ob(b,a),b.prototype.next=function(a){this._onNext(a)},b.prototype.error=function(a){this._onError(a)},b.prototype.completed=function(){this._onCompleted()},b}(vc),xc=W.Observable=function(){function a(a){if(W.config.longStackSupport&&gb){try{throw new Error}catch(b){this.stack=b.stack.substring(b.stack.indexOf("\n")+1)}var d=this;this._subscribe=function(b){var e=b.onError.bind(b);return b.onError=function(a){c(a,d),e(a)},a(b)}}else this._subscribe=a}return uc=a.prototype,uc.subscribe=uc.forEach=function(a,b,c){return this._subscribe("object"==typeof a?a:tc(a,b,c))},uc.subscribeOnNext=function(a,b){return this._subscribe(tc(2===arguments.length?function(c){a.call(b,c)}:a))},uc.subscribeOnError=function(a,b){return this._subscribe(tc(null,2===arguments.length?function(c){a.call(b,c)}:a))},uc.subscribeOnCompleted=function(a,b){return this._subscribe(tc(null,null,2===arguments.length?function(){a.call(b)}:a))},a}(),yc=W.internals.ScheduledObserver=function(a){function b(b,c){a.call(this),this.scheduler=b,this.observer=c,this.isAcquired=!1,this.hasFaulted=!1,this.queue=[],this.disposable=new $b}return Ob(b,a),b.prototype.next=function(a){var b=this;this.queue.push(function(){b.observer.onNext(a)})},b.prototype.error=function(a){var b=this;this.queue.push(function(){b.observer.onError(a)})},b.prototype.completed=function(){var a=this;this.queue.push(function(){a.observer.onCompleted()})},b.prototype.ensureActive=function(){var a=!1,b=this;!this.hasFaulted&&this.queue.length>0&&(a=!this.isAcquired,this.isAcquired=!0),a&&this.disposable.setDisposable(this.scheduler.scheduleRecursive(function(a){var c;if(!(b.queue.length>0))return void(b.isAcquired=!1);c=b.queue.shift();try{c()}catch(d){throw b.queue=[],b.hasFaulted=!0,d}a()}))},b.prototype.dispose=function(){a.prototype.dispose.call(this),this.disposable.dispose()},b}(vc);uc.toArray=function(){var a=this;return new Vc(function(b){var c=[];return a.subscribe(c.push.bind(c),b.onError.bind(b),function(){b.onNext(c),b.onCompleted()})},a)},xc.create=xc.createWithDisposable=function(a,b){return new Vc(a,b)};var zc=xc.defer=function(a){return new Vc(function(b){var c;try{c=a()}catch(d){return Fc(d).subscribe(b)}return cb(c)&&(c=Oc(c)),c.subscribe(b)})},Ac=xc.empty=function(a){return Y(a)||(a=dc),new Vc(function(b){return a.schedule(function(){b.onCompleted()})})},Bc=Math.pow(2,53)-1;r.prototype[lb]=function(){return new t(this._s)},t.prototype[lb]=function(){return this},t.prototype.next=function(){if(this._i<this._l){var a=this._s.charAt(this._i++);return{done:!1,value:a}}return mb},u.prototype[lb]=function(){return new v(this._a)},v.prototype[lb]=function(){return this},v.prototype.next=function(){if(this._i<this._l){var a=this._a[this._i++];return{done:!1,value:a}}return mb};{var Cc=xc.from=function(a,b,c,d){if(null==a)throw new Error("iterable cannot be null.");if(b&&!db(b))throw new Error("mapFn when provided must be a function");Y(d)||(d=ec);var e=Object(a),f=x(e);return new Vc(function(a){var e=0;return d.scheduleRecursive(function(d){var g;try{g=f.next()}catch(h){return void a.onError(h)}if(g.done)return void a.onCompleted();var i=g.value;if(b&&db(b))try{i=b.call(c,i,e)}catch(h){return void a.onError(h)}a.onNext(i),e++,d()})})},Dc=xc.fromArray=function(a,b){return qb("fromArray","from"),Y(b)||(b=ec),new Vc(function(c){var d=0,e=a.length;return b.scheduleRecursive(function(b){e>d?(c.onNext(a[d++]),b()):c.onCompleted()})})};xc.never=function(){return new Vc(function(){return Yb})}}xc.of=function(){return A(null,arguments)},xc.ofWithScheduler=function(a){return A(a,Nb.call(arguments,1))},xc.range=function(a,b,c){return Y(c)||(c=ec),new Vc(function(d){return c.scheduleRecursiveWithState(0,function(c,e){b>c?(d.onNext(a+c),e(c+1)):d.onCompleted()})})},xc.repeat=function(a,b,c){return Y(c)||(c=ec),Ec(a,c).repeat(null==b?-1:b)};var Ec=xc["return"]=xc.just=function(a,b){return Y(b)||(b=dc),new Vc(function(c){return b.schedule(function(){c.onNext(a),c.onCompleted()})})};xc.returnValue=function(){return qb("returnValue","return or just"),Ec.apply(null,arguments)};var Fc=xc["throw"]=xc.throwException=xc.throwError=function(a,b){return Y(b)||(b=dc),new Vc(function(c){return b.schedule(function(){c.onError(a)})})};uc["catch"]=uc.catchError=function(a){return"function"==typeof a?B(this,a):Gc([this,a])},uc.catchException=function(a){return qb("catchException","catch or catchError"),this.catchError(a)};var Gc=xc.catchError=xc["catch"]=function(){return rc(o(arguments,0)).catchError()};xc.catchException=function(){return qb("catchException","catch or catchError"),Gc.apply(null,arguments)},uc.combineLatest=function(){var a=Nb.call(arguments);return Array.isArray(a[0])?a[0].unshift(this):a.unshift(this),Hc.apply(this,a)};var Hc=xc.combineLatest=function(){var a=Nb.call(arguments),b=a.pop();return Array.isArray(a[0])&&(a=a[0]),new Vc(function(c){function d(a){var d;if(h[a]=!0,i||(i=h.every(Z))){try{d=b.apply(null,k)}catch(e){return void c.onError(e)}c.onNext(d)}else j.filter(function(b,c){return c!==a}).every(Z)&&c.onCompleted()}function e(a){j[a]=!0,j.every(Z)&&c.onCompleted()}for(var f=function(){return!1},g=a.length,h=p(g,f),i=!1,j=p(g,f),k=new Array(g),l=new Array(g),m=0;g>m;m++)!function(b){var f=a[b],g=new Zb;cb(f)&&(f=Oc(f)),g.setDisposable(f.subscribe(function(a){k[b]=a,d(b)},c.onError.bind(c),function(){e(b)})),l[b]=g}(m);return new Ub(l)},this)};uc.concat=function(){var a=Nb.call(arguments,0);return a.unshift(this),Ic.apply(this,a)};var Ic=xc.concat=function(){return rc(o(arguments,0)).concat()};uc.concatAll=function(){return this.merge(1)},uc.concatObservable=function(){return qb("concatObservable","concatAll"),this.merge(1)},uc.merge=function(a){if("number"!=typeof a)return Jc(this,a);
3
- var b=this;return new Vc(function(c){function d(a){var b=new Zb;f.add(b),cb(a)&&(a=Oc(a)),b.setDisposable(a.subscribe(c.onNext.bind(c),c.onError.bind(c),function(){f.remove(b),h.length>0?d(h.shift()):(e--,g&&0===e&&c.onCompleted())}))}var e=0,f=new Ub,g=!1,h=[];return f.add(b.subscribe(function(b){a>e?(e++,d(b)):h.push(b)},c.onError.bind(c),function(){g=!0,0===e&&c.onCompleted()})),f},b)};var Jc=xc.merge=function(){var a,b;return arguments[0]?Y(arguments[0])?(a=arguments[0],b=Nb.call(arguments,1)):(a=dc,b=Nb.call(arguments,0)):(a=dc,b=Nb.call(arguments,1)),Array.isArray(b[0])&&(b=b[0]),A(a,b).mergeAll()};uc.mergeAll=function(){var a=this;return new Vc(function(b){var c=new Ub,d=!1,e=new Zb;return c.add(e),e.setDisposable(a.subscribe(function(a){var e=new Zb;c.add(e),cb(a)&&(a=Oc(a)),e.setDisposable(a.subscribe(b.onNext.bind(b),b.onError.bind(b),function(){c.remove(e),d&&1===c.length&&b.onCompleted()}))},b.onError.bind(b),function(){d=!0,1===c.length&&b.onCompleted()})),c},a)},uc.mergeObservable=function(){return qb("mergeObservable","mergeAll"),this.mergeAll.apply(this,arguments)},uc.skipUntil=function(a){var b=this;return new Vc(function(c){var d=!1,e=new Ub(b.subscribe(function(a){d&&c.onNext(a)},c.onError.bind(c),function(){d&&c.onCompleted()}));cb(a)&&(a=Oc(a));var f=new Zb;return e.add(f),f.setDisposable(a.subscribe(function(){d=!0,f.dispose()},c.onError.bind(c),function(){f.dispose()})),e},b)},uc["switch"]=uc.switchLatest=function(){var a=this;return new Vc(function(b){var c=!1,d=new $b,e=!1,f=0,g=a.subscribe(function(a){var g=new Zb,h=++f;c=!0,d.setDisposable(g),cb(a)&&(a=Oc(a)),g.setDisposable(a.subscribe(function(a){f===h&&b.onNext(a)},function(a){f===h&&b.onError(a)},function(){f===h&&(c=!1,e&&b.onCompleted())}))},b.onError.bind(b),function(){e=!0,!c&&b.onCompleted()});return new Ub(g,d)},a)},uc.takeUntil=function(a){var b=this;return new Vc(function(c){return cb(a)&&(a=Oc(a)),new Ub(b.subscribe(c),a.subscribe(c.onCompleted.bind(c),c.onError.bind(c),X))},b)},uc.zip=function(){if(Array.isArray(arguments[0]))return C.apply(this,arguments);var a=this,b=Nb.call(arguments),c=b.pop();return b.unshift(a),new Vc(function(d){function e(b){var e,f;if(h.every(function(a){return a.length>0})){try{f=h.map(function(a){return a.shift()}),e=c.apply(a,f)}catch(g){return void d.onError(g)}d.onNext(e)}else i.filter(function(a,c){return c!==b}).every(Z)&&d.onCompleted()}function f(a){i[a]=!0,i.every(function(a){return a})&&d.onCompleted()}for(var g=b.length,h=p(g,function(){return[]}),i=p(g,function(){return!1}),j=new Array(g),k=0;g>k;k++)!function(a){var c=b[a],g=new Zb;cb(c)&&(c=Oc(c)),g.setDisposable(c.subscribe(function(b){h[a].push(b),e(a)},d.onError.bind(d),function(){f(a)})),j[a]=g}(k);return new Ub(j)},a)},xc.zip=function(){var a=Nb.call(arguments,0),b=a.shift();return b.zip.apply(b,a)},xc.zipArray=function(){var a=o(arguments,0);return new Vc(function(b){function c(a){if(f.every(function(a){return a.length>0})){var c=f.map(function(a){return a.shift()});b.onNext(c)}else if(g.filter(function(b,c){return c!==a}).every(Z))return void b.onCompleted()}function d(a){return g[a]=!0,g.every(Z)?void b.onCompleted():void 0}for(var e=a.length,f=p(e,function(){return[]}),g=p(e,function(){return!1}),h=new Array(e),i=0;e>i;i++)!function(e){h[e]=new Zb,h[e].setDisposable(a[e].subscribe(function(a){f[e].push(a),c(e)},b.onError.bind(b),function(){d(e)}))}(i);var j=new Ub(h);return j.add(Xb(function(){for(var a=0,b=f.length;b>a;a++)f[a]=[]})),j})},uc.asObservable=function(){return new Vc(this.subscribe.bind(this),this)},uc.dematerialize=function(){var a=this;return new Vc(function(b){return a.subscribe(function(a){return a.accept(b)},b.onError.bind(b),b.onCompleted.bind(b))},this)},uc.distinctUntilChanged=function(a,b){var c=this;return a||(a=Z),b||(b=_),new Vc(function(d){var e,f=!1;return c.subscribe(function(c){var g,h=!1;try{g=a(c)}catch(i){return void d.onError(i)}if(f)try{h=b(e,g)}catch(i){return void d.onError(i)}f&&h||(f=!0,e=g,d.onNext(c))},d.onError.bind(d),d.onCompleted.bind(d))},this)},uc["do"]=uc.tap=function(a,b,c){var d,e=this;return"function"==typeof a?d=a:(d=a.onNext.bind(a),b=a.onError.bind(a),c=a.onCompleted.bind(a)),new Vc(function(a){return e.subscribe(function(b){try{d(b)}catch(c){a.onError(c)}a.onNext(b)},function(c){if(b)try{b(c)}catch(d){a.onError(d)}a.onError(c)},function(){if(c)try{c()}catch(b){a.onError(b)}a.onCompleted()})},this)},uc.doAction=function(){return qb("doAction","do or tap"),this.tap.apply(this,arguments)},uc.doOnNext=uc.tapOnNext=function(a,b){return this.tap(2===arguments.length?function(c){a.call(b,c)}:a)},uc.doOnError=uc.tapOnError=function(a,b){return this.tap(X,2===arguments.length?function(c){a.call(b,c)}:a)},uc.doOnCompleted=uc.tapOnCompleted=function(a,b){return this.tap(X,null,2===arguments.length?function(){a.call(b)}:a)},uc["finally"]=uc.ensure=function(a){var b=this;return new Vc(function(c){var d;try{d=b.subscribe(c)}catch(e){throw a(),e}return Xb(function(){try{d.dispose()}catch(b){throw b}finally{a()}})},this)},uc.finallyAction=function(a){return qb("finallyAction","finally or ensure"),this.ensure(a)},uc.ignoreElements=function(){var a=this;return new Vc(function(b){return a.subscribe(X,b.onError.bind(b),b.onCompleted.bind(b))},a)},uc.materialize=function(){var a=this;return new Vc(function(b){return a.subscribe(function(a){b.onNext(lc(a))},function(a){b.onNext(mc(a)),b.onCompleted()},function(){b.onNext(nc()),b.onCompleted()})},a)},uc.repeat=function(a){return qc(this,a).concat()},uc.retry=function(a){return qc(this,a).catchError()},uc.scan=function(){var a,b,c=!1,d=this;return 2===arguments.length?(c=!0,a=arguments[0],b=arguments[1]):b=arguments[0],new Vc(function(e){var f,g,h;return d.subscribe(function(d){!h&&(h=!0);try{f?g=b(g,d):(g=c?b(a,d):d,f=!0)}catch(i){return void e.onError(i)}e.onNext(g)},e.onError.bind(e),function(){!h&&c&&e.onNext(a),e.onCompleted()})},d)},uc.skipLast=function(a){var b=this;return new Vc(function(c){var d=[];return b.subscribe(function(b){d.push(b),d.length>a&&c.onNext(d.shift())},c.onError.bind(c),c.onCompleted.bind(c))},b)},uc.startWith=function(){var a,b,c=0;return arguments.length&&Y(arguments[0])?(b=arguments[0],c=1):b=dc,a=Nb.call(arguments,c),rc([Dc(a,b),this]).concat()},uc.takeLast=function(a){var b=this;return new Vc(function(c){var d=[];return b.subscribe(function(b){d.push(b),d.length>a&&d.shift()},c.onError.bind(c),function(){for(;d.length>0;)c.onNext(d.shift());c.onCompleted()})},b)},uc.selectConcat=uc.concatMap=function(a,b,c){return db(a)&&db(b)?this.concatMap(function(c,d){var e=a(c,d);return cb(e)&&(e=Oc(e)),(ob(e)||nb(e))&&(e=Cc(e)),e.map(function(a,e){return b(c,a,d,e)})}):db(a)?D(this,a,c):D(this,function(){return a})},uc.select=uc.map=function(a,b){var c=db(a)?a:function(){return a},d=this;return new Vc(function(a){var e=0;return d.subscribe(function(f){var g;try{g=c.call(b,f,e++,d)}catch(h){return void a.onError(h)}a.onNext(g)},a.onError.bind(a),a.onCompleted.bind(a))},d)},uc.pluck=function(a){return this.map(function(b){return b[a]})},uc.selectMany=uc.flatMap=function(a,b,c){return db(a)&&db(b)?this.flatMap(function(c,d){var e=a(c,d);return cb(e)&&(e=Oc(e)),(ob(e)||nb(e))&&(e=Cc(e)),e.map(function(a,e){return b(c,a,d,e)})},c):db(a)?E(this,a,c):E(this,function(){return a})},uc.selectSwitch=uc.flatMapLatest=uc.switchMap=function(a,b){return this.select(a,b).switchLatest()},uc.skip=function(a){if(0>a)throw new Error(eb);var b=this;return new Vc(function(c){var d=a;return b.subscribe(function(a){0>=d?c.onNext(a):d--},c.onError.bind(c),c.onCompleted.bind(c))},b)},uc.skipWhile=function(a,b){var c=this;return new Vc(function(d){var e=0,f=!1;return c.subscribe(function(g){if(!f)try{f=!a.call(b,g,e++,c)}catch(h){return void d.onError(h)}f&&d.onNext(g)},d.onError.bind(d),d.onCompleted.bind(d))},c)},uc.take=function(a,b){if(0>a)throw new RangeError(eb);if(0===a)return Ac(b);var c=this;return new Vc(function(b){var d=a;return c.subscribe(function(a){d-->0&&(b.onNext(a),0===d&&b.onCompleted())},b.onError.bind(b),b.onCompleted.bind(b))},c)},uc.takeWhile=function(a,b){var c=this;return new Vc(function(d){var e=0,f=!0;return c.subscribe(function(g){if(f){try{f=a.call(b,g,e++,c)}catch(h){return void d.onError(h)}f?d.onNext(g):d.onCompleted()}},d.onError.bind(d),d.onCompleted.bind(d))},c)},uc.where=uc.filter=function(a,b){var c=this;return new Vc(function(d){var e=0;return c.subscribe(function(f){var g;try{g=a.call(b,f,e++,c)}catch(h){return void d.onError(h)}g&&d.onNext(f)},d.onError.bind(d),d.onCompleted.bind(d))},c)},xc.fromCallback=function(a,b,c){return function(){var d=Nb.call(arguments,0);return new Vc(function(e){function f(){var a=arguments;if(c){try{a=c(a)}catch(b){return void e.onError(b)}e.onNext(a)}else a.length<=1?e.onNext.apply(e,a):e.onNext(a);e.onCompleted()}d.push(f),a.apply(b,d)}).publishLast().refCount()}},xc.fromNodeCallback=function(a,b,c){return function(){var d=Nb.call(arguments,0);return new Vc(function(e){function f(a){if(a)return void e.onError(a);var b=Nb.call(arguments,1);if(c){try{b=c(b)}catch(d){return void e.onError(d)}e.onNext(b)}else b.length<=1?e.onNext.apply(e,b):e.onNext(b);e.onCompleted()}d.push(f),a.apply(b,d)}).publishLast().refCount()}},W.config.useNativeEvents=!1;var Kc=R.angular&&angular.element?angular.element:R.jQuery?R.jQuery:R.Zepto?R.Zepto:null,Lc=!!R.Ember&&"function"==typeof R.Ember.addListener,Mc=!!R.Backbone&&!!R.Backbone.Marionette;xc.fromEvent=function(a,b,c){if(a.addListener)return Nc(function(c){a.addListener(b,c)},function(c){a.removeListener(b,c)},c);if(!W.config.useNativeEvents){if(Mc)return Nc(function(c){a.on(b,c)},function(c){a.off(b,c)},c);if(Lc)return Nc(function(c){Ember.addListener(a,b,c)},function(c){Ember.removeListener(a,b,c)},c);if(Kc){var d=Kc(a);return Nc(function(a){d.on(b,a)},function(a){d.off(b,a)},c)}}return new Vc(function(d){return H(a,b,function(a){var b=a;if(c)try{b=c(arguments)}catch(e){return void d.onError(e)}d.onNext(b)})}).publish().refCount()};var Nc=xc.fromEventPattern=function(a,b,c){return new Vc(function(d){function e(a){var b=a;if(c)try{b=c(arguments)}catch(e){return void d.onError(e)}d.onNext(b)}var f=a(e);return Xb(function(){b&&b(e,f)})}).publish().refCount()},Oc=xc.fromPromise=function(a){return zc(function(){var b=new W.AsyncSubject;return a.then(function(a){b.onNext(a),b.onCompleted()},b.onError.bind(b)),b})};uc.toPromise=function(a){if(a||(a=W.config.Promise),!a)throw new TypeError("Promise type not provided nor in Rx.config.Promise");var b=this;return new a(function(a,c){var d,e=!1;b.subscribe(function(a){d=a,e=!0},c,function(){e&&a(d)})})},xc.startAsync=function(a){var b;try{b=a()}catch(c){return Fc(c)}return Oc(b)},uc.multicast=function(a,b){var c=this;return"function"==typeof a?new Vc(function(d){var e=c.multicast(a());return new Ub(b(e).subscribe(d),e.connect())},c):new Pc(c,a)},uc.publish=function(a){return a&&db(a)?this.multicast(function(){return new Yc},a):this.multicast(new Yc)},uc.share=function(){return this.publish().refCount()},uc.publishLast=function(a){return a&&db(a)?this.multicast(function(){return new Zc},a):this.multicast(new Zc)},uc.publishValue=function(a,b){return 2===arguments.length?this.multicast(function(){return new _c(b)},a):this.multicast(new _c(a))},uc.shareValue=function(a){return this.publishValue(a).refCount()},uc.replay=function(a,b,c,d){return a&&db(a)?this.multicast(function(){return new ad(b,c,d)},a):this.multicast(new ad(b,c,d))},uc.shareReplay=function(a,b,c){return this.replay(null,a,b,c).refCount()};{var Pc=W.ConnectableObservable=function(a){function b(b,c){var d,e=!1,f=b.asObservable();this.connect=function(){return e||(e=!0,d=new Ub(f.subscribe(c),Xb(function(){e=!1}))),d},a.call(this,c.subscribe.bind(c))}return Ob(b,a),b.prototype.refCount=function(){var a,b=0,c=this;return new Vc(function(d){var e=1===++b,f=c.subscribe(d);return e&&(a=c.connect()),function(){f.dispose(),0===--b&&a.dispose()}})},b}(xc),Qc=xc.interval=function(a,b){return L(a,a,Y(b)?b:jc)};xc.timer=function(b,c,d){var e;return Y(d)||(d=jc),c!==a&&"number"==typeof c?e=c:Y(c)&&(d=c),b instanceof Date&&e===a?I(b.getTime(),d):b instanceof Date&&e!==a?(e=c,J(b.getTime(),e,d)):e===a?K(b,d):L(b,e,d)}}uc.delay=function(a,b){return Y(b)||(b=jc),a instanceof Date?N(this,a.getTime(),b):M(this,a,b)},uc.debounce=uc.throttleWithTimeout=function(a,b){Y(b)||(b=jc);var c=this;return new Vc(function(d){var e,f=new $b,g=!1,h=0,i=c.subscribe(function(c){g=!0,e=c,h++;var i=h,j=new Zb;f.setDisposable(j),j.setDisposable(b.scheduleWithRelative(a,function(){g&&h===i&&d.onNext(e),g=!1}))},function(a){f.dispose(),d.onError(a),g=!1,h++},function(){f.dispose(),g&&d.onNext(e),d.onCompleted(),g=!1,h++});return new Ub(i,f)},this)},uc.throttle=function(a,b){return qb("throttle","debounce or throttleWithTimeout"),this.debounce(a,b)},uc.timestamp=function(a){return Y(a)||(a=jc),this.map(function(b){return{value:b,timestamp:a.now()}})},uc.sample=uc.throttleLatest=function(a,b){return Y(b)||(b=jc),"number"==typeof a?O(this,Qc(a,b)):O(this,a)},uc.timeout=function(a,b,c){(null==b||"string"==typeof b)&&(b=Fc(new Error(b||"Timeout"))),Y(c)||(c=jc);var d=this,e=a instanceof Date?"scheduleWithAbsolute":"scheduleWithRelative";return new Vc(function(f){function g(){var d=h;l.setDisposable(c[e](a,function(){h===d&&(cb(b)&&(b=Oc(b)),j.setDisposable(b.subscribe(f)))}))}var h=0,i=new Zb,j=new $b,k=!1,l=new $b;return j.setDisposable(i),g(),i.setDisposable(d.subscribe(function(a){k||(h++,f.onNext(a),g())},function(a){k||(h++,f.onError(a))},function(){k||(h++,f.onCompleted())})),new Ub(j,l)},d)},uc.throttleFirst=function(a,b){Y(b)||(b=jc);var c=+a||0;if(0>=c)throw new RangeError("windowDuration cannot be less or equal zero.");var d=this;return new Vc(function(a){var e=0;return d.subscribe(function(d){var f=b.now();(0===e||f-e>=c)&&(e=f,a.onNext(d))},a.onError.bind(a),a.onCompleted.bind(a))},d)};var Rc=function(a){function b(a){var b=this.source.publish(),c=b.subscribe(a),d=Yb,e=this.pauser.distinctUntilChanged().subscribe(function(a){a?d=b.connect():(d.dispose(),d=Yb)});return new Ub(c,d,e)}function c(c,d){this.source=c,this.controller=new Yc,this.pauser=d&&d.subscribe?this.controller.merge(d):this.controller,a.call(this,b,c)}return Ob(c,a),c.prototype.pause=function(){this.controller.onNext(!1)},c.prototype.resume=function(){this.controller.onNext(!0)},c}(xc);uc.pausable=function(a){return new Rc(this,a)};var Sc=function(b){function c(b){var c,d=[],e=P(this.source,this.pauser.distinctUntilChanged().startWith(!1),function(a,b){return{data:a,shouldFire:b}}).subscribe(function(e){if(c!==a&&e.shouldFire!=c){if(c=e.shouldFire,e.shouldFire)for(;d.length>0;)b.onNext(d.shift())}else c=e.shouldFire,e.shouldFire?b.onNext(e.data):d.push(e.data)},function(a){for(;d.length>0;)b.onNext(d.shift());b.onError(a)},function(){for(;d.length>0;)b.onNext(d.shift());b.onCompleted()});return e}function d(a,d){this.source=a,this.controller=new Yc,this.pauser=d&&d.subscribe?this.controller.merge(d):this.controller,b.call(this,c,a)}return Ob(d,b),d.prototype.pause=function(){this.controller.onNext(!1)},d.prototype.resume=function(){this.controller.onNext(!0)},d}(xc);uc.pausableBuffered=function(a){return new Sc(this,a)};var Tc=function(a){function b(a){return this.source.subscribe(a)}function c(c,d){a.call(this,b,c),this.subject=new Uc(d),this.source=c.multicast(this.subject).refCount()}return Ob(c,a),c.prototype.request=function(a){return null==a&&(a=-1),this.subject.request(a)},c}(xc),Uc=function(a){function b(a){return this.subject.subscribe(a)}function c(c){null==c&&(c=!0),a.call(this,b),this.subject=new Yc,this.enableQueue=c,this.queue=c?[]:null,this.requestedCount=0,this.requestedDisposable=Yb,this.error=null,this.hasFailed=!1,this.hasCompleted=!1,this.controlledDisposable=Yb}return Ob(c,a),Pb(c.prototype,sc,{onCompleted:function(){this.hasCompleted=!0,(!this.enableQueue||0===this.queue.length)&&this.subject.onCompleted()},onError:function(a){this.hasFailed=!0,this.error=a,(!this.enableQueue||0===this.queue.length)&&this.subject.onError(a)},onNext:function(a){var b=!1;0===this.requestedCount?this.enableQueue&&this.queue.push(a):(-1!==this.requestedCount&&0===this.requestedCount--&&this.disposeCurrentRequest(),b=!0),b&&this.subject.onNext(a)},_processRequest:function(a){if(this.enableQueue){for(;this.queue.length>=a&&a>0;)this.subject.onNext(this.queue.shift()),a--;return 0!==this.queue.length?{numberOfItems:a,returnValue:!0}:{numberOfItems:a,returnValue:!1}}return this.hasFailed?(this.subject.onError(this.error),this.controlledDisposable.dispose(),this.controlledDisposable=Yb):this.hasCompleted&&(this.subject.onCompleted(),this.controlledDisposable.dispose(),this.controlledDisposable=Yb),{numberOfItems:a,returnValue:!1}},request:function(a){this.disposeCurrentRequest();var b=this,c=this._processRequest(a),a=c.numberOfItems;return c.returnValue?Yb:(this.requestedCount=a,this.requestedDisposable=Xb(function(){b.requestedCount=0}),this.requestedDisposable)},disposeCurrentRequest:function(){this.requestedDisposable.dispose(),this.requestedDisposable=Yb}}),c}(xc);uc.controlled=function(a){return null==a&&(a=!0),new Tc(this,a)},uc.transduce=function(a){function b(a){return{init:function(){return a},step:function(a,b){return a.onNext(b)},result:function(a){return a.onCompleted()}}}var c=this;return new Vc(function(d){var e=a(b(d));return c.subscribe(function(a){try{e.step(d,a)}catch(b){d.onError(b)}},d.onError.bind(d),function(){e.result(d)})},c)};var Vc=W.AnonymousObservable=function(a){function b(a){return a&&"function"==typeof a.dispose?a:"function"==typeof a?Xb(a):Yb}function c(d,e){function f(a){var c=function(){try{e.setDisposable(b(d(e)))}catch(a){if(!e.fail(a))throw a}},e=new Wc(a);return ec.scheduleRequired()?ec.schedule(c):c(),e}return this.source=e,this instanceof c?void a.call(this,f):new c(d)}return Ob(c,a),c}(xc),Wc=function(a){function b(b){a.call(this),this.observer=b,this.m=new Zb}Ob(b,a);var c=b.prototype;return c.next=function(a){var b=!1;try{this.observer.onNext(a),b=!0}catch(c){throw c}finally{!b&&this.dispose()}},c.error=function(a){try{this.observer.onError(a)}catch(b){throw b}finally{this.dispose()}},c.completed=function(){try{this.observer.onCompleted()}catch(a){throw a}finally{this.dispose()}},c.setDisposable=function(a){this.m.setDisposable(a)},c.getDisposable=function(){return this.m.getDisposable()},c.dispose=function(){a.prototype.dispose.call(this),this.m.dispose()},b}(vc),Xc=function(a,b){this.subject=a,this.observer=b};Xc.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var a=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(a,1),this.observer=null}};var Yc=W.Subject=function(a){function c(a){return b.call(this),this.isStopped?this.exception?(a.onError(this.exception),Yb):(a.onCompleted(),Yb):(this.observers.push(a),new Xc(this,a))}function d(){a.call(this,c),this.isDisposed=!1,this.isStopped=!1,this.observers=[]}return Ob(d,a),Pb(d.prototype,sc,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(b.call(this),!this.isStopped){var a=this.observers.slice(0);this.isStopped=!0;for(var c=0,d=a.length;d>c;c++)a[c].onCompleted();this.observers=[]}},onError:function(a){if(b.call(this),!this.isStopped){var c=this.observers.slice(0);this.isStopped=!0,this.exception=a;for(var d=0,e=c.length;e>d;d++)c[d].onError(a);this.observers=[]}},onNext:function(a){if(b.call(this),!this.isStopped)for(var c=this.observers.slice(0),d=0,e=c.length;e>d;d++)c[d].onNext(a)},dispose:function(){this.isDisposed=!0,this.observers=null}}),d.create=function(a,b){return new $c(a,b)},d}(xc),Zc=W.AsyncSubject=function(a){function c(a){if(b.call(this),!this.isStopped)return this.observers.push(a),new Xc(this,a);var c=this.exception,d=this.hasValue,e=this.value;return c?a.onError(c):d?(a.onNext(e),a.onCompleted()):a.onCompleted(),Yb}function d(){a.call(this,c),this.isDisposed=!1,this.isStopped=!1,this.value=null,this.hasValue=!1,this.observers=[],this.exception=null}return Ob(d,a),Pb(d.prototype,sc,{hasObservers:function(){return b.call(this),this.observers.length>0},onCompleted:function(){var a,c,d;if(b.call(this),!this.isStopped){this.isStopped=!0;var e=this.observers.slice(0),f=this.value,g=this.hasValue;if(g)for(c=0,d=e.length;d>c;c++)a=e[c],a.onNext(f),a.onCompleted();else for(c=0,d=e.length;d>c;c++)e[c].onCompleted();this.observers=[]}},onError:function(a){if(b.call(this),!this.isStopped){var c=this.observers.slice(0);this.isStopped=!0,this.exception=a;for(var d=0,e=c.length;e>d;d++)c[d].onError(a);this.observers=[]}},onNext:function(a){b.call(this),this.isStopped||(this.value=a,this.hasValue=!0)},dispose:function(){this.isDisposed=!0,this.observers=null,this.exception=null,this.value=null}}),d}(xc),$c=W.AnonymousSubject=function(a){function b(b,c){this.observer=b,this.observable=c,a.call(this,this.observable.subscribe.bind(this.observable))}return Ob(b,a),Pb(b.prototype,sc,{onCompleted:function(){this.observer.onCompleted()},onError:function(a){this.observer.onError(a)},onNext:function(a){this.observer.onNext(a)}}),b}(xc),_c=W.BehaviorSubject=function(a){function c(a){if(b.call(this),!this.isStopped)return this.observers.push(a),a.onNext(this.value),new Xc(this,a);var c=this.exception;return c?a.onError(c):a.onCompleted(),Yb}function d(b){a.call(this,c),this.value=b,this.observers=[],this.isDisposed=!1,this.isStopped=!1,this.exception=null}return Ob(d,a),Pb(d.prototype,sc,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(b.call(this),!this.isStopped){this.isStopped=!0;for(var a=0,c=this.observers.slice(0),d=c.length;d>a;a++)c[a].onCompleted();this.observers=[]}},onError:function(a){if(b.call(this),!this.isStopped){this.isStopped=!0,this.exception=a;for(var c=0,d=this.observers.slice(0),e=d.length;e>c;c++)d[c].onError(a);this.observers=[]}},onNext:function(a){if(b.call(this),!this.isStopped){this.value=a;for(var c=0,d=this.observers.slice(0),e=d.length;e>c;c++)d[c].onNext(a)}},dispose:function(){this.isDisposed=!0,this.observers=null,this.value=null,this.exception=null}}),d}(xc),ad=W.ReplaySubject=function(a){function c(a,b){return Xb(function(){b.dispose(),!a.isDisposed&&a.observers.splice(a.observers.indexOf(b),1)})}function d(a){var d=new yc(this.scheduler,a),e=c(this,d);b.call(this),this._trim(this.scheduler.now()),this.observers.push(d);for(var f=0,g=this.q.length;g>f;f++)d.onNext(this.q[f].value);return this.hasError?d.onError(this.error):this.isStopped&&d.onCompleted(),d.ensureActive(),e}function e(b,c,e){this.bufferSize=null==b?Number.MAX_VALUE:b,this.windowSize=null==c?Number.MAX_VALUE:c,this.scheduler=e||ec,this.q=[],this.observers=[],this.isStopped=!1,this.isDisposed=!1,this.hasError=!1,this.error=null,a.call(this,d)}return Ob(e,a),Pb(e.prototype,sc,{hasObservers:function(){return this.observers.length>0},_trim:function(a){for(;this.q.length>this.bufferSize;)this.q.shift();for(;this.q.length>0&&a-this.q[0].interval>this.windowSize;)this.q.shift()},onNext:function(a){if(b.call(this),!this.isStopped){var c=this.scheduler.now();this.q.push({interval:c,value:a}),this._trim(c);for(var d=this.observers.slice(0),e=0,f=d.length;f>e;e++){var g=d[e];g.onNext(a),g.ensureActive()}}},onError:function(a){if(b.call(this),!this.isStopped){this.isStopped=!0,this.error=a,this.hasError=!0;var c=this.scheduler.now();this._trim(c);for(var d=this.observers.slice(0),e=0,f=d.length;f>e;e++){var g=d[e];g.onError(a),g.ensureActive()}this.observers=[]}},onCompleted:function(){if(b.call(this),!this.isStopped){this.isStopped=!0;var a=this.scheduler.now();this._trim(a);for(var c=this.observers.slice(0),d=0,e=c.length;e>d;d++){var f=c[d];f.onCompleted(),f.ensureActive()}this.observers=[]}},dispose:function(){this.isDisposed=!0,this.observers=null}}),e}(xc);"function"==typeof define&&"object"==typeof define.amd&&define.amd?(R.Rx=W,define(function(){return W})):S&&T?U?(T.exports=W).Rx=W:S.Rx=W:R.Rx=W;var bd=g()}).call(this);
2
+ (function(a){function b(a){if(a.isDisposed)throw new Error(lb)}function c(a){for(var b=[],c=0,d=a.length;d>c;c++)b.push(a[c]);return b}function d(a,b){if(mb&&b.stack&&"object"==typeof a&&null!==a&&a.stack&&-1===a.stack.indexOf(qb)){for(var c=[],d=b;d;d=d.source)d.stack&&c.unshift(d.stack);c.unshift(a.stack);var f=c.join("\n"+qb+"\n");a.stack=e(f)}}function e(a){for(var b=a.split("\n"),c=[],d=0,e=b.length;e>d;d++){var h=b[d];f(h)||g(h)||!h||c.push(h)}return c.join("\n")}function f(a){var b=i(a);if(!b)return!1;var c=b[0],d=b[1];return c===ob&&d>=pb&&pd>=d}function g(a){return-1!==a.indexOf("(module.js:")||-1!==a.indexOf("(node.js:")}function h(){if(mb)try{throw new Error}catch(a){var b=a.stack.split("\n"),c=b[0].indexOf("@")>0?b[1]:b[2],d=i(c);if(!d)return;return ob=d[0],d[1]}}function i(a){var b=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(a);if(b)return[b[1],Number(b[2])];var c=/at ([^ ]+):(\d+):(?:\d+)$/.exec(a);if(c)return[c[1],Number(c[2])];var d=/.*@(.+):(\d+)$/.exec(a);return d?[d[1],Number(d[2])]:void 0}function j(a){var b=[];if(!Sb(a))return b;Rb.nonEnumArgs&&a.length&&Tb(a)&&(a=Vb.call(a));var c=Rb.enumPrototypes&&"function"==typeof a,d=Rb.enumErrorProps&&(a===Mb||a instanceof Error);for(var e in a)c&&"prototype"==e||d&&("message"==e||"name"==e)||b.push(e);if(Rb.nonEnumShadows&&a!==Nb){var f=a.constructor,g=-1,h=yb;if(a===(f&&f.prototype))var i=a===Ob?Ib:a===Mb?Db:Jb.call(a),j=Qb[i];for(;++g<h;)e=xb[g],j&&j[e]||!Kb.call(a,e)||b.push(e)}return b}function k(a,b,c){for(var d=-1,e=c(a),f=e.length;++d<f;){var g=e[d];if(b(a[g],g,a)===!1)break}return a}function l(a,b){return k(a,b,j)}function m(a){return"function"!=typeof a.toString&&"string"==typeof(a+"")}function n(a,b,c,d){if(a===b)return 0!==a||1/a==1/b;var e=typeof a,f=typeof b;if(a===a&&(null==a||null==b||"function"!=e&&"object"!=e&&"function"!=f&&"object"!=f))return!1;var g=Jb.call(a),h=Jb.call(b);if(g==zb&&(g=Gb),h==zb&&(h=Gb),g!=h)return!1;switch(g){case Bb:case Cb:return+a==+b;case Fb:return a!=+a?b!=+b:0==a?1/a==1/b:a==+b;case Hb:case Ib:return a==String(b)}var i=g==Ab;if(!i){if(g!=Gb||!Rb.nodeClass&&(m(a)||m(b)))return!1;var j=!Rb.argsObject&&Tb(a)?Object:a.constructor,k=!Rb.argsObject&&Tb(b)?Object:b.constructor;if(!(j==k||Kb.call(a,"constructor")&&Kb.call(b,"constructor")||jb(j)&&j instanceof j&&jb(k)&&k instanceof k||!("constructor"in a&&"constructor"in b)))return!1}c||(c=[]),d||(d=[]);for(var o=c.length;o--;)if(c[o]==a)return d[o]==b;var p=0,q=!0;if(c.push(a),d.push(b),i){if(o=a.length,p=b.length,q=p==o)for(;p--;){var r=b[p];if(!(q=n(a[p],r,c,d)))break}}else l(b,function(b,e,f){return Kb.call(f,e)?(p++,q=Kb.call(a,e)&&n(a[e],b,c,d)):void 0}),q&&l(a,function(a,b,c){return Kb.call(c,b)?q=--p>-1:void 0});return c.pop(),d.pop(),q}function o(a){throw a}function p(a,b){for(var c=new Array(a),d=0;a>d;d++)c[d]=b();return c}function q(a,b){this.id=a,this.value=b}function r(a){this.observer=a,this.a=[],this.isStopped=!1}function t(){this._s=s}function u(){this._s=s,this._l=s.length,this._i=0}function v(a){this._a=a}function w(a){this._a=a,this._l=A(a),this._i=0}function x(a){return"number"==typeof a&&X.isFinite(a)}function y(b){var c,d=b[rb];if(!d&&"string"==typeof b)return c=new t(b),c[rb]();if(!d&&b.length!==a)return c=new v(b),c[rb]();if(!d)throw new TypeError("Object is not iterable");return b[rb]()}function z(a){var b=+a;return 0===b?b:isNaN(b)?b:0>b?-1:1}function A(a){var b=+a.length;return isNaN(b)?0:0!==b&&x(b)?(b=z(b)*Math.floor(Math.abs(b)),0>=b?0:b>Nc?Nc:b):b}function B(a,b){this.observer=a,this.parent=b}function C(a,b){return new Pc(b,a)}function D(a,b){return new hd(function(c){var d=new fc,e=new gc;return e.setDisposable(d),d.setDisposable(a.subscribe(function(a){c.onNext(a)},function(a){try{var d=b(a)}catch(f){return c.onError(f)}ib(d)&&(d=ad(d));var g=new fc;e.setDisposable(g),g.setDisposable(d.subscribe(c))},function(a){c.onCompleted(a)})),e},a)}function E(a,b){var c=this;return new hd(function(d){var e=0,f=a.length;return c.subscribe(function(c){if(f>e){var g,h=a[e++];try{g=b(c,h)}catch(i){return d.onError(i)}d.onNext(g)}else d.onCompleted()},function(a){d.onError(a)},function(){d.onCompleted()})},c)}function F(){return!1}function G(){return[]}function H(a,b,c){var d=wb(b,c,3);return a.map(function(b,c){var e=d(b,c,a);return ib(e)&&(e=ad(e)),(ub(e)||tb(e))&&(e=Oc(e)),e}).concatAll()}function I(a,b,c){this.observer=a,this.selector=b,this.source=c,this.i=0,this.isStopped=!1}function J(a,b,c){var d=wb(b,c,3);return a.map(function(b,c){var e=d(b,c,a);return ib(e)&&(e=ad(e)),(ub(e)||tb(e))&&(e=Oc(e)),e}).mergeAll()}function K(a,b,c){this.observer=a,this.predicate=b,this.source=c,this.i=0,this.isStopped=!1}function L(a){var b=function(){this.cancelBubble=!0},c=function(){if(this.bubbledKeyCode=this.keyCode,this.ctrlKey)try{this.keyCode=0}catch(a){}this.defaultPrevented=!0,this.returnValue=!1,this.modified=!0};if(a||(a=X.event),!a.target)switch(a.target=a.target||a.srcElement,"mouseover"==a.type&&(a.relatedTarget=a.fromElement),"mouseout"==a.type&&(a.relatedTarget=a.toElement),a.stopPropagation||(a.stopPropagation=b,a.preventDefault=c),a.type){case"keypress":var d="charCode"in a?a.charCode:a.keyCode;10==d?(d=0,a.keyCode=13):13==d||27==d?d=0:3==d&&(d=99),a.charCode=d,a.keyChar=a.charCode?String.fromCharCode(a.charCode):""}return a}function M(a,b,c){if(a.addEventListener)return a.addEventListener(b,c,!1),dc(function(){a.removeEventListener(b,c,!1)});if(a.attachEvent){var d=function(a){c(L(a))};return a.attachEvent("on"+b,d),dc(function(){a.detachEvent("on"+b,d)})}return a["on"+b]=c,dc(function(){a["on"+b]=null})}function N(a,b,c){var d=new ac;if("[object NodeList]"===Object.prototype.toString.call(a))for(var e=0,f=a.length;f>e;e++)d.add(N(a.item(e),b,c));else a&&d.add(M(a,b,c));return d}function O(a,b){return new hd(function(c){return b.scheduleWithAbsolute(a,function(){c.onNext(0),c.onCompleted()})})}function P(a,b,c){return new hd(function(d){var e=a,f=jc(b);return c.scheduleRecursiveWithAbsoluteAndState(0,e,function(a,b){if(f>0){var g=c.now();e+=f,g>=e&&(e=g+f)}d.onNext(a),b(a+1,e)})})}function Q(a,b){return new hd(function(c){return b.scheduleWithRelative(jc(a),function(){c.onNext(0),c.onCompleted()})})}function R(a,b,c){return a===b?new hd(function(a){return c.schedulePeriodicWithState(0,b,function(b){return a.onNext(b),b+1})}):Jc(function(){return P(c.now()+a,b,c)})}function S(a,b,c){return new hd(function(d){var e,f=!1,g=new gc,h=null,i=[],j=!1;return e=a.materialize().timestamp(c).subscribe(function(a){var e,k;"E"===a.value.kind?(i=[],i.push(a),h=a.value.exception,k=!j):(i.push({value:a.value,timestamp:a.timestamp+b}),k=!f,f=!0),k&&(null!==h?d.onError(h):(e=new fc,g.setDisposable(e),e.setDisposable(c.scheduleRecursiveWithRelative(b,function(a){var b,e,g,k;if(null===h){j=!0;do g=null,i.length>0&&i[0].timestamp-c.now()<=0&&(g=i.shift().value),null!==g&&g.accept(d);while(null!==g);k=!1,e=0,i.length>0?(k=!0,e=Math.max(0,i[0].timestamp-c.now())):f=!1,b=h,j=!1,null!==b?d.onError(b):k&&a(e)}}))))}),new ac(e,g)},a)}function T(a,b,c){return Jc(function(){return S(a,b-c.now(),c)})}function U(a,b){return new hd(function(c){function d(){g&&(g=!1,c.onNext(f)),e&&c.onCompleted()}var e,f,g;return new ac(a.subscribe(function(a){g=!0,f=a},c.onError.bind(c),function(){e=!0}),b.subscribe(d,c.onError.bind(c),d))},a)}function V(a,b,c){return new hd(function(d){function e(a,b){j[b]=a;var e;if(g[b]=!0,h||(h=g.every(db))){if(f)return void d.onError(f);try{e=c.apply(null,j)}catch(k){return void d.onError(k)}d.onNext(e)}i&&j[1]&&d.onCompleted()}var f,g=[!1,!1],h=!1,i=!1,j=new Array(2);return new ac(a.subscribe(function(a){e(a,0)},function(a){j[1]?d.onError(a):f=a},function(){i=!0,j[1]&&d.onCompleted()}),b.subscribe(function(a){e(a,1)},function(a){d.onError(a)},function(){i=!0,e(!0,1)}))},a)}var W={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},X=W[typeof window]&&window||this,Y=W[typeof exports]&&exports&&!exports.nodeType&&exports,Z=W[typeof module]&&module&&!module.nodeType&&module,$=Z&&Z.exports===Y&&Y,_=W[typeof global]&&global;!_||_.global!==_&&_.window!==_||(X=_);var ab={internals:{},config:{Promise:X.Promise},helpers:{}},bb=ab.helpers.noop=function(){},cb=(ab.helpers.notDefined=function(a){return"undefined"==typeof a},ab.helpers.isScheduler=function(a){return a instanceof ab.Scheduler}),db=ab.helpers.identity=function(a){return a},eb=(ab.helpers.pluck=function(a){return function(b){return b[a]}},ab.helpers.just=function(a){return function(){return a}},ab.helpers.defaultNow=function(){return Date.now?Date.now:function(){return+new Date}}()),fb=ab.helpers.defaultComparer=function(a,b){return Ub(a,b)},gb=ab.helpers.defaultSubComparer=function(a,b){return a>b?1:b>a?-1:0},hb=(ab.helpers.defaultKeySerializer=function(a){return a.toString()},ab.helpers.defaultError=function(a){throw a}),ib=ab.helpers.isPromise=function(a){return!!a&&"function"==typeof a.then},jb=(ab.helpers.asArray=function(){return Array.prototype.slice.call(arguments)},ab.helpers.not=function(a){return!a},ab.helpers.isFunction=function(){var a=function(a){return"function"==typeof a||!1};return a(/x/)&&(a=function(a){return"function"==typeof a&&"[object Function]"==Jb.call(a)}),a}()),kb="Argument out of range",lb="Object has been disposed";ab.config.longStackSupport=!1;var mb=!1;try{throw new Error}catch(nb){mb=!!nb.stack}var ob,pb=h(),qb="From previous event:",rb="function"==typeof Symbol&&Symbol.iterator||"_es6shim_iterator_";X.Set&&"function"==typeof(new X.Set)["@@iterator"]&&(rb="@@iterator");var sb=ab.doneEnumerator={done:!0,value:a},tb=ab.helpers.isIterable=function(b){return b[rb]!==a},ub=ab.helpers.isArrayLike=function(b){return b&&b.length!==a};ab.helpers.iterator=rb;var vb,wb=ab.internals.bindCallback=function(a,b,c){if("undefined"==typeof b)return a;switch(c){case 0:return function(){return a.call(b)};case 1:return function(c){return a.call(b,c)};case 2:return function(c,d){return a.call(b,c,d)};case 3:return function(c,d,e){return a.call(b,c,d,e)}}return function(){return a.apply(b,arguments)}},xb=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],yb=xb.length,zb="[object Arguments]",Ab="[object Array]",Bb="[object Boolean]",Cb="[object Date]",Db="[object Error]",Eb="[object Function]",Fb="[object Number]",Gb="[object Object]",Hb="[object RegExp]",Ib="[object String]",Jb=Object.prototype.toString,Kb=Object.prototype.hasOwnProperty,Lb=Jb.call(arguments)==zb,Mb=Error.prototype,Nb=Object.prototype,Ob=String.prototype,Pb=Nb.propertyIsEnumerable;try{vb=!(Jb.call(document)==Gb&&!({toString:0}+""))}catch(nb){vb=!0}var Qb={};Qb[Ab]=Qb[Cb]=Qb[Fb]={constructor:!0,toLocaleString:!0,toString:!0,valueOf:!0},Qb[Bb]=Qb[Ib]={constructor:!0,toString:!0,valueOf:!0},Qb[Db]=Qb[Eb]=Qb[Hb]={constructor:!0,toString:!0},Qb[Gb]={constructor:!0};var Rb={};!function(){var a=function(){this.x=1},b=[];a.prototype={valueOf:1,y:1};for(var c in new a)b.push(c);for(c in arguments);Rb.enumErrorProps=Pb.call(Mb,"message")||Pb.call(Mb,"name"),Rb.enumPrototypes=Pb.call(a,"prototype"),Rb.nonEnumArgs=0!=c,Rb.nonEnumShadows=!/valueOf/.test(b)}(1);var Sb=ab.internals.isObject=function(a){var b=typeof a;return a&&("function"==b||"object"==b)||!1},Tb=function(a){return a&&"object"==typeof a?Jb.call(a)==zb:!1};Lb||(Tb=function(a){return a&&"object"==typeof a?Kb.call(a,"callee"):!1});{var Ub=ab.internals.isEqual=function(a,b){return n(a,b,[],[])},Vb=({}.hasOwnProperty,Array.prototype.slice),Wb=this.inherits=ab.internals.inherits=function(a,b){function c(){this.constructor=a}c.prototype=b.prototype,a.prototype=new c},Xb=ab.internals.addProperties=function(a){for(var b=[],c=1,d=arguments.length;d>c;c++)b.push(arguments[c]);for(var e=0,f=b.length;f>e;e++){var g=b[e];for(var h in g)a[h]=g[h]}};ab.internals.addRef=function(a,b){return new hd(function(c){return new ac(b.getDisposable(),a.subscribe(c))})}}Function.prototype.bind||(Function.prototype.bind=function(a){var b=this,c=Vb.call(arguments,1),d=function(){function e(){}if(this instanceof d){e.prototype=b.prototype;var f=new e,g=b.apply(f,c.concat(Vb.call(arguments)));return Object(g)===g?g:f}return b.apply(a,c.concat(Vb.call(arguments)))};return d}),Array.prototype.forEach||(Array.prototype.forEach=function(a,b){var c,d;if(null==this)throw new TypeError(" this is null or not defined");var e=Object(this),f=e.length>>>0;if("function"!=typeof a)throw new TypeError(a+" is not a function");for(arguments.length>1&&(c=b),d=0;f>d;){var g;d in e&&(g=e[d],a.call(c,g,d,e)),d++}});var Yb=Object("a"),Zb="a"!=Yb[0]||!(0 in Yb);Array.prototype.every||(Array.prototype.every=function(a){var b=Object(this),c=Zb&&{}.toString.call(this)==Ib?this.split(""):b,d=c.length>>>0,e=arguments[1];if({}.toString.call(a)!=Eb)throw new TypeError(a+" is not a function");for(var f=0;d>f;f++)if(f in c&&!a.call(e,c[f],f,b))return!1;return!0}),Array.prototype.map||(Array.prototype.map=function(a){var b=Object(this),c=Zb&&{}.toString.call(this)==Ib?this.split(""):b,d=c.length>>>0,e=Array(d),f=arguments[1];if({}.toString.call(a)!=Eb)throw new TypeError(a+" is not a function");for(var g=0;d>g;g++)g in c&&(e[g]=a.call(f,c[g],g,b));return e}),Array.prototype.filter||(Array.prototype.filter=function(a){for(var b,c=[],d=new Object(this),e=0,f=d.length>>>0;f>e;e++)b=d[e],e in d&&a.call(arguments[1],b,e,d)&&c.push(b);return c}),Array.isArray||(Array.isArray=function(a){return{}.toString.call(a)==Ab}),Array.prototype.indexOf||(Array.prototype.indexOf=function(a){var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=0;if(arguments.length>1&&(d=Number(arguments[1]),d!==d?d=0:0!==d&&1/0!=d&&d!==-1/0&&(d=(d>0||-1)*Math.floor(Math.abs(d)))),d>=c)return-1;for(var e=d>=0?d:Math.max(c-Math.abs(d),0);c>e;e++)if(e in b&&b[e]===a)return e;return-1}),Object.prototype.propertyIsEnumerable||(Object.prototype.propertyIsEnumerable=function(a){for(var b in this)if(b===a)return!0;return!1}),Object.keys||(Object.keys=function(){"use strict";var a=Object.prototype.hasOwnProperty,b=!{toString:null}.propertyIsEnumerable("toString");return function(c){if("object"!=typeof c&&("function"!=typeof c||null===c))throw new TypeError("Object.keys called on non-object");var d,e,f=[];for(d in c)a.call(c,d)&&f.push(d);if(b)for(e=0;yb>e;e++)a.call(c,xb[e])&&f.push(xb[e]);return f}}()),q.prototype.compareTo=function(a){var b=this.value.compareTo(a.value);return 0===b&&(b=this.id-a.id),b};var $b=ab.internals.PriorityQueue=function(a){this.items=new Array(a),this.length=0},_b=$b.prototype;_b.isHigherPriority=function(a,b){return this.items[a].compareTo(this.items[b])<0},_b.percolate=function(a){if(!(a>=this.length||0>a)){var b=a-1>>1;if(!(0>b||b===a)&&this.isHigherPriority(a,b)){var c=this.items[a];this.items[a]=this.items[b],this.items[b]=c,this.percolate(b)}}},_b.heapify=function(a){if(+a||(a=0),!(a>=this.length||0>a)){var b=2*a+1,c=2*a+2,d=a;if(b<this.length&&this.isHigherPriority(b,d)&&(d=b),c<this.length&&this.isHigherPriority(c,d)&&(d=c),d!==a){var e=this.items[a];this.items[a]=this.items[d],this.items[d]=e,this.heapify(d)}}},_b.peek=function(){return this.items[0].value},_b.removeAt=function(b){this.items[b]=this.items[--this.length],this.items[this.length]=a,this.heapify()},_b.dequeue=function(){var a=this.peek();return this.removeAt(0),a},_b.enqueue=function(a){var b=this.length++;this.items[b]=new q($b.count++,a),this.percolate(b)},_b.remove=function(a){for(var b=0;b<this.length;b++)if(this.items[b].value===a)return this.removeAt(b),!0;return!1},$b.count=0;var ac=ab.CompositeDisposable=function(){var a=[];if(Array.isArray(arguments[0]))a=arguments[0];else{var b=arguments.length;a=new Array(b);for(var c=0;b>c;c++)a[c]=arguments[c]}this.disposables=a,this.isDisposed=!1,this.length=a.length},bc=ac.prototype;bc.add=function(a){this.isDisposed?a.dispose():(this.disposables.push(a),this.length++)},bc.remove=function(a){var b=!1;if(!this.isDisposed){var c=this.disposables.indexOf(a);-1!==c&&(b=!0,this.disposables.splice(c,1),this.length--,a.dispose())}return b},bc.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;for(var a=this.disposables.length,b=new Array(a),c=0;a>c;c++)b[c]=this.disposables[c];for(this.disposables=[],this.length=0,c=0;a>c;c++)b[c].dispose()}};var cc=ab.Disposable=function(a){this.isDisposed=!1,this.action=a||bb};cc.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var dc=cc.create=function(a){return new cc(a)},ec=cc.empty={dispose:bb},fc=ab.SingleAssignmentDisposable=function(){function a(){this.isDisposed=!1,this.current=null}var b=a.prototype;return b.getDisposable=function(){return this.current},b.setDisposable=function(a){var b=this.isDisposed;if(!b){var c=this.current;this.current=a}c&&c.dispose(),b&&a&&a.dispose()},b.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var a=this.current;this.current=null}a&&a.dispose()},a}(),gc=ab.SerialDisposable=fc,hc=(ab.RefCountDisposable=function(){function a(a){this.disposable=a,this.disposable.count++,this.isInnerDisposed=!1}function b(a){this.underlyingDisposable=a,this.isDisposed=!1,this.isPrimaryDisposed=!1,this.count=0}return a.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()))},b.prototype.dispose=function(){this.isDisposed||this.isPrimaryDisposed||(this.isPrimaryDisposed=!0,0===this.count&&(this.isDisposed=!0,this.underlyingDisposable.dispose()))},b.prototype.getDisposable=function(){return this.isDisposed?ec:new a(this)},b}(),ab.internals.ScheduledItem=function(a,b,c,d,e){this.scheduler=a,this.state=b,this.action=c,this.dueTime=d,this.comparer=e||gb,this.disposable=new fc});hc.prototype.invoke=function(){this.disposable.setDisposable(this.invokeCore())},hc.prototype.compareTo=function(a){return this.comparer(this.dueTime,a.dueTime)},hc.prototype.isCancelled=function(){return this.disposable.isDisposed},hc.prototype.invokeCore=function(){return this.action(this.scheduler,this.state)};var ic=ab.Scheduler=function(){function a(a,b,c,d){this.now=a,this._schedule=b,this._scheduleRelative=c,this._scheduleAbsolute=d}function b(a,b){return b(),ec}var c=a.prototype;return c.schedule=function(a){return this._schedule(a,b)},c.scheduleWithState=function(a,b){return this._schedule(a,b)},c.scheduleWithRelative=function(a,c){return this._scheduleRelative(c,a,b)},c.scheduleWithRelativeAndState=function(a,b,c){return this._scheduleRelative(a,b,c)},c.scheduleWithAbsolute=function(a,c){return this._scheduleAbsolute(c,a,b)},c.scheduleWithAbsoluteAndState=function(a,b,c){return this._scheduleAbsolute(a,b,c)},a.now=eb,a.normalize=function(a){return 0>a&&(a=0),a},a}(),jc=ic.normalize;!function(a){function b(a,b){var c=b.first,d=b.second,e=new ac,f=function(b){d(b,function(b){var c=!1,d=!1,g=a.scheduleWithState(b,function(a,b){return c?e.remove(g):d=!0,f(b),ec});d||(e.add(g),c=!0)})};return f(c),e}function c(a,b,c){var d=b.first,e=b.second,f=new ac,g=function(b){e(b,function(b,d){var e=!1,h=!1,i=a[c](b,d,function(a,b){return e?f.remove(i):h=!0,g(b),ec});h||(f.add(i),e=!0)})};return g(d),f}function d(a,b){a(function(c){b(a,c)})}a.scheduleRecursive=function(a){return this.scheduleRecursiveWithState(a,function(a,b){a(function(){b(a)})})},a.scheduleRecursiveWithState=function(a,c){return this.scheduleWithState({first:a,second:c},b)},a.scheduleRecursiveWithRelative=function(a,b){return this.scheduleRecursiveWithRelativeAndState(b,a,d)},a.scheduleRecursiveWithRelativeAndState=function(a,b,d){return this._scheduleRelative({first:a,second:d},b,function(a,b){return c(a,b,"scheduleWithRelativeAndState")})},a.scheduleRecursiveWithAbsolute=function(a,b){return this.scheduleRecursiveWithAbsoluteAndState(b,a,d)},a.scheduleRecursiveWithAbsoluteAndState=function(a,b,d){return this._scheduleAbsolute({first:a,second:d},b,function(a,b){return c(a,b,"scheduleWithAbsoluteAndState")})}}(ic.prototype),function(){ic.prototype.schedulePeriodic=function(a,b){return this.schedulePeriodicWithState(null,a,b)},ic.prototype.schedulePeriodicWithState=function(a,b,c){if("undefined"==typeof X.setInterval)throw new Error("Periodic scheduling not supported.");var d=a,e=X.setInterval(function(){d=c(d)},b);return dc(function(){X.clearInterval(e)})}}(ic.prototype);var kc,lc=ic.immediate=function(){function a(a,b){return b(this,a)}function b(){throw new Error("Not supported")}return new ic(eb,a,b,b)}(),mc=ic.currentThread=function(){function a(a){for(;a.length>0;){var b=a.dequeue();b.isCancelled()||!b.isCancelled()&&b.invoke()}}function b(b,c){var e=new hc(this,b,c,this.now());if(d)d.enqueue(e);else{d=new $b(4),d.enqueue(e);try{a(d)}catch(f){throw f}finally{d=null}}return e.disposable}function c(){throw new Error("Not supported")}var d,e=new ic(eb,b,c,c);return e.scheduleRequired=function(){return!d},e.ensureTrampoline=function(a){d?a():this.schedule(a)},e}(),nc=(ab.internals.SchedulePeriodicRecursive=function(){function a(a,b){b(0,this._period);try{this._state=this._action(this._state)}catch(c){throw this._cancel.dispose(),c}}function b(a,b,c,d){this._scheduler=a,this._state=b,this._period=c,this._action=d}return b.prototype.start=function(){var b=new fc;return this._cancel=b,b.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,a.bind(this))),b},b}(),bb),oc=function(){var a,b=bb;if("WScript"in this)a=function(a,b){WScript.Sleep(b),a()};else{if(!X.setTimeout)throw new Error("No concurrency detected!");a=X.setTimeout,b=X.clearTimeout}return{setTimeout:a,clearTimeout:b}}(),pc=oc.setTimeout,qc=oc.clearTimeout;!function(){function a(){if(!X.postMessage||X.importScripts)return!1;var a=!1,b=X.onmessage;return X.onmessage=function(){a=!0},X.postMessage("","*"),X.onmessage=b,a}var b=RegExp("^"+String(Jb).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),c="function"==typeof(c=_&&$&&_.setImmediate)&&!b.test(c)&&c,d="function"==typeof(d=_&&$&&_.clearImmediate)&&!b.test(d)&&d;if("function"==typeof c)kc=c,nc=d;else if("undefined"!=typeof process&&"[object process]"==={}.toString.call(process))kc=process.nextTick;else if(a()){var e="ms.rx.schedule"+Math.random(),f={},g=0,h=function(a){if("string"==typeof a.data&&a.data.substring(0,e.length)===e){var b=a.data.substring(e.length),c=f[b];c(),delete f[b]}};X.addEventListener?X.addEventListener("message",h,!1):X.attachEvent("onmessage",h,!1),kc=function(a){var b=g++;f[b]=a,X.postMessage(e+b,"*")}}else if(X.MessageChannel){var i=new X.MessageChannel,j={},k=0;i.port1.onmessage=function(a){var b=a.data,c=j[b];c(),delete j[b]},kc=function(a){var b=k++;j[b]=a,i.port2.postMessage(b)}}else"document"in X&&"onreadystatechange"in X.document.createElement("script")?kc=function(a){var b=X.document.createElement("script");b.onreadystatechange=function(){a(),b.onreadystatechange=null,b.parentNode.removeChild(b),b=null},X.document.documentElement.appendChild(b)}:(kc=function(a){return pc(a,0)},nc=qc)}();var rc=ic.timeout=function(){function a(a,b){var c=this,d=new fc,e=kc(function(){d.isDisposed||d.setDisposable(b(c,a))});return new ac(d,dc(function(){nc(e)}))}function b(a,b,c){var d=this,e=ic.normalize(b);if(0===e)return d.scheduleWithState(a,c);var f=new fc,g=pc(function(){f.isDisposed||f.setDisposable(c(d,a))},e);return new ac(f,dc(function(){qc(g)}))}function c(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}return new ic(eb,a,b,c)}(),sc=ab.Notification=function(){function a(a,b){this.hasValue=null==b?!1:b,this.kind=a}return a.prototype.accept=function(a,b,c){return a&&"object"==typeof a?this._acceptObservable(a):this._accept(a,b,c)},a.prototype.toObservable=function(a){var b=this;return cb(a)||(a=lc),new hd(function(c){return a.schedule(function(){b._acceptObservable(c),"N"===b.kind&&c.onCompleted()})})},a}(),tc=sc.createOnNext=function(){function a(a){return a(this.value)}function b(a){return a.onNext(this.value)}function c(){return"OnNext("+this.value+")"}return function(d){var e=new sc("N",!0);return e.value=d,e._accept=a,e._acceptObservable=b,e.toString=c,e}}(),uc=sc.createOnError=function(){function a(a,b){return b(this.exception)}function b(a){return a.onError(this.exception)}function c(){return"OnError("+this.exception+")"}return function(d){var e=new sc("E");return e.exception=d,e._accept=a,e._acceptObservable=b,e.toString=c,e}}(),vc=sc.createOnCompleted=function(){function a(a,b,c){return c()}function b(a){return a.onCompleted()}function c(){return"OnCompleted()"}return function(){var d=new sc("C");return d._accept=a,d._acceptObservable=b,d.toString=c,d}}(),wc=ab.internals.Enumerator=function(a){this._next=a};wc.prototype.next=function(){return this._next()},wc.prototype[rb]=function(){return this};var xc=ab.internals.Enumerable=function(a){this._iterator=a};xc.prototype[rb]=function(){return this._iterator()},xc.prototype.concat=function(){var a=this;return new hd(function(b){var c,d=a[rb](),e=new gc,f=lc.scheduleRecursive(function(a){if(!c){try{var f=d.next()}catch(g){return b.onError(g)}if(f.done)return b.onCompleted();var h=f.value;ib(h)&&(h=ad(h));var i=new fc;e.setDisposable(i),i.setDisposable(h.subscribe(function(a){b.onNext(a)},function(a){b.onError(a)},a))}});return new ac(e,f,dc(function(){c=!0}))})},xc.prototype.catchError=function(){var a=this;return new hd(function(b){var c,d=a[rb](),e=new gc,f=lc.scheduleRecursiveWithState(null,function(a,f){if(!c){try{var g=d.next()}catch(h){return observer.onError(h)}if(g.done)return void(null!==a?b.onError(a):b.onCompleted());var i=g.value;ib(i)&&(i=ad(i));var j=new fc;e.setDisposable(j),j.setDisposable(i.subscribe(function(a){b.onNext(a)},f,function(){b.onCompleted()}))}});return new ac(e,f,dc(function(){c=!0}))})},xc.prototype.catchErrorWhen=function(a){var b=this;return new hd(function(c){var d,e,f=new kd,g=new kd,h=a(f),i=h.subscribe(g),j=b[rb](),k=new gc,l=lc.scheduleRecursive(function(a){if(!d){try{var b=j.next()}catch(h){return c.onError(h)}if(b.done)return void(e?c.onError(e):c.onCompleted());var i=b.value;ib(i)&&(i=ad(i));var l=new fc,m=new fc;k.setDisposable(new ac(m,l)),l.setDisposable(i.subscribe(function(a){c.onNext(a)},function(b){m.setDisposable(g.subscribe(a,function(a){c.onError(a)},function(){c.onCompleted()})),f.onNext(b)},function(){c.onCompleted()}))}});return new ac(i,k,l,dc(function(){d=!0}))})};var yc,zc=xc.repeat=function(a,b){return null==b&&(b=-1),new xc(function(){var c=b;return new wc(function(){return 0===c?sb:(c>0&&c--,{done:!1,value:a})})})},Ac=xc.of=function(a,b,c){if(b)var d=wb(b,c,3);return new xc(function(){var c=-1;return new wc(function(){return++c<a.length?{done:!1,value:b?d(a[c],c,a):a[c]}:sb})})},Bc=ab.Observer=function(){},Cc=Bc.create=function(a,b,c){return a||(a=bb),b||(b=hb),c||(c=bb),new Ec(a,b,c)},Dc=ab.internals.AbstractObserver=function(a){function b(){this.isStopped=!1,a.call(this)}function c(){throw new Error("Method not implemented")}return Wb(b,a),b.prototype.next=c,b.prototype.error=c,b.prototype.completed=c,b.prototype.onNext=function(a){this.isStopped||this.next(a)},b.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.error(a))},b.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.completed())},b.prototype.dispose=function(){this.isStopped=!0},b.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.error(a),!0)},b}(Bc),Ec=ab.AnonymousObserver=function(a){function b(b,c,d){a.call(this),this._onNext=b,this._onError=c,this._onCompleted=d}return Wb(b,a),b.prototype.next=function(a){this._onNext(a)},b.prototype.error=function(a){this._onError(a)},b.prototype.completed=function(){this._onCompleted()},b}(Dc),Fc=ab.Observable=function(){function a(a){if(ab.config.longStackSupport&&mb){try{throw new Error}catch(b){this.stack=b.stack.substring(b.stack.indexOf("\n")+1)}var c=this;this._subscribe=function(b){var e=b.onError.bind(b);return b.onError=function(a){d(a,c),e(a)},a.call(c,b)}}else this._subscribe=a}return yc=a.prototype,yc.subscribe=yc.forEach=function(a,b,c){return this._subscribe("object"==typeof a?a:Cc(a,b,c))},yc.subscribeOnNext=function(a,b){return this._subscribe(Cc("undefined"!=typeof b?function(c){a.call(b,c)}:a))},yc.subscribeOnError=function(a,b){return this._subscribe(Cc(null,"undefined"!=typeof b?function(c){a.call(b,c)}:a))},yc.subscribeOnCompleted=function(a,b){return this._subscribe(Cc(null,null,"undefined"!=typeof b?function(){a.call(b)}:a))},a}(),Gc=ab.ObservableBase=function(a){function b(a){return a&&"function"==typeof a.dispose?a:"function"==typeof a?dc(a):ec}function c(a,c){var d=c[0],e=c[1];try{d.setDisposable(b(e.subscribeCore(d)))}catch(f){if(!d.fail(f))throw f}}function d(a){var b=new id(a),d=[b,this];return mc.scheduleRequired()?mc.scheduleWithState(d,c):c(null,d),b}function e(){a.call(this,d)}return Wb(e,a),e.prototype.subscribeCore=function(){throw new Error("Not implemeneted")},e}(Fc),Hc=ab.internals.ScheduledObserver=function(a){function b(b,c){a.call(this),this.scheduler=b,this.observer=c,this.isAcquired=!1,this.hasFaulted=!1,this.queue=[],this.disposable=new gc}return Wb(b,a),b.prototype.next=function(a){var b=this;this.queue.push(function(){b.observer.onNext(a)})},b.prototype.error=function(a){var b=this;this.queue.push(function(){b.observer.onError(a)})},b.prototype.completed=function(){var a=this;this.queue.push(function(){a.observer.onCompleted()})},b.prototype.ensureActive=function(){var a=!1,b=this;!this.hasFaulted&&this.queue.length>0&&(a=!this.isAcquired,this.isAcquired=!0),a&&this.disposable.setDisposable(this.scheduler.scheduleRecursive(function(a){var c;if(!(b.queue.length>0))return void(b.isAcquired=!1);c=b.queue.shift();try{c()}catch(d){throw b.queue=[],b.hasFaulted=!0,d}a()}))},b.prototype.dispose=function(){a.prototype.dispose.call(this),this.disposable.dispose()},b}(Dc),Ic=function(a){function b(b){this.source=b,a.call(this)}return Wb(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new r(a))},b}(Gc);r.prototype.onNext=function(a){this.isStopped||this.a.push(a)},r.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.observer.onError(a))},r.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.observer.onNext(this.a),this.observer.onCompleted())},r.prototype.dispose=function(){this.isStopped=!0},r.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.observer.onError(a),!0)},yc.toArray=function(){return new Ic(this)},Fc.create=Fc.createWithDisposable=function(a,b){return new hd(a,b)};var Jc=Fc.defer=function(a){return new hd(function(b){var c;try{c=a()}catch(d){return Uc(d).subscribe(b)}return ib(c)&&(c=ad(c)),c.subscribe(b)})},Kc=Fc.empty=function(a){return cb(a)||(a=lc),new hd(function(b){return a.schedule(function(){b.onCompleted()})})},Lc=function(a){function b(b,c,d){this.iterable=b,this.mapper=c,this.scheduler=d,a.call(this)}return Wb(b,a),b.prototype.subscribeCore=function(a){var b=new Mc(a,this);return b.run()},b}(Gc),Mc=function(){function a(a,b){this.observer=a,this.parent=b}return a.prototype.run=function(){function a(a,b){try{var f=c.next()}catch(g){return d.onError(g)}if(f.done)return d.onCompleted();var h=f.value;if(e)try{h=e(h,a)}catch(g){return d.onError(g)}d.onNext(h),b(a+1)}var b=Object(this.parent.iterable),c=y(b),d=this.observer,e=this.parent.mapper;return this.parent.scheduler.scheduleRecursiveWithState(0,a)},a}(),Nc=Math.pow(2,53)-1;t.prototype[rb]=function(){return new u(this._s)},u.prototype[rb]=function(){return this},u.prototype.next=function(){return this._i<this._l?{done:!1,value:this._s.charAt(this._i++)}:sb},v.prototype[rb]=function(){return new w(this._a)},w.prototype[rb]=function(){return this},w.prototype.next=function(){return this._i<this._l?{done:!1,value:this._a[this._i++]}:sb};var Oc=Fc.from=function(a,b,c,d){if(null==a)throw new Error("iterable cannot be null.");if(b&&!jb(b))throw new Error("mapFn when provided must be a function");if(b)var e=wb(b,c,2);
3
+ return cb(d)||(d=mc),new Lc(a,e,d)},Pc=function(a){function b(b,c){this.args=b,this.scheduler=c||mc,a.call(this)}return Wb(b,a),b.prototype.subscribeCore=function(a){var b=new B(a,this);return b.run()},b}(Gc);B.prototype.run=function(){function a(a,e){d>a?(b.onNext(c[a]),e(a+1)):b.onCompleted()}var b=this.observer,c=this.parent.args,d=c.length;return this.parent.scheduler.scheduleRecursiveWithState(0,a)};{var Qc=Fc.fromArray=function(a,b){return new Pc(a,b)};Fc.never=function(){return new hd(function(){return ec})}}Fc.of=function(){for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];return new Pc(b)},Fc.ofWithScheduler=function(a){for(var b=arguments.length,c=new Array(b-1),d=1;b>d;d++)c[d-1]=arguments[d];return new Pc(c,a)},Fc.pairs=function(a,b){return b||(b=ab.Scheduler.currentThread),new hd(function(c){var d=Object.keys(a),e=d.length;return b.scheduleRecursiveWithState(0,function(b,f){if(e>b){var g=d[b];c.onNext([g,a[g]]),f(b+1)}else c.onCompleted()})})};var Rc=function(a){function b(b,c,d){this.start=b,this.count=c,this.scheduler=d,a.call(this)}return Wb(b,a),b.prototype.subscribeCore=function(a){var b=new Sc(a,this);return b.run()},b}(Gc),Sc=function(){function a(a,b){this.observer=a,this.parent=b}return a.prototype.run=function(){function a(a,e){c>a?(d.onNext(b+a),e(a+1)):d.onCompleted()}var b=this.parent.start,c=this.parent.count,d=this.observer;return this.parent.scheduler.scheduleRecursiveWithState(0,a)},a}();Fc.range=function(a,b,c){return cb(c)||(c=mc),new Rc(a,b,c)},Fc.repeat=function(a,b,c){return cb(c)||(c=mc),Tc(a,c).repeat(null==b?-1:b)};var Tc=Fc["return"]=Fc.just=function(a,b){return cb(b)||(b=lc),new hd(function(c){return b.schedule(function(){c.onNext(a),c.onCompleted()})})};Fc.returnValue=function(){return Tc.apply(null,arguments)};var Uc=Fc["throw"]=Fc.throwError=function(a,b){return cb(b)||(b=lc),new hd(function(c){return b.schedule(function(){c.onError(a)})})};Fc.throwException=function(){return Fc.throwError.apply(null,arguments)},yc["catch"]=yc.catchError=yc.catchException=function(a){return"function"==typeof a?D(this,a):Vc([this,a])};var Vc=Fc.catchError=Fc["catch"]=Fc.catchException=function(){var a=[];if(Array.isArray(arguments[0]))a=arguments[0];else for(var b=0,c=arguments.length;c>b;b++)a.push(arguments[b]);return Ac(a).catchError()};yc.combineLatest=function(){for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];return Array.isArray(b[0])?b[0].unshift(this):b.unshift(this),Wc.apply(this,b)};var Wc=Fc.combineLatest=function(){for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];var d=b.pop();return a--,Array.isArray(b[0])&&(b=b[0]),new hd(function(c){function e(a){if(h[a]=!0,i||(i=h.every(db))){try{var b=d.apply(null,k)}catch(e){return void c.onError(e)}c.onNext(b)}else j.filter(function(b,c){return c!==a}).every(db)&&c.onCompleted()}function f(a){j[a]=!0,j.every(db)&&c.onCompleted()}for(var g=function(){return!1},h=p(a,g),i=!1,j=p(a,g),k=new Array(a),l=new Array(a),m=0;a>m;m++)!function(a){var d=b[a],g=new fc;ib(d)&&(d=ad(d)),g.setDisposable(d.subscribe(function(b){k[a]=b,e(a)},function(a){c.onError(a)},function(){f(a)})),l[a]=g}(m);return new ac(l)},this)};yc.concat=function(){for(var a=[],b=0,c=arguments.length;c>b;b++)a.push(arguments[b]);return a.unshift(this),Xc.apply(null,a)};var Xc=Fc.concat=function(){var a;if(Array.isArray(arguments[0]))a=arguments[0];else{a=new Array(arguments.length);for(var b=0,c=arguments.length;c>b;b++)a[b]=arguments[b]}return Ac(a).concat()};yc.concatAll=yc.concatObservable=function(){return this.merge(1)},yc.merge=function(a){if("number"!=typeof a)return Yc(this,a);var b=this;return new hd(function(c){function d(a){var b=new fc;f.add(b),ib(a)&&(a=ad(a)),b.setDisposable(a.subscribe(function(a){c.onNext(a)},function(a){c.onError(a)},function(){f.remove(b),h.length>0?d(h.shift()):(e--,g&&0===e&&c.onCompleted())}))}var e=0,f=new ac,g=!1,h=[];return f.add(b.subscribe(function(b){a>e?(e++,d(b)):h.push(b)},function(a){c.onError(a)},function(){g=!0,0===e&&c.onCompleted()})),f},b)};var Yc=Fc.merge=function(){var a,b,c=[],d=arguments.length;if(arguments[0])if(cb(arguments[0]))for(a=arguments[0],b=1;d>b;b++)c.push(arguments[b]);else for(a=lc,b=0;d>b;b++)c.push(arguments[b]);else for(a=lc,b=1;d>b;b++)c.push(arguments[b]);return Array.isArray(c[0])&&(c=c[0]),C(a,c).mergeAll()};yc.mergeAll=yc.mergeObservable=function(){var a=this;return new hd(function(b){var c=new ac,d=!1,e=new fc;return c.add(e),e.setDisposable(a.subscribe(function(a){var e=new fc;c.add(e),ib(a)&&(a=ad(a)),e.setDisposable(a.subscribe(function(a){b.onNext(a)},function(a){b.onError(a)},function(){c.remove(e),d&&1===c.length&&b.onCompleted()}))},function(a){b.onError(a)},function(){d=!0,1===c.length&&b.onCompleted()})),c},a)},yc.skipUntil=function(a){var b=this;return new hd(function(c){var d=!1,e=new ac(b.subscribe(function(a){d&&c.onNext(a)},function(a){c.onError(a)},function(){d&&c.onCompleted()}));ib(a)&&(a=ad(a));var f=new fc;return e.add(f),f.setDisposable(a.subscribe(function(){d=!0,f.dispose()},function(a){c.onError(a)},function(){f.dispose()})),e},b)},yc["switch"]=yc.switchLatest=function(){var a=this;return new hd(function(b){var c=!1,d=new gc,e=!1,f=0,g=a.subscribe(function(a){var g=new fc,h=++f;c=!0,d.setDisposable(g),ib(a)&&(a=ad(a)),g.setDisposable(a.subscribe(function(a){f===h&&b.onNext(a)},function(a){f===h&&b.onError(a)},function(){f===h&&(c=!1,e&&b.onCompleted())}))},function(a){b.onError(a)},function(){e=!0,!c&&b.onCompleted()});return new ac(g,d)},a)},yc.takeUntil=function(a){var b=this;return new hd(function(c){return ib(a)&&(a=ad(a)),new ac(b.subscribe(c),a.subscribe(function(){c.onCompleted()},function(a){c.onError(a)},bb))},b)},yc.withLatestFrom=function(){for(var a=[],b=0,c=arguments.length;c>b;b++)a.push(arguments[b]);var d=a.pop(),e=this;if("undefined"==typeof e)throw new Error("Source observable not found for withLatestFrom().");if("function"!=typeof d)throw new Error("withLatestFrom() expects a resultSelector function.");return Array.isArray(a[0])&&(a=a[0]),new hd(function(b){for(var c=function(){return!1},f=a.length,g=p(f,c),h=!1,i=new Array(f),j=new Array(f+1),k=0;f>k;k++)!function(c){var d=a[c],e=new fc;ib(d)&&(d=ad(d)),e.setDisposable(d.subscribe(function(a){i[c]=a,g[c]=!0,h=g.every(db)},b.onError.bind(b),function(){})),j[c]=e}(k);var l=new fc;return l.setDisposable(e.subscribe(function(a){var c,e=[a].concat(i);if(h){try{c=d.apply(null,e)}catch(f){return void b.onError(f)}b.onNext(c)}},b.onError.bind(b),function(){b.onCompleted()})),j[f]=l,new ac(j)},this)},yc.zip=function(){if(Array.isArray(arguments[0]))return E.apply(this,arguments);for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];var d=this,e=b.pop();return b.unshift(d),new hd(function(a){function c(b){var c,f;if(h.every(function(a){return a.length>0})){try{f=h.map(function(a){return a.shift()}),c=e.apply(d,f)}catch(g){return void a.onError(g)}a.onNext(c)}else i.filter(function(a,c){return c!==b}).every(db)&&a.onCompleted()}function f(b){i[b]=!0,i.every(function(a){return a})&&a.onCompleted()}for(var g=b.length,h=p(g,G),i=p(g,F),j=new Array(g),k=0;g>k;k++)!function(d){var e=b[d],g=new fc;ib(e)&&(e=ad(e)),g.setDisposable(e.subscribe(function(a){h[d].push(a),c(d)},function(b){a.onError(b)},function(){f(d)})),j[d]=g}(k);return new ac(j)},d)},Fc.zip=function(){for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];var d=b.shift();return d.zip.apply(d,b)},Fc.zipArray=function(){var a;if(Array.isArray(arguments[0]))a=arguments[0];else{var b=arguments.length;a=new Array(b);for(var c=0;b>c;c++)a[c]=arguments[c]}return new hd(function(b){function c(a){if(f.every(function(a){return a.length>0})){var c=f.map(function(a){return a.shift()});b.onNext(c)}else if(g.filter(function(b,c){return c!==a}).every(db))return void b.onCompleted()}function d(a){return g[a]=!0,g.every(db)?void b.onCompleted():void 0}for(var e=a.length,f=p(e,function(){return[]}),g=p(e,function(){return!1}),h=new Array(e),i=0;e>i;i++)!function(e){h[e]=new fc,h[e].setDisposable(a[e].subscribe(function(a){f[e].push(a),c(e)},function(a){b.onError(a)},function(){d(e)}))}(i);return new ac(h)})},yc.asObservable=function(){var a=this;return new hd(function(b){return a.subscribe(b)},this)},yc.dematerialize=function(){var a=this;return new hd(function(b){return a.subscribe(function(a){return a.accept(b)},function(a){b.onError(a)},function(){b.onCompleted()})},this)},yc.distinctUntilChanged=function(a,b){var c=this;return b||(b=fb),new hd(function(d){var e,f=!1;return c.subscribe(function(c){var g=c;if(a)try{g=a(c)}catch(h){return void d.onError(h)}if(f)try{var i=b(e,g)}catch(h){return void d.onError(h)}f&&i||(f=!0,e=g,d.onNext(c))},function(a){d.onError(a)},function(){d.onCompleted()})},this)},yc["do"]=yc.tap=yc.doAction=function(a,b,c){var d=this,e="function"==typeof a||"undefined"==typeof a?Cc(a||bb,b||bb,c||bb):a;return new hd(function(a){return d.subscribe(function(b){try{e.onNext(b)}catch(c){a.onError(c)}a.onNext(b)},function(b){try{e.onError(b)}catch(c){a.onError(c)}a.onError(b)},function(){try{e.onCompleted()}catch(b){a.onError(b)}a.onCompleted()})},this)},yc.doOnNext=yc.tapOnNext=function(a,b){return this.tap("undefined"!=typeof b?function(c){a.call(b,c)}:a)},yc.doOnError=yc.tapOnError=function(a,b){return this.tap(bb,"undefined"!=typeof b?function(c){a.call(b,c)}:a)},yc.doOnCompleted=yc.tapOnCompleted=function(a,b){return this.tap(bb,null,"undefined"!=typeof b?function(){a.call(b)}:a)},yc["finally"]=yc.ensure=function(a){var b=this;return new hd(function(c){var d;try{d=b.subscribe(c)}catch(e){throw a(),e}return dc(function(){try{d.dispose()}catch(b){throw b}finally{a()}})},this)},yc.finallyAction=function(a){return this.ensure(a)},yc.ignoreElements=function(){var a=this;return new hd(function(b){return a.subscribe(bb,function(a){b.onError(a)},function(){b.onCompleted()})},a)},yc.materialize=function(){var a=this;return new hd(function(b){return a.subscribe(function(a){b.onNext(tc(a))},function(a){b.onNext(uc(a)),b.onCompleted()},function(){b.onNext(vc()),b.onCompleted()})},a)},yc.repeat=function(a){return zc(this,a).concat()},yc.retry=function(a){return zc(this,a).catchError()},yc.retryWhen=function(a){return zc(this).catchErrorWhen(a)},yc.scan=function(){var a,b,c=!1,d=this;return 2===arguments.length?(c=!0,a=arguments[0],b=arguments[1]):b=arguments[0],new hd(function(e){var f,g,h;return d.subscribe(function(d){!h&&(h=!0);try{f?g=b(g,d):(g=c?b(a,d):d,f=!0)}catch(i){return void e.onError(i)}e.onNext(g)},function(a){e.onError(a)},function(){!h&&c&&e.onNext(a),e.onCompleted()})},d)},yc.skipLast=function(a){var b=this;return new hd(function(c){var d=[];return b.subscribe(function(b){d.push(b),d.length>a&&c.onNext(d.shift())},function(a){c.onError(a)},function(){c.onCompleted()})},b)},yc.startWith=function(){var a,b=0;arguments.length&&cb(arguments[0])?(a=arguments[0],b=1):a=lc;for(var c=[],d=b,e=arguments.length;e>d;d++)c.push(arguments[d]);return Ac([Qc(c,a),this]).concat()},yc.takeLast=function(a){var b=this;return new hd(function(c){var d=[];return b.subscribe(function(b){d.push(b),d.length>a&&d.shift()},function(a){c.onError(a)},function(){for(;d.length>0;)c.onNext(d.shift());c.onCompleted()})},b)},yc.selectConcat=yc.concatMap=function(a,b,c){return jb(a)&&jb(b)?this.concatMap(function(c,d){var e=a(c,d);return ib(e)&&(e=ad(e)),(ub(e)||tb(e))&&(e=Oc(e)),e.map(function(a,e){return b(c,a,d,e)})}):jb(a)?H(this,a,c):H(this,function(){return a})};var Zc=function(a){function b(b,c,d){this.source=b,this.selector=wb(c,d,3),a.call(this)}return Wb(b,a),b.prototype.internalMap=function(a,c){var d=this;return new b(this.source,function(b,c,e){return a(d.selector(b,c,e),c,e)},c)},b.prototype.subscribeCore=function(a){return this.source.subscribe(new I(a,this.selector,this))},b}(Gc);I.prototype.onNext=function(a){if(!this.isStopped){try{var b=this.selector(a,this.i++,this.source)}catch(c){return this.observer.onError(c)}this.observer.onNext(b)}},I.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.observer.onError(a))},I.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.observer.onCompleted())},I.prototype.dispose=function(){this.isStopped=!0},I.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.observer.onError(a),!0)},yc.map=yc.select=function(a,b){var c="function"==typeof a?a:function(){return a};return this instanceof Zc?this.internalMap(c,b):new Zc(this,c,b)},yc.pluck=function(){var b=arguments,c=arguments.length;if(0===c)throw new Error("List of properties cannot be empty.");return this.map(function(d){for(var e=d,f=0;c>f;f++){var g=e[b[f]];if("undefined"==typeof g)return a;e=g}return e})},yc.selectMany=yc.flatMap=function(a,b,c){return jb(a)&&jb(b)?this.flatMap(function(c,d){var e=a(c,d);return ib(e)&&(e=ad(e)),(ub(e)||tb(e))&&(e=Oc(e)),e.map(function(a,e){return b(c,a,d,e)})},c):jb(a)?J(this,a,c):J(this,function(){return a})},yc.selectSwitch=yc.flatMapLatest=yc.switchMap=function(a,b){return this.select(a,b).switchLatest()},yc.skip=function(a){if(0>a)throw new Error(kb);var b=this;return new hd(function(c){var d=a;return b.subscribe(function(a){0>=d?c.onNext(a):d--},function(a){c.onError(a)},function(){c.onCompleted()})},b)},yc.skipWhile=function(a,b){var c=this,d=wb(a,b,3);return new hd(function(a){var b=0,e=!1;return c.subscribe(function(f){if(!e)try{e=!d(f,b++,c)}catch(g){return void a.onError(g)}e&&a.onNext(f)},function(b){a.onError(b)},function(){a.onCompleted()})},c)},yc.take=function(a,b){if(0>a)throw new RangeError(kb);if(0===a)return Kc(b);var c=this;return new hd(function(b){var d=a;return c.subscribe(function(a){d-->0&&(b.onNext(a),0===d&&b.onCompleted())},function(a){b.onError(a)},function(){b.onCompleted()})},c)},yc.takeWhile=function(a,b){var c=this,d=wb(a,b,3);return new hd(function(a){var b=0,e=!0;return c.subscribe(function(f){if(e){try{e=d(f,b++,c)}catch(g){return void a.onError(g)}e?a.onNext(f):a.onCompleted()}},function(b){a.onError(b)},function(){a.onCompleted()})},c)};var $c=function(a){function b(b,c,d){this.source=b,this.predicate=wb(c,d,3),a.call(this)}return Wb(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new K(a,this.predicate,this))},b.prototype.internalFilter=function(a,c){var d=this;return new b(this.source,function(b,c,e){return d.predicate(b,c,e)&&a(b,c,e)},c)},b}(Gc);K.prototype.onNext=function(a){if(!this.isStopped){try{var b=this.predicate(a,this.i++,this.source)}catch(c){return this.observer.onError(c)}b&&this.observer.onNext(a)}},K.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.observer.onError(a))},K.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.observer.onCompleted())},K.prototype.dispose=function(){this.isStopped=!0},K.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.observer.onError(a),!0)},yc.filter=yc.where=function(a,b){return this instanceof $c?this.internalFilter(a,b):new $c(this,a,b)},Fc.fromCallback=function(a,b,c){return function(){for(var d=[],e=0,f=arguments.length;f>e;e++)d.push(arguments[e]);return new hd(function(e){function f(){var a=arguments;if(c){try{a=c(a)}catch(b){return e.onError(b)}e.onNext(a)}else a.length<=1?e.onNext.apply(e,a):e.onNext(a);e.onCompleted()}d.push(f),a.apply(b,d)}).publishLast().refCount()}},Fc.fromNodeCallback=function(a,b,c){return function(){for(var d=[],e=0,f=arguments.length;f>e;e++)d.push(arguments[e]);return new hd(function(e){function f(a){if(a)return void e.onError(a);for(var b=[],d=1,f=arguments.length;f>d;d++)b.push(arguments[d]);if(c){try{b=c(b)}catch(g){return e.onError(g)}e.onNext(b)}else b.length<=1?e.onNext.apply(e,b):e.onNext(b);e.onCompleted()}d.push(f),a.apply(b,d)}).publishLast().refCount()}},ab.config.useNativeEvents=!1,Fc.fromEvent=function(a,b,c){return a.addListener?_c(function(c){a.addListener(b,c)},function(c){a.removeListener(b,c)},c):ab.config.useNativeEvents||"function"!=typeof a.on||"function"!=typeof a.off?new hd(function(d){return N(a,b,function(a){var b=a;if(c)try{b=c(arguments)}catch(e){return void d.onError(e)}d.onNext(b)})}).publish().refCount():_c(function(c){a.on(b,c)},function(c){a.off(b,c)},c)};var _c=Fc.fromEventPattern=function(a,b,c){return new hd(function(d){function e(a){var b=a;if(c)try{b=c(arguments)}catch(e){return void d.onError(e)}d.onNext(b)}var f=a(e);return dc(function(){b&&b(e,f)})}).publish().refCount()},ad=Fc.fromPromise=function(a){return Jc(function(){var b=new ab.AsyncSubject;return a.then(function(a){b.onNext(a),b.onCompleted()},b.onError.bind(b)),b})};yc.toPromise=function(a){if(a||(a=ab.config.Promise),!a)throw new TypeError("Promise type not provided nor in Rx.config.Promise");var b=this;return new a(function(a,c){var d,e=!1;b.subscribe(function(a){d=a,e=!0},c,function(){e&&a(d)})})},Fc.startAsync=function(a){var b;try{b=a()}catch(c){return Uc(c)}return ad(b)},yc.multicast=function(a,b){var c=this;return"function"==typeof a?new hd(function(d){var e=c.multicast(a());return new ac(b(e).subscribe(d),e.connect())},c):new bd(c,a)},yc.publish=function(a){return a&&jb(a)?this.multicast(function(){return new kd},a):this.multicast(new kd)},yc.share=function(){return this.publish().refCount()},yc.publishLast=function(a){return a&&jb(a)?this.multicast(function(){return new ld},a):this.multicast(new ld)},yc.publishValue=function(a,b){return 2===arguments.length?this.multicast(function(){return new nd(b)},a):this.multicast(new nd(a))},yc.shareValue=function(a){return this.publishValue(a).refCount()},yc.replay=function(a,b,c,d){return a&&jb(a)?this.multicast(function(){return new od(b,c,d)},a):this.multicast(new od(b,c,d))},yc.shareReplay=function(a,b,c){return this.replay(null,a,b,c).refCount()};{var bd=ab.ConnectableObservable=function(a){function b(b,c){var d,e=!1,f=b.asObservable();this.connect=function(){return e||(e=!0,d=new ac(f.subscribe(c),dc(function(){e=!1}))),d},a.call(this,function(a){return c.subscribe(a)})}return Wb(b,a),b.prototype.refCount=function(){var a,b=0,c=this;return new hd(function(d){var e=1===++b,f=c.subscribe(d);return e&&(a=c.connect()),function(){f.dispose(),0===--b&&a.dispose()}})},b}(Fc),cd=Fc.interval=function(a,b){return R(a,a,cb(b)?b:rc)};Fc.timer=function(b,c,d){var e;return cb(d)||(d=rc),c!==a&&"number"==typeof c?e=c:cb(c)&&(d=c),b instanceof Date&&e===a?O(b.getTime(),d):b instanceof Date&&e!==a?(e=c,P(b.getTime(),e,d)):e===a?Q(b,d):R(b,e,d)}}yc.delay=function(a,b){return cb(b)||(b=rc),a instanceof Date?T(this,a.getTime(),b):S(this,a,b)},yc.debounce=yc.throttleWithTimeout=function(a,b){cb(b)||(b=rc);var c=this;return new hd(function(d){var e,f=new gc,g=!1,h=0,i=c.subscribe(function(c){g=!0,e=c,h++;var i=h,j=new fc;f.setDisposable(j),j.setDisposable(b.scheduleWithRelative(a,function(){g&&h===i&&d.onNext(e),g=!1}))},function(a){f.dispose(),d.onError(a),g=!1,h++},function(){f.dispose(),g&&d.onNext(e),d.onCompleted(),g=!1,h++});return new ac(i,f)},this)},yc.throttle=function(a,b){return this.debounce(a,b)},yc.timestamp=function(a){return cb(a)||(a=rc),this.map(function(b){return{value:b,timestamp:a.now()}})},yc.sample=yc.throttleLatest=function(a,b){return cb(b)||(b=rc),"number"==typeof a?U(this,cd(a,b)):U(this,a)},yc.timeout=function(a,b,c){(null==b||"string"==typeof b)&&(b=Uc(new Error(b||"Timeout"))),cb(c)||(c=rc);var d=this,e=a instanceof Date?"scheduleWithAbsolute":"scheduleWithRelative";return new hd(function(f){function g(){var d=h;l.setDisposable(c[e](a,function(){h===d&&(ib(b)&&(b=ad(b)),j.setDisposable(b.subscribe(f)))}))}var h=0,i=new fc,j=new gc,k=!1,l=new gc;return j.setDisposable(i),g(),i.setDisposable(d.subscribe(function(a){k||(h++,f.onNext(a),g())},function(a){k||(h++,f.onError(a))},function(){k||(h++,f.onCompleted())})),new ac(j,l)},d)},yc.throttleFirst=function(a,b){cb(b)||(b=rc);var c=+a||0;if(0>=c)throw new RangeError("windowDuration cannot be less or equal zero.");var d=this;return new hd(function(a){var e=0;return d.subscribe(function(d){var f=b.now();(0===e||f-e>=c)&&(e=f,a.onNext(d))},function(b){a.onError(b)},function(){a.onCompleted()})},d)};var dd=function(a){function b(a){var b=this.source.publish(),c=b.subscribe(a),d=ec,e=this.pauser.distinctUntilChanged().subscribe(function(a){a?d=b.connect():(d.dispose(),d=ec)});return new ac(c,d,e)}function c(c,d){this.source=c,this.controller=new kd,this.pauser=d&&d.subscribe?this.controller.merge(d):this.controller,a.call(this,b,c)}return Wb(c,a),c.prototype.pause=function(){this.controller.onNext(!1)},c.prototype.resume=function(){this.controller.onNext(!0)},c}(Fc);yc.pausable=function(a){return new dd(this,a)};var ed=function(b){function c(b){var c,d=[],e=V(this.source,this.pauser.distinctUntilChanged().startWith(!1),function(a,b){return{data:a,shouldFire:b}}).subscribe(function(e){if(c!==a&&e.shouldFire!=c){if(c=e.shouldFire,e.shouldFire)for(;d.length>0;)b.onNext(d.shift())}else c=e.shouldFire,e.shouldFire?b.onNext(e.data):d.push(e.data)},function(a){for(;d.length>0;)b.onNext(d.shift());b.onError(a)},function(){for(;d.length>0;)b.onNext(d.shift());b.onCompleted()});return e}function d(a,d){this.source=a,this.controller=new kd,this.pauser=d&&d.subscribe?this.controller.merge(d):this.controller,b.call(this,c,a)}return Wb(d,b),d.prototype.pause=function(){this.controller.onNext(!1)},d.prototype.resume=function(){this.controller.onNext(!0)},d}(Fc);yc.pausableBuffered=function(a){return new ed(this,a)};var fd=function(a){function b(a){return this.source.subscribe(a)}function c(c,d){a.call(this,b,c),this.subject=new gd(d),this.source=c.multicast(this.subject).refCount()}return Wb(c,a),c.prototype.request=function(a){return null==a&&(a=-1),this.subject.request(a)},c}(Fc),gd=function(a){function b(a){return this.subject.subscribe(a)}function c(c){null==c&&(c=!0),a.call(this,b),this.subject=new kd,this.enableQueue=c,this.queue=c?[]:null,this.requestedCount=0,this.requestedDisposable=ec,this.error=null,this.hasFailed=!1,this.hasCompleted=!1,this.controlledDisposable=ec}return Wb(c,a),Xb(c.prototype,Bc,{onCompleted:function(){this.hasCompleted=!0,(!this.enableQueue||0===this.queue.length)&&this.subject.onCompleted()},onError:function(a){this.hasFailed=!0,this.error=a,(!this.enableQueue||0===this.queue.length)&&this.subject.onError(a)},onNext:function(a){var b=!1;0===this.requestedCount?this.enableQueue&&this.queue.push(a):(-1!==this.requestedCount&&0===this.requestedCount--&&this.disposeCurrentRequest(),b=!0),b&&this.subject.onNext(a)},_processRequest:function(a){if(this.enableQueue){for(;this.queue.length>=a&&a>0;)this.subject.onNext(this.queue.shift()),a--;return 0!==this.queue.length?{numberOfItems:a,returnValue:!0}:{numberOfItems:a,returnValue:!1}}return this.hasFailed?(this.subject.onError(this.error),this.controlledDisposable.dispose(),this.controlledDisposable=ec):this.hasCompleted&&(this.subject.onCompleted(),this.controlledDisposable.dispose(),this.controlledDisposable=ec),{numberOfItems:a,returnValue:!1}},request:function(a){this.disposeCurrentRequest();var b=this,c=this._processRequest(a),a=c.numberOfItems;return c.returnValue?ec:(this.requestedCount=a,this.requestedDisposable=dc(function(){b.requestedCount=0}),this.requestedDisposable)},disposeCurrentRequest:function(){this.requestedDisposable.dispose(),this.requestedDisposable=ec}}),c}(Fc);yc.controlled=function(a){return null==a&&(a=!0),new fd(this,a)},yc.transduce=function(a){function b(a){return{init:function(){return a},step:function(a,b){return a.onNext(b)},result:function(a){return a.onCompleted()}}}var c=this;return new hd(function(d){var e=a(b(d));return c.subscribe(function(a){try{e.step(d,a)}catch(b){d.onError(b)}},d.onError.bind(d),function(){e.result(d)})},c)};var hd=ab.AnonymousObservable=function(a){function b(a){return a&&"function"==typeof a.dispose?a:"function"==typeof a?dc(a):ec}function c(a,c){var d=c[0],e=c[1];try{d.setDisposable(b(e(d)))}catch(f){if(!d.fail(f))throw f}}function d(b,d){function e(a){var d=new id(a),e=[d,b];return mc.scheduleRequired()?mc.scheduleWithState(e,c):c(null,e),d}this.source=d,a.call(this,e)}return Wb(d,a),d}(Fc),id=function(a){function b(b){a.call(this),this.observer=b,this.m=new fc}Wb(b,a);var c=b.prototype;return c.next=function(a){var b=!1;try{this.observer.onNext(a),b=!0}catch(c){return o(c)}finally{!b&&this.dispose()}},c.error=function(a){try{this.observer.onError(a)}catch(b){return o(b)}finally{this.dispose()}},c.completed=function(){try{this.observer.onCompleted()}catch(a){return o(a)}finally{this.dispose()}},c.setDisposable=function(a){this.m.setDisposable(a)},c.getDisposable=function(){return this.m.getDisposable()},c.dispose=function(){a.prototype.dispose.call(this),this.m.dispose()},b}(Dc),jd=function(a,b){this.subject=a,this.observer=b};jd.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var a=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(a,1),this.observer=null}};var kd=ab.Subject=function(a){function d(a){return b(this),this.isStopped?this.hasError?(a.onError(this.error),ec):(a.onCompleted(),ec):(this.observers.push(a),new jd(this,a))}function e(){a.call(this,d),this.isDisposed=!1,this.isStopped=!1,this.observers=[],this.hasError=!1}return Wb(e,a),Xb(e.prototype,Bc.prototype,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(b(this),!this.isStopped){this.isStopped=!0;for(var a=0,d=c(this.observers),e=d.length;e>a;a++)d[a].onCompleted();this.observers.length=0}},onError:function(a){if(b(this),!this.isStopped){this.isStopped=!0,this.error=a,this.hasError=!0;for(var d=0,e=c(this.observers),f=e.length;f>d;d++)e[d].onError(a);this.observers.length=0}},onNext:function(a){if(b(this),!this.isStopped)for(var d=0,e=c(this.observers),f=e.length;f>d;d++)e[d].onNext(a)},dispose:function(){this.isDisposed=!0,this.observers=null}}),e.create=function(a,b){return new md(a,b)},e}(Fc),ld=ab.AsyncSubject=function(a){function d(a){return b(this),this.isStopped?(this.hasError?a.onError(this.error):this.hasValue?(a.onNext(this.value),a.onCompleted()):a.onCompleted(),ec):(this.observers.push(a),new jd(this,a))}function e(){a.call(this,d),this.isDisposed=!1,this.isStopped=!1,this.hasValue=!1,this.observers=[],this.hasError=!1}return Wb(e,a),Xb(e.prototype,Bc,{hasObservers:function(){return b(this),this.observers.length>0},onCompleted:function(){var a,d;if(b(this),!this.isStopped){this.isStopped=!0;var e=c(this.observers),d=e.length;if(this.hasValue)for(a=0;d>a;a++){var f=e[a];f.onNext(this.value),f.onCompleted()}else for(a=0;d>a;a++)e[a].onCompleted();this.observers.length=0}},onError:function(a){if(b(this),!this.isStopped){this.isStopped=!0,this.hasError=!0,this.error=a;for(var d=0,e=c(this.observers),f=e.length;f>d;d++)e[d].onError(a);this.observers.length=0}},onNext:function(a){b(this),this.isStopped||(this.value=a,this.hasValue=!0)},dispose:function(){this.isDisposed=!0,this.observers=null,this.exception=null,this.value=null}}),e}(Fc),md=ab.AnonymousSubject=function(a){function b(a){return this.observable.subscribe(a)}function c(c,d){this.observer=c,this.observable=d,a.call(this,b)}return Wb(c,a),Xb(c.prototype,Bc.prototype,{onCompleted:function(){this.observer.onCompleted()},onError:function(a){this.observer.onError(a)},onNext:function(a){this.observer.onNext(a)}}),c}(Fc),nd=ab.BehaviorSubject=function(a){function d(a){return b(this),this.isStopped?(this.hasError?a.onError(this.error):a.onCompleted(),ec):(this.observers.push(a),a.onNext(this.value),new jd(this,a))}function e(b){a.call(this,d),this.value=b,this.observers=[],this.isDisposed=!1,this.isStopped=!1,this.hasError=!1}return Wb(e,a),Xb(e.prototype,Bc,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(b(this),!this.isStopped){this.isStopped=!0;for(var a=0,d=c(this.observers),e=d.length;e>a;a++)d[a].onCompleted();this.observers.length=0}},onError:function(a){if(b(this),!this.isStopped){this.isStopped=!0,this.hasError=!0,this.error=a;for(var d=0,e=c(this.observers),f=e.length;f>d;d++)e[d].onError(a);this.observers.length=0}},onNext:function(a){if(b(this),!this.isStopped){this.value=a;for(var d=0,e=c(this.observers),f=e.length;f>d;d++)e[d].onNext(a)}},dispose:function(){this.isDisposed=!0,this.observers=null,this.value=null,this.exception=null}}),e}(Fc),od=ab.ReplaySubject=function(a){function d(a,b){return dc(function(){b.dispose(),!a.isDisposed&&a.observers.splice(a.observers.indexOf(b),1)})}function e(a){var c=new Hc(this.scheduler,a),e=d(this,c);b(this),this._trim(this.scheduler.now()),this.observers.push(c);for(var f=0,g=this.q.length;g>f;f++)c.onNext(this.q[f].value);return this.hasError?c.onError(this.error):this.isStopped&&c.onCompleted(),c.ensureActive(),e}function f(b,c,d){this.bufferSize=null==b?Number.MAX_VALUE:b,this.windowSize=null==c?Number.MAX_VALUE:c,this.scheduler=d||mc,this.q=[],this.observers=[],this.isStopped=!1,this.isDisposed=!1,this.hasError=!1,this.error=null,a.call(this,e)}return Wb(f,a),Xb(f.prototype,Bc.prototype,{hasObservers:function(){return this.observers.length>0},_trim:function(a){for(;this.q.length>this.bufferSize;)this.q.shift();for(;this.q.length>0&&a-this.q[0].interval>this.windowSize;)this.q.shift()},onNext:function(a){if(b(this),!this.isStopped){var d=this.scheduler.now();this.q.push({interval:d,value:a}),this._trim(d);for(var e=0,f=c(this.observers),g=f.length;g>e;e++){var h=f[e];h.onNext(a),h.ensureActive()}}},onError:function(a){if(b(this),!this.isStopped){this.isStopped=!0,this.error=a,this.hasError=!0;var d=this.scheduler.now();this._trim(d);for(var e=0,f=c(this.observers),g=f.length;g>e;e++){var h=f[e];h.onError(a),h.ensureActive()}this.observers.length=0}},onCompleted:function(){if(b(this),!this.isStopped){this.isStopped=!0;var a=this.scheduler.now();this._trim(a);for(var d=0,e=c(this.observers),f=e.length;f>d;d++){var g=e[d];g.onCompleted(),g.ensureActive()}this.observers.length=0}},dispose:function(){this.isDisposed=!0,this.observers=null}}),f}(Fc);ab.Pauser=function(a){function b(){a.call(this)}return Wb(b,a),b.prototype.pause=function(){this.onNext(!1)},b.prototype.resume=function(){this.onNext(!0)},b}(kd),"function"==typeof define&&"object"==typeof define.amd&&define.amd?(X.Rx=ab,define(function(){return ab})):Y&&Z?$?(Z.exports=ab).Rx=ab:Y.Rx=ab:X.Rx=ab;var pd=h()}).call(this);
4
4
  //# sourceMappingURL=rx.lite.compat.map
@@ -38,6 +38,10 @@
38
38
  observableNever = Observable.never,
39
39
  observableThrow = Observable.throwException,
40
40
  AnonymousObservable = Rx.AnonymousObservable,
41
+ AnonymousObserver = Rx.AnonymousObserver,
42
+ notificationCreateOnNext = Rx.Notification.createOnNext,
43
+ notificationCreateOnError = Rx.Notification.createOnError,
44
+ notificationCreateOnCompleted = Rx.Notification.createOnCompleted,
41
45
  Observer = Rx.Observer,
42
46
  Subject = Rx.Subject,
43
47
  internals = Rx.internals,
@@ -54,6 +58,7 @@
54
58
  identity = helpers.identity,
55
59
  isPromise = helpers.isPromise,
56
60
  inherits = internals.inherits,
61
+ bindCallback = internals.bindCallback,
57
62
  noop = helpers.noop,
58
63
  isScheduler = helpers.isScheduler,
59
64
  observableFromPromise = Observable.fromPromise,
@@ -67,21 +72,22 @@
67
72
 
68
73
  var argumentOutOfRange = 'Argument out of range';
69
74
 
70
- function ScheduledDisposable(scheduler, disposable) {
71
- this.scheduler = scheduler;
72
- this.disposable = disposable;
73
- this.isDisposed = false;
75
+ function ScheduledDisposable(scheduler, disposable) {
76
+ this.scheduler = scheduler;
77
+ this.disposable = disposable;
78
+ this.isDisposed = false;
79
+ }
80
+
81
+ function scheduleItem(s, self) {
82
+ if (!self.isDisposed) {
83
+ self.isDisposed = true;
84
+ self.disposable.dispose();
74
85
  }
86
+ }
75
87
 
76
- ScheduledDisposable.prototype.dispose = function () {
77
- var parent = this;
78
- this.scheduler.schedule(function () {
79
- if (!parent.isDisposed) {
80
- parent.isDisposed = true;
81
- parent.disposable.dispose();
82
- }
83
- });
84
- };
88
+ ScheduledDisposable.prototype.dispose = function () {
89
+ this.scheduler.scheduleWithState(this, scheduleItem);
90
+ };
85
91
 
86
92
  var CheckedObserver = (function (_super) {
87
93
  inherits(CheckedObserver, _super);
@@ -168,6 +174,61 @@
168
174
  return ObserveOnObserver;
169
175
  })(ScheduledObserver);
170
176
 
177
+ /**
178
+ * Checks access to the observer for grammar violations. This includes checking for multiple OnError or OnCompleted calls, as well as reentrancy in any of the observer methods.
179
+ * If a violation is detected, an Error is thrown from the offending observer method call.
180
+ *
181
+ * @returns An observer that checks callbacks invocations against the observer grammar and, if the checks pass, forwards those to the specified observer.
182
+ */
183
+ Observer.prototype.checked = function () { return new CheckedObserver(this); };
184
+
185
+ /**
186
+ * Schedules the invocation of observer methods on the given scheduler.
187
+ * @param {Scheduler} scheduler Scheduler to schedule observer messages on.
188
+ * @returns {Observer} Observer whose messages are scheduled on the given scheduler.
189
+ */
190
+ Observer.notifyOn = function (scheduler) {
191
+ return new ObserveOnObserver(scheduler, this);
192
+ };
193
+
194
+ /**
195
+ * Creates an observer from a notification callback.
196
+ * @param {Function} handler Action that handles a notification.
197
+ * @returns The observer object that invokes the specified handler using a notification corresponding to each message it receives.
198
+ */
199
+ Observer.fromNotifier = function (handler, thisArg) {
200
+ var handlerFunc = bindCallback(handler, thisArg, 1);
201
+ return new AnonymousObserver(function (x) {
202
+ return handlerFunc(notificationCreateOnNext(x));
203
+ }, function (e) {
204
+ return handlerFunc(notificationCreateOnError(e));
205
+ }, function () {
206
+ return handlerFunc(notificationCreateOnCompleted());
207
+ });
208
+ };
209
+
210
+ /**
211
+ * Creates a notification callback from an observer.
212
+ * @returns The action that forwards its input notification to the underlying observer.
213
+ */
214
+ Observer.prototype.toNotifier = function () {
215
+ var observer = this;
216
+ return function (n) { return n.accept(observer); };
217
+ };
218
+
219
+ /**
220
+ * Hides the identity of an observer.
221
+ * @returns An observer that hides the identity of the specified observer.
222
+ */
223
+ Observer.prototype.asObserver = function () {
224
+ var source = this;
225
+ return new AnonymousObserver(
226
+ function (x) { source.onNext(x); },
227
+ function (e) { source.onError(e); },
228
+ function () { source.onCompleted(); }
229
+ );
230
+ };
231
+
171
232
  /**
172
233
  * Wraps the source sequence in order to run its observer callbacks on the specified scheduler.
173
234
  *
@@ -344,8 +405,13 @@
344
405
  * @returns {Observable} An observable sequence that surfaces any of the given sequences, whichever reacted first.
345
406
  */
346
407
  Observable.amb = function () {
347
- var acc = observableNever(),
348
- items = argsOrArray(arguments, 0);
408
+ var acc = observableNever(), items = [];
409
+ if (Array.isArray(arguments[0])) {
410
+ items = arguments[0];
411
+ } else {
412
+ for(var i = 0, len = arguments.length; i < len; i++) { items.push(arguments[i]); }
413
+ }
414
+
349
415
  function func(previous, current) {
350
416
  return previous.amb(current);
351
417
  }
@@ -374,7 +440,12 @@
374
440
  * @returns {Observable} An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.
375
441
  */
376
442
  var onErrorResumeNext = Observable.onErrorResumeNext = function () {
377
- var sources = argsOrArray(arguments, 0);
443
+ var sources = [];
444
+ if (Array.isArray(arguments[0])) {
445
+ sources = arguments[0];
446
+ } else {
447
+ for(var i = 0, len = arguments.length; i < len; i++) { sources.push(arguments[i]); }
448
+ }
378
449
  return new AnonymousObservable(function (observer) {
379
450
  var pos = 0, subscription = new SerialDisposable(),
380
451
  cancelable = immediateScheduler.scheduleRecursive(function (self) {
@@ -478,14 +549,14 @@
478
549
  */
479
550
  observableProto.takeLastBuffer = function (count) {
480
551
  var source = this;
481
- return new AnonymousObservable(function (observer) {
552
+ return new AnonymousObservable(function (o) {
482
553
  var q = [];
483
554
  return source.subscribe(function (x) {
484
555
  q.push(x);
485
556
  q.length > count && q.shift();
486
- }, observer.onError.bind(observer), function () {
487
- observer.onNext(q);
488
- observer.onCompleted();
557
+ }, function (e) { o.onError(e); }, function () {
558
+ o.onNext(q);
559
+ o.onCompleted();
489
560
  });
490
561
  }, source);
491
562
  };
@@ -508,11 +579,13 @@
508
579
  return source.subscribe(function (x) {
509
580
  found = true;
510
581
  observer.onNext(x);
511
- }, observer.onError.bind(observer), function () {
582
+ },
583
+ function (e) { observer.onError(e); },
584
+ function () {
512
585
  !found && observer.onNext(defaultValue);
513
586
  observer.onCompleted();
514
587
  });
515
- }, this);
588
+ }, source);
516
589
  };
517
590
 
518
591
  // Swap out for Array.findIndex
@@ -548,7 +621,7 @@
548
621
  observableProto.distinct = function (keySelector, comparer) {
549
622
  var source = this;
550
623
  comparer || (comparer = defaultComparer);
551
- return new AnonymousObservable(function (observer) {
624
+ return new AnonymousObservable(function (o) {
552
625
  var hashSet = new HashSet(comparer);
553
626
  return source.subscribe(function (x) {
554
627
  var key = x;
@@ -557,14 +630,13 @@
557
630
  try {
558
631
  key = keySelector(x);
559
632
  } catch (e) {
560
- observer.onError(e);
633
+ o.onError(e);
561
634
  return;
562
635
  }
563
636
  }
564
- hashSet.push(key) && observer.onNext(x);
637
+ hashSet.push(key) && o.onNext(x);
565
638
  },
566
- observer.onError.bind(observer),
567
- observer.onCompleted.bind(observer));
639
+ function (e) { o.onError(e); }, function () { o.onCompleted(); });
568
640
  }, this);
569
641
  };
570
642
 
@@ -1,3 +1,3 @@
1
1
  /* Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.*/
2
- (function(a){var b={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},c=b[typeof window]&&window||this,d=b[typeof exports]&&exports&&!exports.nodeType&&exports,e=b[typeof module]&&module&&!module.nodeType&&module,f=(e&&e.exports===d&&d,b[typeof global]&&global);!f||f.global!==f&&f.window!==f||(c=f),"function"==typeof define&&define.amd?define(["rx"],function(b,d){return a(c,d,b)}):"object"==typeof module&&module&&module.exports===d?module.exports=a(c,module.exports,require("./rx")):c.Rx=a(c,{},c.Rx)}).call(this,function(a,b,c,d){function e(a,b){return 1===a.length&&Array.isArray(a[b])?a[b]:D.call(a)}function f(a,b){this.scheduler=a,this.disposable=b,this.isDisposed=!1}function g(a,b,c){for(var d=0,e=a.length;e>d;d++)if(c(a[d],b))return d;return-1}function h(a){this.comparer=a,this.set=[]}var i=c.Observable,j=i.prototype,k=i.never,l=i.throwException,m=c.AnonymousObservable,n=c.Observer,o=c.Subject,p=c.internals,q=c.helpers,r=p.ScheduledObserver,s=c.SerialDisposable,t=c.SingleAssignmentDisposable,u=c.CompositeDisposable,v=c.RefCountDisposable,w=c.Disposable.empty,x=c.Scheduler.immediate,y=(q.defaultKeySerializer,c.internals.addRef),z=(q.identity,q.isPromise),A=p.inherits,B=(q.noop,q.isScheduler),C=i.fromPromise,D=Array.prototype.slice,E="Argument out of range";f.prototype.dispose=function(){var a=this;this.scheduler.schedule(function(){a.isDisposed||(a.isDisposed=!0,a.disposable.dispose())})};var F=(function(a){function b(b){a.call(this),this._observer=b,this._state=0}A(b,a);var c=b.prototype;return c.onNext=function(a){this.checkAccess();try{this._observer.onNext(a)}catch(b){throw b}finally{this._state=0}},c.onError=function(a){this.checkAccess();try{this._observer.onError(a)}catch(b){throw b}finally{this._state=2}},c.onCompleted=function(){this.checkAccess();try{this._observer.onCompleted()}catch(a){throw a}finally{this._state=2}},c.checkAccess=function(){if(1===this._state)throw new Error("Re-entrancy detected");if(2===this._state)throw new Error("Observer completed");0===this._state&&(this._state=1)},b}(n),function(a){function b(b,c,d){a.call(this,b,c),this._cancel=d}return A(b,a),b.prototype.next=function(b){a.prototype.next.call(this,b),this.ensureActive()},b.prototype.error=function(b){a.prototype.error.call(this,b),this.ensureActive()},b.prototype.completed=function(){a.prototype.completed.call(this),this.ensureActive()},b.prototype.dispose=function(){a.prototype.dispose.call(this),this._cancel&&this._cancel.dispose(),this._cancel=null},b}(r));j.observeOn=function(a){var b=this;return new m(function(c){return b.subscribe(new F(a,c))},b)},j.subscribeOn=function(a){var b=this;return new m(function(c){var d=new t,e=new s;return e.setDisposable(d),d.setDisposable(a.schedule(function(){e.setDisposable(new f(a,b.subscribe(c)))})),e},b)},i.generate=function(a,b,c,d,e){return B(e)||(e=currentThreadScheduler),new m(function(f){var g=!0,h=a;return e.scheduleRecursive(function(a){var e,i;try{g?g=!1:h=c(h),e=b(h),e&&(i=d(h))}catch(j){return void f.onError(j)}e?(f.onNext(i),a()):f.onCompleted()})})},i.using=function(a,b){return new m(function(c){var d,e,f=w;try{d=a(),d&&(f=d),e=b(d)}catch(g){return new u(l(g).subscribe(c),f)}return new u(e.subscribe(c),f)})},j.amb=function(a){var b=this;return new m(function(c){function d(){f||(f=g,j.dispose())}function e(){f||(f=h,i.dispose())}var f,g="L",h="R",i=new t,j=new t;return z(a)&&(a=C(a)),i.setDisposable(b.subscribe(function(a){d(),f===g&&c.onNext(a)},function(a){d(),f===g&&c.onError(a)},function(){d(),f===g&&c.onCompleted()})),j.setDisposable(a.subscribe(function(a){e(),f===h&&c.onNext(a)},function(a){e(),f===h&&c.onError(a)},function(){e(),f===h&&c.onCompleted()})),new u(i,j)})},i.amb=function(){function a(a,b){return a.amb(b)}for(var b=k(),c=e(arguments,0),d=0,f=c.length;f>d;d++)b=a(b,c[d]);return b},j.onErrorResumeNext=function(a){if(!a)throw new Error("Second observable is required");return G([this,a])};var G=i.onErrorResumeNext=function(){var a=e(arguments,0);return new m(function(b){var c=0,d=new s,e=x.scheduleRecursive(function(e){var f,g;c<a.length?(f=a[c++],z(f)&&(f=C(f)),g=new t,d.setDisposable(g),g.setDisposable(f.subscribe(b.onNext.bind(b),e,e))):b.onCompleted()});return new u(d,e)})};return j.bufferWithCount=function(a,b){return"number"!=typeof b&&(b=a),this.windowWithCount(a,b).selectMany(function(a){return a.toArray()}).where(function(a){return a.length>0})},j.windowWithCount=function(a,b){var c=this;if(+a||(a=0),1/0===Math.abs(a)&&(a=0),0>=a)throw new Error(E);if(null==b&&(b=a),+b||(b=0),1/0===Math.abs(b)&&(b=0),0>=b)throw new Error(E);return new m(function(d){function e(){var a=new o;i.push(a),d.onNext(y(a,g))}var f=new t,g=new v(f),h=0,i=[];return e(),f.setDisposable(c.subscribe(function(c){for(var d=0,f=i.length;f>d;d++)i[d].onNext(c);var g=h-a+1;g>=0&&g%b===0&&i.shift().onCompleted(),++h%b===0&&e()},function(a){for(;i.length>0;)i.shift().onError(a);d.onError(a)},function(){for(;i.length>0;)i.shift().onCompleted();d.onCompleted()})),g},c)},j.takeLastBuffer=function(a){var b=this;return new m(function(c){var d=[];return b.subscribe(function(b){d.push(b),d.length>a&&d.shift()},c.onError.bind(c),function(){c.onNext(d),c.onCompleted()})},b)},j.defaultIfEmpty=function(a){var b=this;return a===d&&(a=null),new m(function(c){var d=!1;return b.subscribe(function(a){d=!0,c.onNext(a)},c.onError.bind(c),function(){!d&&c.onNext(a),c.onCompleted()})},this)},h.prototype.push=function(a){var b=-1===g(this.set,a,this.comparer);return b&&this.set.push(a),b},j.distinct=function(a,b){var c=this;return b||(b=defaultComparer),new m(function(d){var e=new h(b);return c.subscribe(function(b){var c=b;if(a)try{c=a(b)}catch(f){return void d.onError(f)}e.push(c)&&d.onNext(b)},d.onError.bind(d),d.onCompleted.bind(d))},this)},c});
2
+ (function(a){var b={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},c=b[typeof window]&&window||this,d=b[typeof exports]&&exports&&!exports.nodeType&&exports,e=b[typeof module]&&module&&!module.nodeType&&module,f=(e&&e.exports===d&&d,b[typeof global]&&global);!f||f.global!==f&&f.window!==f||(c=f),"function"==typeof define&&define.amd?define(["rx"],function(b,d){return a(c,d,b)}):"object"==typeof module&&module&&module.exports===d?module.exports=a(c,module.exports,require("./rx")):c.Rx=a(c,{},c.Rx)}).call(this,function(a,b,c,d){function e(a,b){this.scheduler=a,this.disposable=b,this.isDisposed=!1}function f(a,b){b.isDisposed||(b.isDisposed=!0,b.disposable.dispose())}function g(a,b,c){for(var d=0,e=a.length;e>d;d++)if(c(a[d],b))return d;return-1}function h(a){this.comparer=a,this.set=[]}var i=c.Observable,j=i.prototype,k=i.never,l=i.throwException,m=c.AnonymousObservable,n=c.AnonymousObserver,o=c.Notification.createOnNext,p=c.Notification.createOnError,q=c.Notification.createOnCompleted,r=c.Observer,s=c.Subject,t=c.internals,u=c.helpers,v=t.ScheduledObserver,w=c.SerialDisposable,x=c.SingleAssignmentDisposable,y=c.CompositeDisposable,z=c.RefCountDisposable,A=c.Disposable.empty,B=c.Scheduler.immediate,C=(u.defaultKeySerializer,c.internals.addRef),D=(u.identity,u.isPromise),E=t.inherits,F=t.bindCallback,G=(u.noop,u.isScheduler),H=i.fromPromise,I=(Array.prototype.slice,"Argument out of range");e.prototype.dispose=function(){this.scheduler.scheduleWithState(this,f)};var J=function(a){function b(b){a.call(this),this._observer=b,this._state=0}E(b,a);var c=b.prototype;return c.onNext=function(a){this.checkAccess();try{this._observer.onNext(a)}catch(b){throw b}finally{this._state=0}},c.onError=function(a){this.checkAccess();try{this._observer.onError(a)}catch(b){throw b}finally{this._state=2}},c.onCompleted=function(){this.checkAccess();try{this._observer.onCompleted()}catch(a){throw a}finally{this._state=2}},c.checkAccess=function(){if(1===this._state)throw new Error("Re-entrancy detected");if(2===this._state)throw new Error("Observer completed");0===this._state&&(this._state=1)},b}(r),K=function(a){function b(b,c,d){a.call(this,b,c),this._cancel=d}return E(b,a),b.prototype.next=function(b){a.prototype.next.call(this,b),this.ensureActive()},b.prototype.error=function(b){a.prototype.error.call(this,b),this.ensureActive()},b.prototype.completed=function(){a.prototype.completed.call(this),this.ensureActive()},b.prototype.dispose=function(){a.prototype.dispose.call(this),this._cancel&&this._cancel.dispose(),this._cancel=null},b}(v);r.prototype.checked=function(){return new J(this)},r.notifyOn=function(a){return new K(a,this)},r.fromNotifier=function(a,b){var c=F(a,b,1);return new n(function(a){return c(o(a))},function(a){return c(p(a))},function(){return c(q())})},r.prototype.toNotifier=function(){var a=this;return function(b){return b.accept(a)}},r.prototype.asObserver=function(){var a=this;return new n(function(b){a.onNext(b)},function(b){a.onError(b)},function(){a.onCompleted()})},j.observeOn=function(a){var b=this;return new m(function(c){return b.subscribe(new K(a,c))},b)},j.subscribeOn=function(a){var b=this;return new m(function(c){var d=new x,f=new w;return f.setDisposable(d),d.setDisposable(a.schedule(function(){f.setDisposable(new e(a,b.subscribe(c)))})),f},b)},i.generate=function(a,b,c,d,e){return G(e)||(e=currentThreadScheduler),new m(function(f){var g=!0,h=a;return e.scheduleRecursive(function(a){var e,i;try{g?g=!1:h=c(h),e=b(h),e&&(i=d(h))}catch(j){return void f.onError(j)}e?(f.onNext(i),a()):f.onCompleted()})})},i.using=function(a,b){return new m(function(c){var d,e,f=A;try{d=a(),d&&(f=d),e=b(d)}catch(g){return new y(l(g).subscribe(c),f)}return new y(e.subscribe(c),f)})},j.amb=function(a){var b=this;return new m(function(c){function d(){f||(f=g,j.dispose())}function e(){f||(f=h,i.dispose())}var f,g="L",h="R",i=new x,j=new x;return D(a)&&(a=H(a)),i.setDisposable(b.subscribe(function(a){d(),f===g&&c.onNext(a)},function(a){d(),f===g&&c.onError(a)},function(){d(),f===g&&c.onCompleted()})),j.setDisposable(a.subscribe(function(a){e(),f===h&&c.onNext(a)},function(a){e(),f===h&&c.onError(a)},function(){e(),f===h&&c.onCompleted()})),new y(i,j)})},i.amb=function(){function a(a,b){return a.amb(b)}var b=k(),c=[];if(Array.isArray(arguments[0]))c=arguments[0];else for(var d=0,e=arguments.length;e>d;d++)c.push(arguments[d]);for(var d=0,e=c.length;e>d;d++)b=a(b,c[d]);return b},j.onErrorResumeNext=function(a){if(!a)throw new Error("Second observable is required");return L([this,a])};var L=i.onErrorResumeNext=function(){var a=[];if(Array.isArray(arguments[0]))a=arguments[0];else for(var b=0,c=arguments.length;c>b;b++)a.push(arguments[b]);return new m(function(b){var c=0,d=new w,e=B.scheduleRecursive(function(e){var f,g;c<a.length?(f=a[c++],D(f)&&(f=H(f)),g=new x,d.setDisposable(g),g.setDisposable(f.subscribe(b.onNext.bind(b),e,e))):b.onCompleted()});return new y(d,e)})};return j.bufferWithCount=function(a,b){return"number"!=typeof b&&(b=a),this.windowWithCount(a,b).selectMany(function(a){return a.toArray()}).where(function(a){return a.length>0})},j.windowWithCount=function(a,b){var c=this;if(+a||(a=0),1/0===Math.abs(a)&&(a=0),0>=a)throw new Error(I);if(null==b&&(b=a),+b||(b=0),1/0===Math.abs(b)&&(b=0),0>=b)throw new Error(I);return new m(function(d){function e(){var a=new s;i.push(a),d.onNext(C(a,g))}var f=new x,g=new z(f),h=0,i=[];return e(),f.setDisposable(c.subscribe(function(c){for(var d=0,f=i.length;f>d;d++)i[d].onNext(c);var g=h-a+1;g>=0&&g%b===0&&i.shift().onCompleted(),++h%b===0&&e()},function(a){for(;i.length>0;)i.shift().onError(a);d.onError(a)},function(){for(;i.length>0;)i.shift().onCompleted();d.onCompleted()})),g},c)},j.takeLastBuffer=function(a){var b=this;return new m(function(c){var d=[];return b.subscribe(function(b){d.push(b),d.length>a&&d.shift()},function(a){c.onError(a)},function(){c.onNext(d),c.onCompleted()})},b)},j.defaultIfEmpty=function(a){var b=this;return a===d&&(a=null),new m(function(c){var d=!1;return b.subscribe(function(a){d=!0,c.onNext(a)},function(a){c.onError(a)},function(){!d&&c.onNext(a),c.onCompleted()})},b)},h.prototype.push=function(a){var b=-1===g(this.set,a,this.comparer);return b&&this.set.push(a),b},j.distinct=function(a,b){var c=this;return b||(b=defaultComparer),new m(function(d){var e=new h(b);return c.subscribe(function(b){var c=b;if(a)try{c=a(b)}catch(f){return void d.onError(f)}e.push(c)&&d.onNext(b)},function(a){d.onError(a)},function(){d.onCompleted()})},this)},c});
3
3
  //# sourceMappingURL=rx.lite.extras.map
@@ -24,7 +24,7 @@
24
24
  var Rx = {
25
25
  internals: {},
26
26
  config: {
27
- Promise: root.Promise,
27
+ Promise: root.Promise
28
28
  },
29
29
  helpers: { }
30
30
  };
@@ -64,7 +64,8 @@
64
64
  var sequenceContainsNoElements = 'Sequence contains no elements.';
65
65
  var argumentOutOfRange = 'Argument out of range';
66
66
  var objectDisposed = 'Object has been disposed';
67
- function checkDisposed() { if (this.isDisposed) { throw new Error(objectDisposed); } }
67
+ function checkDisposed(self) { if (self.isDisposed) { throw new Error(objectDisposed); } }
68
+ function cloneArray(arr) { for(var a = [], i = 0, len = arr.length; i < len; i++) { a.push(arr[i]); } return a;}
68
69
 
69
70
  Rx.config.longStackSupport = false;
70
71
  var hasStacks = false;
@@ -182,11 +183,41 @@
182
183
 
183
184
  Rx.helpers.iterator = $iterator$;
184
185
 
185
- var deprecate = Rx.helpers.deprecate = function (name, alternative) {
186
- /*if (typeof console !== "undefined" && typeof console.warn === "function") {
187
- console.warn(name + ' is deprecated, use ' + alternative + ' instead.', new Error('').stack);
188
- }*/
189
- }
186
+ var bindCallback = Rx.internals.bindCallback = function (func, thisArg, argCount) {
187
+ if (typeof thisArg === 'undefined') { return func; }
188
+ switch(argCount) {
189
+ case 0:
190
+ return function() {
191
+ return func.call(thisArg)
192
+ };
193
+ case 1:
194
+ return function(arg) {
195
+ return func.call(thisArg, arg);
196
+ }
197
+ case 2:
198
+ return function(value, index) {
199
+ return func.call(thisArg, value, index);
200
+ };
201
+ case 3:
202
+ return function(value, index, collection) {
203
+ return func.call(thisArg, value, index, collection);
204
+ };
205
+ }
206
+
207
+ return function() {
208
+ return func.apply(thisArg, arguments);
209
+ };
210
+ };
211
+
212
+ /** Used to determine if values are of the language type Object */
213
+ var dontEnums = ['toString',
214
+ 'toLocaleString',
215
+ 'valueOf',
216
+ 'hasOwnProperty',
217
+ 'isPrototypeOf',
218
+ 'propertyIsEnumerable',
219
+ 'constructor'],
220
+ dontEnumsLength = dontEnums.length;
190
221
 
191
222
  /** `Object#toString` result shortcuts */
192
223
  var argsClass = '[object Arguments]',
@@ -209,24 +240,12 @@
209
240
  stringProto = String.prototype,
210
241
  propertyIsEnumerable = objectProto.propertyIsEnumerable;
211
242
 
212
- // Fix for Tessel
213
- if (!propertyIsEnumerable) {
214
- propertyIsEnumerable = objectProto.propertyIsEnumerable = function (key) {
215
- for (var k in this) { if (k === key) { return true; } }
216
- return false;
217
- };
218
- }
219
-
220
243
  try {
221
244
  supportNodeClass = !(toString.call(document) == objectClass && !({ 'toString': 0 } + ''));
222
245
  } catch (e) {
223
246
  supportNodeClass = true;
224
247
  }
225
248
 
226
- var shadowedProps = [
227
- 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf'
228
- ];
229
-
230
249
  var nonEnumProps = {};
231
250
  nonEnumProps[arrayClass] = nonEnumProps[dateClass] = nonEnumProps[numberClass] = { 'constructor': true, 'toLocaleString': true, 'toString': true, 'valueOf': true };
232
251
  nonEnumProps[boolClass] = nonEnumProps[stringClass] = { 'constructor': true, 'toString': true, 'valueOf': true };
@@ -255,14 +274,10 @@
255
274
  support.nonEnumShadows = !/valueOf/.test(props);
256
275
  }(1));
257
276
 
258
- function isObject(value) {
259
- // check if the value is the ECMAScript language type of Object
260
- // http://es5.github.io/#x8
261
- // and avoid a V8 bug
262
- // https://code.google.com/p/v8/issues/detail?id=2291
277
+ var isObject = Rx.internals.isObject = function(value) {
263
278
  var type = typeof value;
264
279
  return value && (type == 'function' || type == 'object') || false;
265
- }
280
+ };
266
281
 
267
282
  function keysIn(object) {
268
283
  var result = [];
@@ -285,14 +300,14 @@
285
300
  if (support.nonEnumShadows && object !== objectProto) {
286
301
  var ctor = object.constructor,
287
302
  index = -1,
288
- length = shadowedProps.length;
303
+ length = dontEnumsLength;
289
304
 
290
305
  if (object === (ctor && ctor.prototype)) {
291
306
  var className = object === stringProto ? stringClass : object === errorProto ? errorClass : toString.call(object),
292
307
  nonEnum = nonEnumProps[className];
293
308
  }
294
309
  while (++index < length) {
295
- key = shadowedProps[index];
310
+ key = dontEnums[index];
296
311
  if (!(nonEnum && nonEnum[key]) && hasOwnProperty.call(object, key)) {
297
312
  result.push(key);
298
313
  }
@@ -479,13 +494,27 @@
479
494
  return result;
480
495
  }
481
496
 
482
- var slice = Array.prototype.slice;
483
- function argsOrArray(args, idx) {
484
- return args.length === 1 && Array.isArray(args[idx]) ?
485
- args[idx] :
486
- slice.call(args);
497
+ var errorObj = {e: {}};
498
+ var tryCatchTarget;
499
+ function tryCatcher() {
500
+ try {
501
+ return tryCatchTarget.apply(this, arguments);
502
+ } catch (e) {
503
+ errorObj.e = e;
504
+ return errorObj;
505
+ }
506
+ }
507
+ function tryCatch(fn) {
508
+ if (!isFunction(fn)) { throw new TypeError('fn must be a function'); }
509
+ tryCatchTarget = fn;
510
+ return tryCatcher;
511
+ }
512
+ function thrower(e) {
513
+ throw e;
487
514
  }
488
- var hasProp = {}.hasOwnProperty;
515
+
516
+ var hasProp = {}.hasOwnProperty,
517
+ slice = Array.prototype.slice;
489
518
 
490
519
  var inherits = this.inherits = Rx.internals.inherits = function (child, parent) {
491
520
  function __() { this.constructor = child; }
@@ -494,9 +523,9 @@
494
523
  };
495
524
 
496
525
  var addProperties = Rx.internals.addProperties = function (obj) {
497
- var sources = slice.call(arguments, 1);
498
- for (var i = 0, len = sources.length; i < len; i++) {
499
- var source = sources[i];
526
+ for(var sources = [], i = 1, len = arguments.length; i < len; i++) { sources.push(arguments[i]); }
527
+ for (var idx = 0, ln = sources.length; idx < ln; idx++) {
528
+ var source = sources[idx];
500
529
  for (var prop in source) {
501
530
  obj[prop] = source[prop];
502
531
  }
@@ -577,7 +606,7 @@
577
606
 
578
607
  priorityProto.removeAt = function (index) {
579
608
  this.items[index] = this.items[--this.length];
580
- delete this.items[this.length];
609
+ this.items[this.length] = undefined;
581
610
  this.heapify();
582
611
  };
583
612
 
@@ -609,9 +638,17 @@
609
638
  * @constructor
610
639
  */
611
640
  var CompositeDisposable = Rx.CompositeDisposable = function () {
612
- this.disposables = argsOrArray(arguments, 0);
641
+ var args = [];
642
+ if (Array.isArray(arguments[0])) {
643
+ args = arguments[0];
644
+ } else {
645
+ var len = arguments.length;
646
+ args = new Array(len);
647
+ for(var i = 0; i < len; i++) { args[i] = arguments[i]; }
648
+ }
649
+ this.disposables = args;
613
650
  this.isDisposed = false;
614
- this.length = this.disposables.length;
651
+ this.length = args.length;
615
652
  };
616
653
 
617
654
  var CompositeDisposablePrototype = CompositeDisposable.prototype;
@@ -654,28 +691,19 @@
654
691
  CompositeDisposablePrototype.dispose = function () {
655
692
  if (!this.isDisposed) {
656
693
  this.isDisposed = true;
657
- var currentDisposables = this.disposables.slice(0);
694
+ var len = this.disposables.length, currentDisposables = new Array(len);
695
+ for(var i = 0; i < len; i++) { currentDisposables[i] = this.disposables[i]; }
658
696
  this.disposables = [];
659
697
  this.length = 0;
660
698
 
661
- for (var i = 0, len = currentDisposables.length; i < len; i++) {
699
+ for (i = 0; i < len; i++) {
662
700
  currentDisposables[i].dispose();
663
701
  }
664
702
  }
665
703
  };
666
704
 
667
- /**
668
- * Converts the existing CompositeDisposable to an array of disposables
669
- * @returns {Array} An array of disposable objects.
670
- */
671
- CompositeDisposablePrototype.toArray = function () {
672
- return this.disposables.slice(0);
673
- };
674
-
675
705
  /**
676
706
  * Provides a set of static methods for creating Disposables.
677
- *
678
- * @constructor
679
707
  * @param {Function} dispose Action to run during the first call to dispose. The action is guaranteed to be run at most once.
680
708
  */
681
709
  var Disposable = Rx.Disposable = function (action) {
@@ -724,9 +752,9 @@
724
752
  * @param {Disposable} value The new underlying disposable.
725
753
  */
726
754
  booleanDisposablePrototype.setDisposable = function (value) {
727
- var shouldDispose = this.isDisposed, old;
755
+ var shouldDispose = this.isDisposed;
728
756
  if (!shouldDispose) {
729
- old = this.current;
757
+ var old = this.current;
730
758
  this.current = value;
731
759
  }
732
760
  old && old.dispose();
@@ -737,10 +765,9 @@
737
765
  * Disposes the underlying disposable as well as all future replacements.
738
766
  */
739
767
  booleanDisposablePrototype.dispose = function () {
740
- var old;
741
768
  if (!this.isDisposed) {
742
769
  this.isDisposed = true;
743
- old = this.current;
770
+ var old = this.current;
744
771
  this.current = null;
745
772
  }
746
773
  old && old.dispose();
@@ -750,67 +777,63 @@
750
777
  }());
751
778
  var SerialDisposable = Rx.SerialDisposable = SingleAssignmentDisposable;
752
779
 
753
- /**
754
- * Represents a disposable resource that only disposes its underlying disposable resource when all dependent disposable objects have been disposed.
755
- */
756
- var RefCountDisposable = Rx.RefCountDisposable = (function () {
780
+ /**
781
+ * Represents a disposable resource that only disposes its underlying disposable resource when all dependent disposable objects have been disposed.
782
+ */
783
+ var RefCountDisposable = Rx.RefCountDisposable = (function () {
784
+
785
+ function InnerDisposable(disposable) {
786
+ this.disposable = disposable;
787
+ this.disposable.count++;
788
+ this.isInnerDisposed = false;
789
+ }
757
790
 
758
- function InnerDisposable(disposable) {
759
- this.disposable = disposable;
760
- this.disposable.count++;
761
- this.isInnerDisposed = false;
791
+ InnerDisposable.prototype.dispose = function () {
792
+ if (!this.disposable.isDisposed && !this.isInnerDisposed) {
793
+ this.isInnerDisposed = true;
794
+ this.disposable.count--;
795
+ if (this.disposable.count === 0 && this.disposable.isPrimaryDisposed) {
796
+ this.disposable.isDisposed = true;
797
+ this.disposable.underlyingDisposable.dispose();
762
798
  }
799
+ }
800
+ };
763
801
 
764
- InnerDisposable.prototype.dispose = function () {
765
- if (!this.disposable.isDisposed) {
766
- if (!this.isInnerDisposed) {
767
- this.isInnerDisposed = true;
768
- this.disposable.count--;
769
- if (this.disposable.count === 0 && this.disposable.isPrimaryDisposed) {
770
- this.disposable.isDisposed = true;
771
- this.disposable.underlyingDisposable.dispose();
772
- }
773
- }
774
- }
775
- };
802
+ /**
803
+ * Initializes a new instance of the RefCountDisposable with the specified disposable.
804
+ * @constructor
805
+ * @param {Disposable} disposable Underlying disposable.
806
+ */
807
+ function RefCountDisposable(disposable) {
808
+ this.underlyingDisposable = disposable;
809
+ this.isDisposed = false;
810
+ this.isPrimaryDisposed = false;
811
+ this.count = 0;
812
+ }
776
813
 
777
- /**
778
- * Initializes a new instance of the RefCountDisposable with the specified disposable.
779
- * @constructor
780
- * @param {Disposable} disposable Underlying disposable.
781
- */
782
- function RefCountDisposable(disposable) {
783
- this.underlyingDisposable = disposable;
784
- this.isDisposed = false;
785
- this.isPrimaryDisposed = false;
786
- this.count = 0;
814
+ /**
815
+ * Disposes the underlying disposable only when all dependent disposables have been disposed
816
+ */
817
+ RefCountDisposable.prototype.dispose = function () {
818
+ if (!this.isDisposed && !this.isPrimaryDisposed) {
819
+ this.isPrimaryDisposed = true;
820
+ if (this.count === 0) {
821
+ this.isDisposed = true;
822
+ this.underlyingDisposable.dispose();
787
823
  }
824
+ }
825
+ };
788
826
 
789
- /**
790
- * Disposes the underlying disposable only when all dependent disposables have been disposed
791
- */
792
- RefCountDisposable.prototype.dispose = function () {
793
- if (!this.isDisposed) {
794
- if (!this.isPrimaryDisposed) {
795
- this.isPrimaryDisposed = true;
796
- if (this.count === 0) {
797
- this.isDisposed = true;
798
- this.underlyingDisposable.dispose();
799
- }
800
- }
801
- }
802
- };
803
-
804
- /**
805
- * Returns a dependent disposable that when disposed decreases the refcount on the underlying disposable.
806
- * @returns {Disposable} A dependent disposable contributing to the reference count that manages the underlying disposable's lifetime.
807
- */
808
- RefCountDisposable.prototype.getDisposable = function () {
809
- return this.isDisposed ? disposableEmpty : new InnerDisposable(this);
810
- };
827
+ /**
828
+ * Returns a dependent disposable that when disposed decreases the refcount on the underlying disposable.
829
+ * @returns {Disposable} A dependent disposable contributing to the reference count that manages the underlying disposable's lifetime.
830
+ */
831
+ RefCountDisposable.prototype.getDisposable = function () {
832
+ return this.isDisposed ? disposableEmpty : new InnerDisposable(this);
833
+ };
811
834
 
812
- return RefCountDisposable;
813
- })();
835
+ return RefCountDisposable;
836
+ })();
814
837
 
815
838
  var ScheduledItem = Rx.internals.ScheduledItem = function (scheduler, state, action, dueTime, comparer) {
816
839
  this.scheduler = scheduler;
@@ -963,7 +986,7 @@
963
986
  recursiveAction = function (state1) {
964
987
  action(state1, function (state2, dueTime1) {
965
988
  var isAdded = false, isDone = false,
966
- d = scheduler[method].call(scheduler, state2, dueTime1, function (scheduler1, state3) {
989
+ d = scheduler[method](state2, dueTime1, function (scheduler1, state3) {
967
990
  if (isAdded) {
968
991
  group.remove(d);
969
992
  } else {
@@ -1091,18 +1114,9 @@
1091
1114
  var immediateScheduler = Scheduler.immediate = (function () {
1092
1115
 
1093
1116
  function scheduleNow(state, action) { return action(this, state); }
1117
+ function notSupported() { throw new Error('Not supported'); }
1094
1118
 
1095
- function scheduleRelative(state, dueTime, action) {
1096
- var dt = normalizeTime(dueTime);
1097
- while (dt - this.now() > 0) { }
1098
- return action(this, state);
1099
- }
1100
-
1101
- function scheduleAbsolute(state, dueTime, action) {
1102
- return this.scheduleWithRelativeAndState(state, dueTime - this.now(), action);
1103
- }
1104
-
1105
- return new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);
1119
+ return new Scheduler(defaultNow, scheduleNow, notSupported, notSupported);
1106
1120
  }());
1107
1121
 
1108
1122
  /**
@@ -1112,27 +1126,16 @@
1112
1126
  var queue;
1113
1127
 
1114
1128
  function runTrampoline (q) {
1115
- var item;
1116
1129
  while (q.length > 0) {
1117
- item = q.dequeue();
1130
+ var item = q.dequeue();
1118
1131
  if (!item.isCancelled()) {
1119
- // Note, do not schedule blocking work!
1120
- while (item.dueTime - Scheduler.now() > 0) {
1121
- }
1122
- if (!item.isCancelled()) {
1123
- item.invoke();
1124
- }
1132
+ !item.isCancelled() && item.invoke();
1125
1133
  }
1126
1134
  }
1127
1135
  }
1128
1136
 
1129
1137
  function scheduleNow(state, action) {
1130
- return this.scheduleWithRelativeAndState(state, 0, action);
1131
- }
1132
-
1133
- function scheduleRelative(state, dueTime, action) {
1134
- var dt = this.now() + Scheduler.normalize(dueTime),
1135
- si = new ScheduledItem(this, state, action, dt);
1138
+ var si = new ScheduledItem(this, state, action, this.now());
1136
1139
 
1137
1140
  if (!queue) {
1138
1141
  queue = new PriorityQueue(4);
@@ -1150,11 +1153,9 @@
1150
1153
  return si.disposable;
1151
1154
  }
1152
1155
 
1153
- function scheduleAbsolute(state, dueTime, action) {
1154
- return this.scheduleWithRelativeAndState(state, dueTime - this.now(), action);
1155
- }
1156
+ function notSupported() { throw new Error('Not supported'); }
1156
1157
 
1157
- var currentScheduler = new Scheduler(defaultNow, scheduleNow, scheduleRelative, scheduleAbsolute);
1158
+ var currentScheduler = new Scheduler(defaultNow, scheduleNow, notSupported, notSupported);
1158
1159
 
1159
1160
  currentScheduler.scheduleRequired = function () { return !queue; };
1160
1161
  currentScheduler.ensureTrampoline = function (action) {
@@ -1478,31 +1479,20 @@
1478
1479
 
1479
1480
  Enumerable.prototype.concat = function () {
1480
1481
  var sources = this;
1481
- return new AnonymousObservable(function (observer) {
1482
- var e;
1483
- try {
1484
- e = sources[$iterator$]();
1485
- } catch (err) {
1486
- observer.onError(err);
1487
- return;
1488
- }
1482
+ return new AnonymousObservable(function (o) {
1483
+ var e = sources[$iterator$]();
1489
1484
 
1490
- var isDisposed,
1491
- subscription = new SerialDisposable();
1485
+ var isDisposed, subscription = new SerialDisposable();
1492
1486
  var cancelable = immediateScheduler.scheduleRecursive(function (self) {
1493
- var currentItem;
1494
1487
  if (isDisposed) { return; }
1495
-
1496
1488
  try {
1497
- currentItem = e.next();
1489
+ var currentItem = e.next();
1498
1490
  } catch (ex) {
1499
- observer.onError(ex);
1500
- return;
1491
+ return o.onError(ex);
1501
1492
  }
1502
1493
 
1503
1494
  if (currentItem.done) {
1504
- observer.onCompleted();
1505
- return;
1495
+ return o.onCompleted();
1506
1496
  }
1507
1497
 
1508
1498
  // Check if promise
@@ -1512,9 +1502,9 @@
1512
1502
  var d = new SingleAssignmentDisposable();
1513
1503
  subscription.setDisposable(d);
1514
1504
  d.setDisposable(currentValue.subscribe(
1515
- observer.onNext.bind(observer),
1516
- observer.onError.bind(observer),
1517
- function () { self(); })
1505
+ function(x) { o.onNext(x); },
1506
+ function(err) { o.onError(err); },
1507
+ self)
1518
1508
  );
1519
1509
  });
1520
1510
 
@@ -1526,14 +1516,55 @@
1526
1516
 
1527
1517
  Enumerable.prototype.catchError = function () {
1528
1518
  var sources = this;
1529
- return new AnonymousObservable(function (observer) {
1530
- var e;
1531
- try {
1532
- e = sources[$iterator$]();
1533
- } catch (err) {
1534
- observer.onError(err);
1535
- return;
1536
- }
1519
+ return new AnonymousObservable(function (o) {
1520
+ var e = sources[$iterator$]();
1521
+
1522
+ var isDisposed, subscription = new SerialDisposable();
1523
+ var cancelable = immediateScheduler.scheduleRecursiveWithState(null, function (lastException, self) {
1524
+ if (isDisposed) { return; }
1525
+
1526
+ try {
1527
+ var currentItem = e.next();
1528
+ } catch (ex) {
1529
+ return observer.onError(ex);
1530
+ }
1531
+
1532
+ if (currentItem.done) {
1533
+ if (lastException !== null) {
1534
+ o.onError(lastException);
1535
+ } else {
1536
+ o.onCompleted();
1537
+ }
1538
+ return;
1539
+ }
1540
+
1541
+ // Check if promise
1542
+ var currentValue = currentItem.value;
1543
+ isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));
1544
+
1545
+ var d = new SingleAssignmentDisposable();
1546
+ subscription.setDisposable(d);
1547
+ d.setDisposable(currentValue.subscribe(
1548
+ function(x) { o.onNext(x); },
1549
+ self,
1550
+ function() { o.onCompleted(); }));
1551
+ });
1552
+ return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
1553
+ isDisposed = true;
1554
+ }));
1555
+ });
1556
+ };
1557
+
1558
+
1559
+ Enumerable.prototype.catchErrorWhen = function (notificationHandler) {
1560
+ var sources = this;
1561
+ return new AnonymousObservable(function (o) {
1562
+ var exceptions = new Subject(),
1563
+ notifier = new Subject(),
1564
+ handled = notificationHandler(exceptions),
1565
+ notificationDisposable = handled.subscribe(notifier);
1566
+
1567
+ var e = sources[$iterator$]();
1537
1568
 
1538
1569
  var isDisposed,
1539
1570
  lastException,
@@ -1541,19 +1572,17 @@
1541
1572
  var cancelable = immediateScheduler.scheduleRecursive(function (self) {
1542
1573
  if (isDisposed) { return; }
1543
1574
 
1544
- var currentItem;
1545
1575
  try {
1546
- currentItem = e.next();
1576
+ var currentItem = e.next();
1547
1577
  } catch (ex) {
1548
- observer.onError(ex);
1549
- return;
1578
+ return o.onError(ex);
1550
1579
  }
1551
1580
 
1552
1581
  if (currentItem.done) {
1553
1582
  if (lastException) {
1554
- observer.onError(lastException);
1583
+ o.onError(lastException);
1555
1584
  } else {
1556
- observer.onCompleted();
1585
+ o.onCompleted();
1557
1586
  }
1558
1587
  return;
1559
1588
  }
@@ -1562,17 +1591,24 @@
1562
1591
  var currentValue = currentItem.value;
1563
1592
  isPromise(currentValue) && (currentValue = observableFromPromise(currentValue));
1564
1593
 
1565
- var d = new SingleAssignmentDisposable();
1566
- subscription.setDisposable(d);
1567
- d.setDisposable(currentValue.subscribe(
1568
- observer.onNext.bind(observer),
1594
+ var outer = new SingleAssignmentDisposable();
1595
+ var inner = new SingleAssignmentDisposable();
1596
+ subscription.setDisposable(new CompositeDisposable(inner, outer));
1597
+ outer.setDisposable(currentValue.subscribe(
1598
+ function(x) { o.onNext(x); },
1569
1599
  function (exn) {
1570
- lastException = exn;
1571
- self();
1600
+ inner.setDisposable(notifier.subscribe(self, function(ex) {
1601
+ o.onError(ex);
1602
+ }, function() {
1603
+ o.onCompleted();
1604
+ }));
1605
+
1606
+ exceptions.onNext(exn);
1572
1607
  },
1573
- observer.onCompleted.bind(observer)));
1608
+ function() { o.onCompleted(); }));
1574
1609
  });
1575
- return new CompositeDisposable(subscription, cancelable, disposableCreate(function () {
1610
+
1611
+ return new CompositeDisposable(notificationDisposable, subscription, cancelable, disposableCreate(function () {
1576
1612
  isDisposed = true;
1577
1613
  }));
1578
1614
  });
@@ -1591,13 +1627,15 @@
1591
1627
  };
1592
1628
 
1593
1629
  var enumerableOf = Enumerable.of = function (source, selector, thisArg) {
1594
- selector || (selector = identity);
1630
+ if (selector) {
1631
+ var selectorFn = bindCallback(selector, thisArg, 3);
1632
+ }
1595
1633
  return new Enumerable(function () {
1596
1634
  var index = -1;
1597
1635
  return new Enumerator(
1598
1636
  function () {
1599
1637
  return ++index < source.length ?
1600
- { done: false, value: selector.call(thisArg, source[index], index, source) } :
1638
+ { done: false, value: !selector ? source[index] : selectorFn(source[index], index, source) } :
1601
1639
  doneEnumerator;
1602
1640
  });
1603
1641
  });
@@ -1608,23 +1646,6 @@
1608
1646
  */
1609
1647
  var Observer = Rx.Observer = function () { };
1610
1648
 
1611
- /**
1612
- * Creates a notification callback from an observer.
1613
- * @returns The action that forwards its input notification to the underlying observer.
1614
- */
1615
- Observer.prototype.toNotifier = function () {
1616
- var observer = this;
1617
- return function (n) { return n.accept(observer); };
1618
- };
1619
-
1620
- /**
1621
- * Hides the identity of an observer.
1622
- * @returns An observer that hides the identity of the specified observer.
1623
- */
1624
- Observer.prototype.asObserver = function () {
1625
- return new AnonymousObserver(this.onNext.bind(this), this.onError.bind(this), this.onCompleted.bind(this));
1626
- };
1627
-
1628
1649
  /**
1629
1650
  * Creates an observer from the specified OnNext, along with optional OnError, and OnCompleted actions.
1630
1651
  * @param {Function} [onNext] Observer's OnNext action implementation.
@@ -1639,21 +1660,6 @@
1639
1660
  return new AnonymousObserver(onNext, onError, onCompleted);
1640
1661
  };
1641
1662
 
1642
- /**
1643
- * Creates an observer from a notification callback.
1644
- * @param {Function} handler Action that handles a notification.
1645
- * @returns The observer object that invokes the specified handler using a notification corresponding to each message it receives.
1646
- */
1647
- Observer.fromNotifier = function (handler, thisArg) {
1648
- return new AnonymousObserver(function (x) {
1649
- return handler.call(thisArg, notificationCreateOnNext(x));
1650
- }, function (e) {
1651
- return handler.call(thisArg, notificationCreateOnError(e));
1652
- }, function () {
1653
- return handler.call(thisArg, notificationCreateOnCompleted());
1654
- });
1655
- };
1656
-
1657
1663
  /**
1658
1664
  * Abstract base class for implementations of the Observer class.
1659
1665
  * This base class enforces the grammar of observers where OnError and OnCompleted are terminal messages.
@@ -1669,6 +1675,15 @@
1669
1675
  __super__.call(this);
1670
1676
  }
1671
1677
 
1678
+ function notImplemented() {
1679
+ throw new Error('Method not implemented');
1680
+ }
1681
+
1682
+ // Must be implemented by other observers
1683
+ AbstractObserver.prototype.next = notImplemented;
1684
+ AbstractObserver.prototype.error = notImplemented;
1685
+ AbstractObserver.prototype.completed = notImplemented;
1686
+
1672
1687
  /**
1673
1688
  * Notifies the observer of a new element in the sequence.
1674
1689
  * @param {Any} value Next element in the sequence.
@@ -1787,7 +1802,7 @@
1787
1802
  oldOnError(err);
1788
1803
  };
1789
1804
 
1790
- return subscribe(observer);
1805
+ return subscribe.call(self, observer);
1791
1806
  };
1792
1807
  } else {
1793
1808
  this._subscribe = subscribe;
@@ -1816,7 +1831,7 @@
1816
1831
  * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.
1817
1832
  */
1818
1833
  observableProto.subscribeOnNext = function (onNext, thisArg) {
1819
- return this._subscribe(observerCreate(arguments.length === 2 ? function(x) { onNext.call(thisArg, x); } : onNext));
1834
+ return this._subscribe(observerCreate(typeof thisArg !== 'undefined' ? function(x) { onNext.call(thisArg, x); } : onNext));
1820
1835
  };
1821
1836
 
1822
1837
  /**
@@ -1826,7 +1841,7 @@
1826
1841
  * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.
1827
1842
  */
1828
1843
  observableProto.subscribeOnError = function (onError, thisArg) {
1829
- return this._subscribe(observerCreate(null, arguments.length === 2 ? function(e) { onError.call(thisArg, e); } : onError));
1844
+ return this._subscribe(observerCreate(null, typeof thisArg !== 'undefined' ? function(e) { onError.call(thisArg, e); } : onError));
1830
1845
  };
1831
1846
 
1832
1847
  /**
@@ -1836,7 +1851,7 @@
1836
1851
  * @returns {Disposable} A disposable handling the subscriptions and unsubscriptions.
1837
1852
  */
1838
1853
  observableProto.subscribeOnCompleted = function (onCompleted, thisArg) {
1839
- return this._subscribe(observerCreate(null, null, arguments.length === 2 ? function() { onCompleted.call(thisArg); } : onCompleted));
1854
+ return this._subscribe(observerCreate(null, null, typeof thisArg !== 'undefined' ? function() { onCompleted.call(thisArg); } : onCompleted));
1840
1855
  };
1841
1856
 
1842
1857
  return Observable;
@@ -1905,22 +1920,102 @@
1905
1920
  return ScheduledObserver;
1906
1921
  }(AbstractObserver));
1907
1922
 
1923
+ var ObservableBase = Rx.ObservableBase = (function (__super__) {
1924
+
1925
+ inherits(ObservableBase, __super__);
1926
+
1927
+ // Fix subscriber to check for undefined or function returned to decorate as Disposable
1928
+ function fixSubscriber(subscriber) {
1929
+ if (subscriber && typeof subscriber.dispose === 'function') { return subscriber; }
1930
+
1931
+ return typeof subscriber === 'function' ?
1932
+ disposableCreate(subscriber) :
1933
+ disposableEmpty;
1934
+ }
1935
+
1936
+ function setDisposable(s, state) {
1937
+ var ado = state[0], self = state[1];
1938
+ try {
1939
+ ado.setDisposable(fixSubscriber(self.subscribeCore(ado)));
1940
+ } catch (e) {
1941
+ if (!ado.fail(e)) { throw e; }
1942
+ }
1943
+ }
1944
+
1945
+ function subscribe(observer) {
1946
+ var ado = new AutoDetachObserver(observer), state = [ado, this];
1947
+
1948
+ if (currentThreadScheduler.scheduleRequired()) {
1949
+ currentThreadScheduler.scheduleWithState(state, setDisposable);
1950
+ } else {
1951
+ setDisposable(null, state);
1952
+ }
1953
+
1954
+ return ado;
1955
+ }
1956
+
1957
+ function ObservableBase() {
1958
+ __super__.call(this, subscribe);
1959
+ }
1960
+
1961
+ ObservableBase.prototype.subscribeCore = function(observer) {
1962
+ throw new Error('Not implemeneted');
1963
+ }
1964
+
1965
+ return ObservableBase;
1966
+
1967
+ }(Observable));
1968
+
1969
+ var ToArrayObservable = (function(__super__) {
1970
+ inherits(ToArrayObservable, __super__);
1971
+ function ToArrayObservable(source) {
1972
+ this.source = source;
1973
+ __super__.call(this);
1974
+ }
1975
+
1976
+ ToArrayObservable.prototype.subscribeCore = function(observer) {
1977
+ return this.source.subscribe(new ToArrayObserver(observer));
1978
+ };
1979
+
1980
+ return ToArrayObservable;
1981
+ }(ObservableBase));
1982
+
1983
+ function ToArrayObserver(observer) {
1984
+ this.observer = observer;
1985
+ this.a = [];
1986
+ this.isStopped = false;
1987
+ }
1988
+ ToArrayObserver.prototype.onNext = function (x) { if(!this.isStopped) { this.a.push(x); } };
1989
+ ToArrayObserver.prototype.onError = function (e) {
1990
+ if (!this.isStopped) {
1991
+ this.isStopped = true;
1992
+ this.observer.onError(e);
1993
+ }
1994
+ };
1995
+ ToArrayObserver.prototype.onCompleted = function () {
1996
+ if (!this.isStopped) {
1997
+ this.isStopped = true;
1998
+ this.observer.onNext(this.a);
1999
+ this.observer.onCompleted();
2000
+ }
2001
+ };
2002
+ ToArrayObserver.prototype.dispose = function () { this.isStopped = true; }
2003
+ ToArrayObserver.prototype.fail = function (e) {
2004
+ if (!this.isStopped) {
2005
+ this.isStopped = true;
2006
+ this.observer.onError(e);
2007
+ return true;
2008
+ }
2009
+
2010
+ return false;
2011
+ };
2012
+
1908
2013
  /**
1909
- * Creates an array from an observable sequence.
1910
- * @returns {Observable} An observable sequence containing a single element with a list containing all the elements of the source sequence.
1911
- */
2014
+ * Creates an array from an observable sequence.
2015
+ * @returns {Observable} An observable sequence containing a single element with a list containing all the elements of the source sequence.
2016
+ */
1912
2017
  observableProto.toArray = function () {
1913
- var source = this;
1914
- return new AnonymousObservable(function(observer) {
1915
- var arr = [];
1916
- return source.subscribe(
1917
- arr.push.bind(arr),
1918
- observer.onError.bind(observer),
1919
- function () {
1920
- observer.onNext(arr);
1921
- observer.onCompleted();
1922
- });
1923
- }, source);
2018
+ return new ToArrayObservable(this);
1924
2019
  };
1925
2020
 
1926
2021
  /**
@@ -1975,6 +2070,65 @@
1975
2070
  });
1976
2071
  };
1977
2072
 
2073
+ var FromObservable = (function(__super__) {
2074
+ inherits(FromObservable, __super__);
2075
+ function FromObservable(iterable, mapper, scheduler) {
2076
+ this.iterable = iterable;
2077
+ this.mapper = mapper;
2078
+ this.scheduler = scheduler;
2079
+ __super__.call(this);
2080
+ }
2081
+
2082
+ FromObservable.prototype.subscribeCore = function (observer) {
2083
+ var sink = new FromSink(observer, this);
2084
+ return sink.run();
2085
+ };
2086
+
2087
+ return FromObservable;
2088
+ }(ObservableBase));
2089
+
2090
+ var FromSink = (function () {
2091
+ function FromSink(observer, parent) {
2092
+ this.observer = observer;
2093
+ this.parent = parent;
2094
+ }
2095
+
2096
+ FromSink.prototype.run = function () {
2097
+ var list = Object(this.parent.iterable),
2098
+ it = getIterable(list),
2099
+ observer = this.observer,
2100
+ mapper = this.parent.mapper;
2101
+
2102
+ function loopRecursive(i, recurse) {
2103
+ try {
2104
+ var next = it.next();
2105
+ } catch (e) {
2106
+ return observer.onError(e);
2107
+ }
2108
+ if (next.done) {
2109
+ return observer.onCompleted();
2110
+ }
2111
+
2112
+ var result = next.value;
2113
+
2114
+ if (mapper) {
2115
+ try {
2116
+ result = mapper(result, i);
2117
+ } catch (e) {
2118
+ return observer.onError(e);
2119
+ }
2120
+ }
2121
+
2122
+ observer.onNext(result);
2123
+ recurse(i + 1);
2124
+ }
2125
+
2126
+ return this.parent.scheduler.scheduleRecursiveWithState(0, loopRecursive);
2127
+ };
2128
+
2129
+ return FromSink;
2130
+ }());
2131
+
1978
2132
  var maxSafeInteger = Math.pow(2, 53) - 1;
1979
2133
 
1980
2134
  function StringIterable(str) {
@@ -1996,12 +2150,7 @@
1996
2150
  };
1997
2151
 
1998
2152
  StringIterator.prototype.next = function () {
1999
- if (this._i < this._l) {
2000
- var val = this._s.charAt(this._i++);
2001
- return { done: false, value: val };
2002
- } else {
2003
- return doneEnumerator;
2004
- }
2153
+ return this._i < this._l ? { done: false, value: this._s.charAt(this._i++) } : doneEnumerator;
2005
2154
  };
2006
2155
 
2007
2156
  function ArrayIterable(a) {
@@ -2023,12 +2172,7 @@
2023
2172
  };
2024
2173
 
2025
2174
  ArrayIterator.prototype.next = function () {
2026
- if (this._i < this._l) {
2027
- var val = this._a[this._i++];
2028
- return { done: false, value: val };
2029
- } else {
2030
- return doneEnumerator;
2031
- }
2175
+ return this._i < this._l ? { done: false, value: this._a[this._i++] } : doneEnumerator;
2032
2176
  };
2033
2177
 
2034
2178
  function numberIsFinite(value) {
@@ -2071,12 +2215,12 @@
2071
2215
  }
2072
2216
 
2073
2217
  /**
2074
- * This method creates a new Observable sequence from an array-like or iterable object.
2075
- * @param {Any} arrayLike An array-like or iterable object to convert to an Observable sequence.
2076
- * @param {Function} [mapFn] Map function to call on every element of the array.
2077
- * @param {Any} [thisArg] The context to use calling the mapFn if provided.
2078
- * @param {Scheduler} [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread.
2079
- */
2218
+ * This method creates a new Observable sequence from an array-like or iterable object.
2219
+ * @param {Any} arrayLike An array-like or iterable object to convert to an Observable sequence.
2220
+ * @param {Function} [mapFn] Map function to call on every element of the array.
2221
+ * @param {Any} [thisArg] The context to use calling the mapFn if provided.
2222
+ * @param {Scheduler} [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread.
2223
+ */
2080
2224
  var observableFrom = Observable.from = function (iterable, mapFn, thisArg, scheduler) {
2081
2225
  if (iterable == null) {
2082
2226
  throw new Error('iterable cannot be null.')
@@ -2084,61 +2228,56 @@
2084
2228
  if (mapFn && !isFunction(mapFn)) {
2085
2229
  throw new Error('mapFn when provided must be a function');
2086
2230
  }
2231
+ if (mapFn) {
2232
+ var mapper = bindCallback(mapFn, thisArg, 2);
2233
+ }
2087
2234
  isScheduler(scheduler) || (scheduler = currentThreadScheduler);
2088
- var list = Object(iterable), it = getIterable(list);
2089
- return new AnonymousObservable(function (observer) {
2090
- var i = 0;
2091
- return scheduler.scheduleRecursive(function (self) {
2092
- var next;
2093
- try {
2094
- next = it.next();
2095
- } catch (e) {
2096
- observer.onError(e);
2097
- return;
2098
- }
2099
- if (next.done) {
2100
- observer.onCompleted();
2101
- return;
2102
- }
2235
+ return new FromObservable(iterable, mapper, scheduler);
2236
+ }
2103
2237
 
2104
- var result = next.value;
2238
+ var FromArrayObservable = (function(__super__) {
2239
+ inherits(FromArrayObservable, __super__);
2240
+ function FromArrayObservable(args, scheduler) {
2241
+ this.args = args;
2242
+ this.scheduler = scheduler || currentThreadScheduler;
2243
+ __super__.call(this);
2244
+ }
2105
2245
 
2106
- if (mapFn && isFunction(mapFn)) {
2107
- try {
2108
- result = mapFn.call(thisArg, result, i);
2109
- } catch (e) {
2110
- observer.onError(e);
2111
- return;
2112
- }
2113
- }
2246
+ FromArrayObservable.prototype.subscribeCore = function (observer) {
2247
+ var sink = new FromArraySink(observer, this);
2248
+ return sink.run();
2249
+ };
2114
2250
 
2115
- observer.onNext(result);
2116
- i++;
2117
- self();
2118
- });
2119
- });
2251
+ return FromArrayObservable;
2252
+ }(ObservableBase));
2253
+
2254
+ function FromArraySink(observer, parent) {
2255
+ this.observer = observer;
2256
+ this.parent = parent;
2257
+ }
2258
+
2259
+ FromArraySink.prototype.run = function () {
2260
+ var observer = this.observer, args = this.parent.args, len = args.length;
2261
+ function loopRecursive(i, recurse) {
2262
+ if (i < len) {
2263
+ observer.onNext(args[i]);
2264
+ recurse(i + 1);
2265
+ } else {
2266
+ observer.onCompleted();
2267
+ }
2268
+ }
2269
+
2270
+ return this.parent.scheduler.scheduleRecursiveWithState(0, loopRecursive);
2120
2271
  };
2121
2272
 
2122
2273
  /**
2123
- * Converts an array to an observable sequence, using an optional scheduler to enumerate the array.
2124
- * @deprecated use Observable.from or Observable.of
2125
- * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on.
2126
- * @returns {Observable} The observable sequence whose elements are pulled from the given enumerable sequence.
2127
- */
2274
+ * Converts an array to an observable sequence, using an optional scheduler to enumerate the array.
2275
+ * @deprecated use Observable.from or Observable.of
2276
+ * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on.
2277
+ * @returns {Observable} The observable sequence whose elements are pulled from the given enumerable sequence.
2278
+ */
2128
2279
  var observableFromArray = Observable.fromArray = function (array, scheduler) {
2129
- deprecate('fromArray', 'from');
2130
- isScheduler(scheduler) || (scheduler = currentThreadScheduler);
2131
- return new AnonymousObservable(function (observer) {
2132
- var count = 0, len = array.length;
2133
- return scheduler.scheduleRecursive(function (self) {
2134
- if (count < len) {
2135
- observer.onNext(array[count++]);
2136
- self();
2137
- } else {
2138
- observer.onCompleted();
2139
- }
2140
- });
2141
- });
2280
+ return new FromArrayObservable(array, scheduler)
2142
2281
  };
2143
2282
 
2144
2283
  /**
@@ -2152,55 +2291,45 @@
2152
2291
  };
2153
2292
 
2154
2293
  function observableOf (scheduler, array) {
2155
- isScheduler(scheduler) || (scheduler = currentThreadScheduler);
2156
- return new AnonymousObservable(function (observer) {
2157
- var count = 0, len = array.length;
2158
- return scheduler.scheduleRecursive(function (self) {
2159
- if (count < len) {
2160
- observer.onNext(array[count++]);
2161
- self();
2162
- } else {
2163
- observer.onCompleted();
2164
- }
2165
- });
2166
- });
2294
+ return new FromArrayObservable(array, scheduler);
2167
2295
  }
2168
2296
 
2169
2297
  /**
2170
- * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.
2171
- * @returns {Observable} The observable sequence whose elements are pulled from the given arguments.
2172
- */
2298
+ * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.
2299
+ * @returns {Observable} The observable sequence whose elements are pulled from the given arguments.
2300
+ */
2173
2301
  Observable.of = function () {
2174
- return observableOf(null, arguments);
2302
+ var len = arguments.length, args = new Array(len);
2303
+ for(var i = 0; i < len; i++) { args[i] = arguments[i]; }
2304
+ return new FromArrayObservable(args);
2175
2305
  };
2176
2306
 
2177
2307
  /**
2178
- * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.
2179
- * @param {Scheduler} scheduler A scheduler to use for scheduling the arguments.
2180
- * @returns {Observable} The observable sequence whose elements are pulled from the given arguments.
2181
- */
2308
+ * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments.
2309
+ * @param {Scheduler} scheduler A scheduler to use for scheduling the arguments.
2310
+ * @returns {Observable} The observable sequence whose elements are pulled from the given arguments.
2311
+ */
2182
2312
  Observable.ofWithScheduler = function (scheduler) {
2183
- return observableOf(scheduler, slice.call(arguments, 1));
2313
+ var len = arguments.length, args = new Array(len - 1);
2314
+ for(var i = 1; i < len; i++) { args[i - 1] = arguments[i]; }
2315
+ return new FromArrayObservable(args, scheduler);
2184
2316
  };
2185
2317
 
2186
2318
  /**
2187
- * Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to send out observer messages.
2188
- *
2189
- * @example
2190
- * var res = Rx.Observable.range(0, 10);
2191
- * var res = Rx.Observable.range(0, 10, Rx.Scheduler.timeout);
2192
- * @param {Number} start The value of the first integer in the sequence.
2193
- * @param {Number} count The number of sequential integers to generate.
2194
- * @param {Scheduler} [scheduler] Scheduler to run the generator loop on. If not specified, defaults to Scheduler.currentThread.
2195
- * @returns {Observable} An observable sequence that contains a range of sequential integral numbers.
2319
+ * Convert an object into an observable sequence of [key, value] pairs.
2320
+ * @param {Object} obj The object to inspect.
2321
+ * @param {Scheduler} [scheduler] Scheduler to run the enumeration of the input sequence on.
2322
+ * @returns {Observable} An observable sequence of [key, value] pairs from the object.
2196
2323
  */
2197
- Observable.range = function (start, count, scheduler) {
2198
- isScheduler(scheduler) || (scheduler = currentThreadScheduler);
2324
+ Observable.pairs = function (obj, scheduler) {
2325
+ scheduler || (scheduler = Rx.Scheduler.currentThread);
2199
2326
  return new AnonymousObservable(function (observer) {
2200
- return scheduler.scheduleRecursiveWithState(0, function (i, self) {
2201
- if (i < count) {
2202
- observer.onNext(start + i);
2203
- self(i + 1);
2327
+ var keys = Object.keys(obj), len = keys.length;
2328
+ return scheduler.scheduleRecursiveWithState(0, function (idx, self) {
2329
+ if (idx < len) {
2330
+ var key = keys[idx];
2331
+ observer.onNext([key, obj[key]]);
2332
+ self(idx + 1);
2204
2333
  } else {
2205
2334
  observer.onCompleted();
2206
2335
  }
@@ -2208,6 +2337,58 @@
2208
2337
  });
2209
2338
  };
2210
2339
 
2340
+ var RangeObservable = (function(__super__) {
2341
+ inherits(RangeObservable, __super__);
2342
+ function RangeObservable(start, count, scheduler) {
2343
+ this.start = start;
2344
+ this.count = count;
2345
+ this.scheduler = scheduler;
2346
+ __super__.call(this);
2347
+ }
2348
+
2349
+ RangeObservable.prototype.subscribeCore = function (observer) {
2350
+ var sink = new RangeSink(observer, this);
2351
+ return sink.run();
2352
+ };
2353
+
2354
+ return RangeObservable;
2355
+ }(ObservableBase));
2356
+
2357
+ var RangeSink = (function () {
2358
+ function RangeSink(observer, parent) {
2359
+ this.observer = observer;
2360
+ this.parent = parent;
2361
+ }
2362
+
2363
+ RangeSink.prototype.run = function () {
2364
+ var start = this.parent.start, count = this.parent.count, observer = this.observer;
2365
+ function loopRecursive(i, recurse) {
2366
+ if (i < count) {
2367
+ observer.onNext(start + i);
2368
+ recurse(i + 1);
2369
+ } else {
2370
+ observer.onCompleted();
2371
+ }
2372
+ }
2373
+
2374
+ return this.parent.scheduler.scheduleRecursiveWithState(0, loopRecursive);
2375
+ };
2376
+
2377
+ return RangeSink;
2378
+ }());
2379
+
2380
+ /**
2381
+ * Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to send out observer messages.
2382
+ * @param {Number} start The value of the first integer in the sequence.
2383
+ * @param {Number} count The number of sequential integers to generate.
2384
+ * @param {Scheduler} [scheduler] Scheduler to run the generator loop on. If not specified, defaults to Scheduler.currentThread.
2385
+ * @returns {Observable} An observable sequence that contains a range of sequential integral numbers.
2386
+ */
2387
+ Observable.range = function (start, count, scheduler) {
2388
+ isScheduler(scheduler) || (scheduler = currentThreadScheduler);
2389
+ return new RangeObservable(start, count, scheduler);
2390
+ };
2391
+
2211
2392
  /**
2212
2393
  * Generates an observable sequence that repeats the given element the specified number of times, using the specified scheduler to send out observer messages.
2213
2394
  *
@@ -2229,10 +2410,6 @@
2229
2410
  /**
2230
2411
  * Returns an observable sequence that contains a single element, using the specified scheduler to send out observer messages.
2231
2412
  * There is an alias called 'just', and 'returnValue' for browsers <IE9.
2232
- *
2233
- * @example
2234
- * var res = Rx.Observable.return(42);
2235
- * var res = Rx.Observable.return(42, Rx.Scheduler.timeout);
2236
2413
  * @param {Mixed} value Single element in the resulting observable sequence.
2237
2414
  * @param {Scheduler} scheduler Scheduler to send the single element on. If not specified, defaults to Scheduler.immediate.
2238
2415
  * @returns {Observable} An observable sequence containing the single specified element.
@@ -2249,44 +2426,48 @@
2249
2426
 
2250
2427
  /** @deprecated use return or just */
2251
2428
  Observable.returnValue = function () {
2252
- deprecate('returnValue', 'return or just');
2429
+ //deprecate('returnValue', 'return or just');
2253
2430
  return observableReturn.apply(null, arguments);
2254
2431
  };
2255
2432
 
2256
2433
  /**
2257
2434
  * Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single onError message.
2258
2435
  * There is an alias to this method called 'throwError' for browsers <IE9.
2259
- * @param {Mixed} exception An object used for the sequence's termination.
2436
+ * @param {Mixed} error An object used for the sequence's termination.
2260
2437
  * @param {Scheduler} scheduler Scheduler to send the exceptional termination call on. If not specified, defaults to Scheduler.immediate.
2261
2438
  * @returns {Observable} The observable sequence that terminates exceptionally with the specified exception object.
2262
2439
  */
2263
- var observableThrow = Observable['throw'] = Observable.throwException = Observable.throwError = function (exception, scheduler) {
2440
+ var observableThrow = Observable['throw'] = Observable.throwError = function (error, scheduler) {
2264
2441
  isScheduler(scheduler) || (scheduler = immediateScheduler);
2265
2442
  return new AnonymousObservable(function (observer) {
2266
2443
  return scheduler.schedule(function () {
2267
- observer.onError(exception);
2444
+ observer.onError(error);
2268
2445
  });
2269
2446
  });
2270
2447
  };
2271
2448
 
2449
+ /** @deprecated use #some instead */
2450
+ Observable.throwException = function () {
2451
+ //deprecate('throwException', 'throwError');
2452
+ return Observable.throwError.apply(null, arguments);
2453
+ };
2454
+
2272
2455
  function observableCatchHandler(source, handler) {
2273
- return new AnonymousObservable(function (observer) {
2456
+ return new AnonymousObservable(function (o) {
2274
2457
  var d1 = new SingleAssignmentDisposable(), subscription = new SerialDisposable();
2275
2458
  subscription.setDisposable(d1);
2276
- d1.setDisposable(source.subscribe(observer.onNext.bind(observer), function (exception) {
2277
- var d, result;
2459
+ d1.setDisposable(source.subscribe(function (x) { o.onNext(x); }, function (e) {
2278
2460
  try {
2279
- result = handler(exception);
2461
+ var result = handler(e);
2280
2462
  } catch (ex) {
2281
- observer.onError(ex);
2282
- return;
2463
+ return o.onError(ex);
2283
2464
  }
2284
2465
  isPromise(result) && (result = observableFromPromise(result));
2285
2466
 
2286
- d = new SingleAssignmentDisposable();
2467
+ var d = new SingleAssignmentDisposable();
2287
2468
  subscription.setDisposable(d);
2288
- d.setDisposable(result.subscribe(observer));
2289
- }, observer.onCompleted.bind(observer)));
2469
+ d.setDisposable(result.subscribe(o));
2470
+ }, function (x) { o.onCompleted(x); }));
2290
2471
 
2291
2472
  return subscription;
2292
2473
  }, source);
@@ -2300,35 +2481,25 @@
2300
2481
  * @param {Mixed} handlerOrSecond Exception handler function that returns an observable sequence given the error that occurred in the first sequence, or a second observable sequence used to produce results when an error occurred in the first sequence.
2301
2482
  * @returns {Observable} An observable sequence containing the first sequence's elements, followed by the elements of the handler sequence in case an exception occurred.
2302
2483
  */
2303
- observableProto['catch'] = observableProto.catchError = function (handlerOrSecond) {
2484
+ observableProto['catch'] = observableProto.catchError = observableProto.catchException = function (handlerOrSecond) {
2304
2485
  return typeof handlerOrSecond === 'function' ?
2305
2486
  observableCatchHandler(this, handlerOrSecond) :
2306
2487
  observableCatch([this, handlerOrSecond]);
2307
2488
  };
2308
2489
 
2309
- /**
2310
- * @deprecated use #catch or #catchError instead.
2311
- */
2312
- observableProto.catchException = function (handlerOrSecond) {
2313
- deprecate('catchException', 'catch or catchError');
2314
- return this.catchError(handlerOrSecond);
2315
- };
2316
-
2317
2490
  /**
2318
2491
  * Continues an observable sequence that is terminated by an exception with the next observable sequence.
2319
2492
  * @param {Array | Arguments} args Arguments or an array to use as the next sequence if an error occurs.
2320
2493
  * @returns {Observable} An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.
2321
2494
  */
2322
- var observableCatch = Observable.catchError = Observable['catch'] = function () {
2323
- return enumerableOf(argsOrArray(arguments, 0)).catchError();
2324
- };
2325
-
2326
- /**
2327
- * @deprecated use #catch or #catchError instead.
2328
- */
2329
- Observable.catchException = function () {
2330
- deprecate('catchException', 'catch or catchError');
2331
- return observableCatch.apply(null, arguments);
2495
+ var observableCatch = Observable.catchError = Observable['catch'] = Observable.catchException = function () {
2496
+ var items = [];
2497
+ if (Array.isArray(arguments[0])) {
2498
+ items = arguments[0];
2499
+ } else {
2500
+ for(var i = 0, len = arguments.length; i < len; i++) { items.push(arguments[i]); }
2501
+ }
2502
+ return enumerableOf(items).catchError();
2332
2503
  };
2333
2504
 
2334
2505
  /**
@@ -2341,7 +2512,8 @@
2341
2512
  * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
2342
2513
  */
2343
2514
  observableProto.combineLatest = function () {
2344
- var args = slice.call(arguments);
2515
+ var len = arguments.length, args = new Array(len);
2516
+ for(var i = 0; i < len; i++) { args[i] = arguments[i]; }
2345
2517
  if (Array.isArray(args[0])) {
2346
2518
  args[0].unshift(this);
2347
2519
  } else {
@@ -2359,54 +2531,51 @@
2359
2531
  * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
2360
2532
  */
2361
2533
  var combineLatest = Observable.combineLatest = function () {
2362
- var args = slice.call(arguments), resultSelector = args.pop();
2363
-
2364
- if (Array.isArray(args[0])) {
2365
- args = args[0];
2366
- }
2534
+ var len = arguments.length, args = new Array(len);
2535
+ for(var i = 0; i < len; i++) { args[i] = arguments[i]; }
2536
+ var resultSelector = args.pop();
2537
+ len--;
2538
+ Array.isArray(args[0]) && (args = args[0]);
2367
2539
 
2368
- return new AnonymousObservable(function (observer) {
2540
+ return new AnonymousObservable(function (o) {
2369
2541
  var falseFactory = function () { return false; },
2370
- n = args.length,
2371
- hasValue = arrayInitialize(n, falseFactory),
2542
+ hasValue = arrayInitialize(len, falseFactory),
2372
2543
  hasValueAll = false,
2373
- isDone = arrayInitialize(n, falseFactory),
2374
- values = new Array(n);
2544
+ isDone = arrayInitialize(len, falseFactory),
2545
+ values = new Array(len);
2375
2546
 
2376
2547
  function next(i) {
2377
- var res;
2378
2548
  hasValue[i] = true;
2379
2549
  if (hasValueAll || (hasValueAll = hasValue.every(identity))) {
2380
2550
  try {
2381
- res = resultSelector.apply(null, values);
2551
+ var res = resultSelector.apply(null, values);
2382
2552
  } catch (ex) {
2383
- observer.onError(ex);
2553
+ o.onError(ex);
2384
2554
  return;
2385
2555
  }
2386
- observer.onNext(res);
2556
+ o.onNext(res);
2387
2557
  } else if (isDone.filter(function (x, j) { return j !== i; }).every(identity)) {
2388
- observer.onCompleted();
2558
+ o.onCompleted();
2389
2559
  }
2390
2560
  }
2391
2561
 
2392
2562
  function done (i) {
2393
2563
  isDone[i] = true;
2394
- if (isDone.every(identity)) {
2395
- observer.onCompleted();
2396
- }
2564
+ isDone.every(identity) && o.onCompleted();
2397
2565
  }
2398
2566
 
2399
- var subscriptions = new Array(n);
2400
- for (var idx = 0; idx < n; idx++) {
2567
+ var subscriptions = new Array(len);
2568
+ for (var idx = 0; idx < len; idx++) {
2401
2569
  (function (i) {
2402
2570
  var source = args[i], sad = new SingleAssignmentDisposable();
2403
2571
  isPromise(source) && (source = observableFromPromise(source));
2404
2572
  sad.setDisposable(source.subscribe(function (x) {
2405
- values[i] = x;
2406
- next(i);
2407
- }, observer.onError.bind(observer), function () {
2408
- done(i);
2409
- }));
2573
+ values[i] = x;
2574
+ next(i);
2575
+ },
2576
+ function(e) { o.onError(e); },
2577
+ function () { done(i); }
2578
+ ));
2410
2579
  subscriptions[i] = sad;
2411
2580
  }(idx));
2412
2581
  }
@@ -2415,19 +2584,15 @@
2415
2584
  }, this);
2416
2585
  };
2417
2586
 
2418
- /**
2419
- * Concatenates all the observable sequences. This takes in either an array or variable arguments to concatenate.
2420
- *
2421
- * @example
2422
- * 1 - concatenated = xs.concat(ys, zs);
2423
- * 2 - concatenated = xs.concat([ys, zs]);
2424
- * @returns {Observable} An observable sequence that contains the elements of each given sequence, in sequential order.
2425
- */
2426
- observableProto.concat = function () {
2427
- var items = slice.call(arguments, 0);
2428
- items.unshift(this);
2429
- return observableConcat.apply(this, items);
2430
- };
2587
+ /**
2588
+ * Concatenates all the observable sequences. This takes in either an array or variable arguments to concatenate.
2589
+ * @returns {Observable} An observable sequence that contains the elements of each given sequence, in sequential order.
2590
+ */
2591
+ observableProto.concat = function () {
2592
+ for(var args = [], i = 0, len = arguments.length; i < len; i++) { args.push(arguments[i]); }
2593
+ args.unshift(this);
2594
+ return observableConcat.apply(null, args);
2595
+ };
2431
2596
 
2432
2597
  /**
2433
2598
  * Concatenates all the observable sequences.
@@ -2435,20 +2600,21 @@
2435
2600
  * @returns {Observable} An observable sequence that contains the elements of each given sequence, in sequential order.
2436
2601
  */
2437
2602
  var observableConcat = Observable.concat = function () {
2438
- return enumerableOf(argsOrArray(arguments, 0)).concat();
2603
+ var args;
2604
+ if (Array.isArray(arguments[0])) {
2605
+ args = arguments[0];
2606
+ } else {
2607
+ args = new Array(arguments.length);
2608
+ for(var i = 0, len = arguments.length; i < len; i++) { args[i] = arguments[i]; }
2609
+ }
2610
+ return enumerableOf(args).concat();
2439
2611
  };
2440
2612
 
2441
2613
  /**
2442
2614
  * Concatenates an observable sequence of observable sequences.
2443
2615
  * @returns {Observable} An observable sequence that contains the elements of each observed inner sequence, in sequential order.
2444
2616
  */
2445
- observableProto.concatAll = function () {
2446
- return this.merge(1);
2447
- };
2448
-
2449
- /** @deprecated Use `concatAll` instead. */
2450
- observableProto.concatObservable = function () {
2451
- deprecate('concatObservable', 'concatAll');
2617
+ observableProto.concatAll = observableProto.concatObservable = function () {
2452
2618
  return this.merge(1);
2453
2619
  };
2454
2620
 
@@ -2465,7 +2631,7 @@
2465
2631
  observableProto.merge = function (maxConcurrentOrOther) {
2466
2632
  if (typeof maxConcurrentOrOther !== 'number') { return observableMerge(this, maxConcurrentOrOther); }
2467
2633
  var sources = this;
2468
- return new AnonymousObservable(function (observer) {
2634
+ return new AnonymousObservable(function (o) {
2469
2635
  var activeCount = 0, group = new CompositeDisposable(), isStopped = false, q = [];
2470
2636
 
2471
2637
  function subscribe(xs) {
@@ -2475,13 +2641,13 @@
2475
2641
  // Check for promises support
2476
2642
  isPromise(xs) && (xs = observableFromPromise(xs));
2477
2643
 
2478
- subscription.setDisposable(xs.subscribe(observer.onNext.bind(observer), observer.onError.bind(observer), function () {
2644
+ subscription.setDisposable(xs.subscribe(function (x) { o.onNext(x); }, function (e) { o.onError(e); }, function () {
2479
2645
  group.remove(subscription);
2480
2646
  if (q.length > 0) {
2481
2647
  subscribe(q.shift());
2482
2648
  } else {
2483
2649
  activeCount--;
2484
- isStopped && activeCount === 0 && observer.onCompleted();
2650
+ isStopped && activeCount === 0 && o.onCompleted();
2485
2651
  }
2486
2652
  }));
2487
2653
  }
@@ -2492,9 +2658,9 @@
2492
2658
  } else {
2493
2659
  q.push(innerSource);
2494
2660
  }
2495
- }, observer.onError.bind(observer), function () {
2661
+ }, function (e) { o.onError(e); }, function () {
2496
2662
  isStopped = true;
2497
- activeCount === 0 && observer.onCompleted();
2663
+ activeCount === 0 && o.onCompleted();
2498
2664
  }));
2499
2665
  return group;
2500
2666
  }, sources);
@@ -2506,16 +2672,16 @@
2506
2672
  * @returns {Observable} The observable sequence that merges the elements of the observable sequences.
2507
2673
  */
2508
2674
  var observableMerge = Observable.merge = function () {
2509
- var scheduler, sources;
2675
+ var scheduler, sources = [], i, len = arguments.length;
2510
2676
  if (!arguments[0]) {
2511
2677
  scheduler = immediateScheduler;
2512
- sources = slice.call(arguments, 1);
2678
+ for(i = 1; i < len; i++) { sources.push(arguments[i]); }
2513
2679
  } else if (isScheduler(arguments[0])) {
2514
2680
  scheduler = arguments[0];
2515
- sources = slice.call(arguments, 1);
2681
+ for(i = 1; i < len; i++) { sources.push(arguments[i]); }
2516
2682
  } else {
2517
2683
  scheduler = immediateScheduler;
2518
- sources = slice.call(arguments, 0);
2684
+ for(i = 0; i < len; i++) { sources.push(arguments[i]); }
2519
2685
  }
2520
2686
  if (Array.isArray(sources[0])) {
2521
2687
  sources = sources[0];
@@ -2527,9 +2693,9 @@
2527
2693
  * Merges an observable sequence of observable sequences into an observable sequence.
2528
2694
  * @returns {Observable} The observable sequence that merges the elements of the inner sequences.
2529
2695
  */
2530
- observableProto.mergeAll = function () {
2696
+ observableProto.mergeAll = observableProto.mergeObservable = function () {
2531
2697
  var sources = this;
2532
- return new AnonymousObservable(function (observer) {
2698
+ return new AnonymousObservable(function (o) {
2533
2699
  var group = new CompositeDisposable(),
2534
2700
  isStopped = false,
2535
2701
  m = new SingleAssignmentDisposable();
@@ -2542,26 +2708,18 @@
2542
2708
  // Check for promises support
2543
2709
  isPromise(innerSource) && (innerSource = observableFromPromise(innerSource));
2544
2710
 
2545
- innerSubscription.setDisposable(innerSource.subscribe(observer.onNext.bind(observer), observer.onError.bind(observer), function () {
2711
+ innerSubscription.setDisposable(innerSource.subscribe(function (x) { o.onNext(x); }, function (e) { o.onError(e); }, function () {
2546
2712
  group.remove(innerSubscription);
2547
- isStopped && group.length === 1 && observer.onCompleted();
2713
+ isStopped && group.length === 1 && o.onCompleted();
2548
2714
  }));
2549
- }, observer.onError.bind(observer), function () {
2715
+ }, function (e) { o.onError(e); }, function () {
2550
2716
  isStopped = true;
2551
- group.length === 1 && observer.onCompleted();
2717
+ group.length === 1 && o.onCompleted();
2552
2718
  }));
2553
2719
  return group;
2554
2720
  }, sources);
2555
2721
  };
2556
2722
 
2557
- /**
2558
- * @deprecated use #mergeAll instead.
2559
- */
2560
- observableProto.mergeObservable = function () {
2561
- deprecate('mergeObservable', 'mergeAll');
2562
- return this.mergeAll.apply(this, arguments);
2563
- };
2564
-
2565
2723
  /**
2566
2724
  * Returns the values from the source observable sequence only after the other observable sequence produces a value.
2567
2725
  * @param {Observable | Promise} other The observable sequence or Promise that triggers propagation of elements of the source sequence.
@@ -2569,12 +2727,12 @@
2569
2727
  */
2570
2728
  observableProto.skipUntil = function (other) {
2571
2729
  var source = this;
2572
- return new AnonymousObservable(function (observer) {
2730
+ return new AnonymousObservable(function (o) {
2573
2731
  var isOpen = false;
2574
2732
  var disposables = new CompositeDisposable(source.subscribe(function (left) {
2575
- isOpen && observer.onNext(left);
2576
- }, observer.onError.bind(observer), function () {
2577
- isOpen && observer.onCompleted();
2733
+ isOpen && o.onNext(left);
2734
+ }, function (e) { o.onError(e); }, function () {
2735
+ isOpen && o.onCompleted();
2578
2736
  }));
2579
2737
 
2580
2738
  isPromise(other) && (other = observableFromPromise(other));
@@ -2584,7 +2742,7 @@
2584
2742
  rightSubscription.setDisposable(other.subscribe(function () {
2585
2743
  isOpen = true;
2586
2744
  rightSubscription.dispose();
2587
- }, observer.onError.bind(observer), function () {
2745
+ }, function (e) { o.onError(e); }, function () {
2588
2746
  rightSubscription.dispose();
2589
2747
  }));
2590
2748
 
@@ -2622,7 +2780,7 @@
2622
2780
  }
2623
2781
  }));
2624
2782
  },
2625
- observer.onError.bind(observer),
2783
+ function (e) { observer.onError(e); },
2626
2784
  function () {
2627
2785
  isStopped = true;
2628
2786
  !hasLatest && observer.onCompleted();
@@ -2638,15 +2796,79 @@
2638
2796
  */
2639
2797
  observableProto.takeUntil = function (other) {
2640
2798
  var source = this;
2641
- return new AnonymousObservable(function (observer) {
2799
+ return new AnonymousObservable(function (o) {
2642
2800
  isPromise(other) && (other = observableFromPromise(other));
2643
2801
  return new CompositeDisposable(
2644
- source.subscribe(observer),
2645
- other.subscribe(observer.onCompleted.bind(observer), observer.onError.bind(observer), noop)
2802
+ source.subscribe(o),
2803
+ other.subscribe(function () { o.onCompleted(); }, function (e) { o.onError(e); }, noop)
2646
2804
  );
2647
2805
  }, source);
2648
2806
  };
2649
2807
 
2808
+ /**
2809
+ * Merges the specified observable sequences into one observable sequence by using the selector function only when the (first) source observable sequence produces an element.
2810
+ *
2811
+ * @example
2812
+ * 1 - obs = obs1.withLatestFrom(obs2, obs3, function (o1, o2, o3) { return o1 + o2 + o3; });
2813
+ * 2 - obs = obs1.withLatestFrom([obs2, obs3], function (o1, o2, o3) { return o1 + o2 + o3; });
2814
+ * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
2815
+ */
2816
+ observableProto.withLatestFrom = function () {
2817
+ for(var args = [], i = 0, len = arguments.length; i < len; i++) { args.push(arguments[i]); }
2818
+ var resultSelector = args.pop(), source = this;
2819
+
2820
+ if (typeof source === 'undefined') {
2821
+ throw new Error('Source observable not found for withLatestFrom().');
2822
+ }
2823
+ if (typeof resultSelector !== 'function') {
2824
+ throw new Error('withLatestFrom() expects a resultSelector function.');
2825
+ }
2826
+ if (Array.isArray(args[0])) {
2827
+ args = args[0];
2828
+ }
2829
+
2830
+ return new AnonymousObservable(function (observer) {
2831
+ var falseFactory = function () { return false; },
2832
+ n = args.length,
2833
+ hasValue = arrayInitialize(n, falseFactory),
2834
+ hasValueAll = false,
2835
+ values = new Array(n);
2836
+
2837
+ var subscriptions = new Array(n + 1);
2838
+ for (var idx = 0; idx < n; idx++) {
2839
+ (function (i) {
2840
+ var other = args[i], sad = new SingleAssignmentDisposable();
2841
+ isPromise(other) && (other = observableFromPromise(other));
2842
+ sad.setDisposable(other.subscribe(function (x) {
2843
+ values[i] = x;
2844
+ hasValue[i] = true;
2845
+ hasValueAll = hasValue.every(identity);
2846
+ }, observer.onError.bind(observer), function () {}));
2847
+ subscriptions[i] = sad;
2848
+ }(idx));
2849
+ }
2850
+
2851
+ var sad = new SingleAssignmentDisposable();
2852
+ sad.setDisposable(source.subscribe(function (x) {
2853
+ var res;
2854
+ var allValues = [x].concat(values);
2855
+ if (!hasValueAll) return;
2856
+ try {
2857
+ res = resultSelector.apply(null, allValues);
2858
+ } catch (ex) {
2859
+ observer.onError(ex);
2860
+ return;
2861
+ }
2862
+ observer.onNext(res);
2863
+ }, observer.onError.bind(observer), function () {
2864
+ observer.onCompleted();
2865
+ }));
2866
+ subscriptions[n] = sad;
2867
+
2868
+ return new CompositeDisposable(subscriptions);
2869
+ }, this);
2870
+ };
2871
+
2650
2872
  function zipArray(second, resultSelector) {
2651
2873
  var first = this;
2652
2874
  return new AnonymousObservable(function (observer) {
@@ -2657,36 +2879,39 @@
2657
2879
  try {
2658
2880
  result = resultSelector(left, right);
2659
2881
  } catch (e) {
2660
- observer.onError(e);
2661
- return;
2882
+ return observer.onError(e);
2662
2883
  }
2663
2884
  observer.onNext(result);
2664
2885
  } else {
2665
2886
  observer.onCompleted();
2666
2887
  }
2667
- }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
2888
+ }, function (e) { observer.onError(e); }, function () { observer.onCompleted(); });
2668
2889
  }, first);
2669
2890
  }
2670
2891
 
2892
+ function falseFactory() { return false; }
2893
+ function emptyArrayFactory() { return []; }
2894
+
2671
2895
  /**
2672
2896
  * Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences or an array have produced an element at a corresponding index.
2673
- * The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the sources.
2897
+ * The last element in the arguments must be a function to invoke for each series of elements at corresponding indexes in the args.
2674
2898
  *
2675
2899
  * @example
2676
2900
  * 1 - res = obs1.zip(obs2, fn);
2677
2901
  * 1 - res = x1.zip([1,2,3], fn);
2678
- * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
2902
+ * @returns {Observable} An observable sequence containing the result of combining elements of the args using the specified result selector function.
2679
2903
  */
2680
2904
  observableProto.zip = function () {
2681
- if (Array.isArray(arguments[0])) {
2682
- return zipArray.apply(this, arguments);
2683
- }
2684
- var parent = this, sources = slice.call(arguments), resultSelector = sources.pop();
2685
- sources.unshift(parent);
2905
+ if (Array.isArray(arguments[0])) { return zipArray.apply(this, arguments); }
2906
+ var len = arguments.length, args = new Array(len);
2907
+ for(var i = 0; i < len; i++) { args[i] = arguments[i]; }
2908
+
2909
+ var parent = this, resultSelector = args.pop();
2910
+ args.unshift(parent);
2686
2911
  return new AnonymousObservable(function (observer) {
2687
- var n = sources.length,
2688
- queues = arrayInitialize(n, function () { return []; }),
2689
- isDone = arrayInitialize(n, function () { return false; });
2912
+ var n = args.length,
2913
+ queues = arrayInitialize(n, emptyArrayFactory),
2914
+ isDone = arrayInitialize(n, falseFactory);
2690
2915
 
2691
2916
  function next(i) {
2692
2917
  var res, queuedValues;
@@ -2714,12 +2939,12 @@
2714
2939
  var subscriptions = new Array(n);
2715
2940
  for (var idx = 0; idx < n; idx++) {
2716
2941
  (function (i) {
2717
- var source = sources[i], sad = new SingleAssignmentDisposable();
2942
+ var source = args[i], sad = new SingleAssignmentDisposable();
2718
2943
  isPromise(source) && (source = observableFromPromise(source));
2719
2944
  sad.setDisposable(source.subscribe(function (x) {
2720
2945
  queues[i].push(x);
2721
2946
  next(i);
2722
- }, observer.onError.bind(observer), function () {
2947
+ }, function (e) { observer.onError(e); }, function () {
2723
2948
  done(i);
2724
2949
  }));
2725
2950
  subscriptions[i] = sad;
@@ -2737,7 +2962,9 @@
2737
2962
  * @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
2738
2963
  */
2739
2964
  Observable.zip = function () {
2740
- var args = slice.call(arguments, 0), first = args.shift();
2965
+ var len = arguments.length, args = new Array(len);
2966
+ for(var i = 0; i < len; i++) { args[i] = arguments[i]; }
2967
+ var first = args.shift();
2741
2968
  return first.zip.apply(first, args);
2742
2969
  };
2743
2970
 
@@ -2747,7 +2974,14 @@
2747
2974
  * @returns {Observable} An observable sequence containing lists of elements at corresponding indexes.
2748
2975
  */
2749
2976
  Observable.zipArray = function () {
2750
- var sources = argsOrArray(arguments, 0);
2977
+ var sources;
2978
+ if (Array.isArray(arguments[0])) {
2979
+ sources = arguments[0];
2980
+ } else {
2981
+ var len = arguments.length;
2982
+ sources = new Array(len);
2983
+ for(var i = 0; i < len; i++) { sources[i] = arguments[i]; }
2984
+ }
2751
2985
  return new AnonymousObservable(function (observer) {
2752
2986
  var n = sources.length,
2753
2987
  queues = arrayInitialize(n, function () { return []; }),
@@ -2778,17 +3012,13 @@
2778
3012
  subscriptions[i].setDisposable(sources[i].subscribe(function (x) {
2779
3013
  queues[i].push(x);
2780
3014
  next(i);
2781
- }, observer.onError.bind(observer), function () {
3015
+ }, function (e) { observer.onError(e); }, function () {
2782
3016
  done(i);
2783
3017
  }));
2784
3018
  })(idx);
2785
3019
  }
2786
3020
 
2787
- var compositeDisposable = new CompositeDisposable(subscriptions);
2788
- compositeDisposable.add(disposableCreate(function () {
2789
- for (var qIdx = 0, qLen = queues.length; qIdx < qLen; qIdx++) { queues[qIdx] = []; }
2790
- }));
2791
- return compositeDisposable;
3021
+ return new CompositeDisposable(subscriptions);
2792
3022
  });
2793
3023
  };
2794
3024
 
@@ -2797,7 +3027,8 @@
2797
3027
  * @returns {Observable} An observable sequence that hides the identity of the source sequence.
2798
3028
  */
2799
3029
  observableProto.asObservable = function () {
2800
- return new AnonymousObservable(this.subscribe.bind(this), this);
3030
+ var source = this;
3031
+ return new AnonymousObservable(function (o) { return source.subscribe(o); }, this);
2801
3032
  };
2802
3033
 
2803
3034
  /**
@@ -2806,8 +3037,8 @@
2806
3037
  */
2807
3038
  observableProto.dematerialize = function () {
2808
3039
  var source = this;
2809
- return new AnonymousObservable(function (observer) {
2810
- return source.subscribe(function (x) { return x.accept(observer); }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
3040
+ return new AnonymousObservable(function (o) {
3041
+ return source.subscribe(function (x) { return x.accept(o); }, function(e) { o.onError(e); }, function () { o.onCompleted(); });
2811
3042
  }, this);
2812
3043
  };
2813
3044
 
@@ -2824,32 +3055,33 @@
2824
3055
  */
2825
3056
  observableProto.distinctUntilChanged = function (keySelector, comparer) {
2826
3057
  var source = this;
2827
- keySelector || (keySelector = identity);
2828
3058
  comparer || (comparer = defaultComparer);
2829
- return new AnonymousObservable(function (observer) {
3059
+ return new AnonymousObservable(function (o) {
2830
3060
  var hasCurrentKey = false, currentKey;
2831
3061
  return source.subscribe(function (value) {
2832
- var comparerEquals = false, key;
3062
+ var key = value;
3063
+ if (keySelector) {
2833
3064
  try {
2834
3065
  key = keySelector(value);
2835
3066
  } catch (e) {
2836
- observer.onError(e);
3067
+ o.onError(e);
2837
3068
  return;
2838
3069
  }
2839
- if (hasCurrentKey) {
2840
- try {
2841
- comparerEquals = comparer(currentKey, key);
2842
- } catch (e) {
2843
- observer.onError(e);
2844
- return;
2845
- }
2846
- }
2847
- if (!hasCurrentKey || !comparerEquals) {
2848
- hasCurrentKey = true;
2849
- currentKey = key;
2850
- observer.onNext(value);
3070
+ }
3071
+ if (hasCurrentKey) {
3072
+ try {
3073
+ var comparerEquals = comparer(currentKey, key);
3074
+ } catch (e) {
3075
+ o.onError(e);
3076
+ return;
2851
3077
  }
2852
- }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
3078
+ }
3079
+ if (!hasCurrentKey || !comparerEquals) {
3080
+ hasCurrentKey = true;
3081
+ currentKey = key;
3082
+ o.onNext(value);
3083
+ }
3084
+ }, function (e) { o.onError(e); }, function () { o.onCompleted(); });
2853
3085
  }, this);
2854
3086
  };
2855
3087
 
@@ -2861,51 +3093,36 @@
2861
3093
  * @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence. Used if only the observerOrOnNext parameter is also a function.
2862
3094
  * @returns {Observable} The source sequence with the side-effecting behavior applied.
2863
3095
  */
2864
- observableProto['do'] = observableProto.tap = function (observerOrOnNext, onError, onCompleted) {
2865
- var source = this, onNextFunc;
2866
- if (typeof observerOrOnNext === 'function') {
2867
- onNextFunc = observerOrOnNext;
2868
- } else {
2869
- onNextFunc = observerOrOnNext.onNext.bind(observerOrOnNext);
2870
- onError = observerOrOnNext.onError.bind(observerOrOnNext);
2871
- onCompleted = observerOrOnNext.onCompleted.bind(observerOrOnNext);
2872
- }
3096
+ observableProto['do'] = observableProto.tap = observableProto.doAction = function (observerOrOnNext, onError, onCompleted) {
3097
+ var source = this, tapObserver = typeof observerOrOnNext === 'function' || typeof observerOrOnNext === 'undefined'?
3098
+ observerCreate(observerOrOnNext || noop, onError || noop, onCompleted || noop) :
3099
+ observerOrOnNext;
2873
3100
  return new AnonymousObservable(function (observer) {
2874
3101
  return source.subscribe(function (x) {
2875
3102
  try {
2876
- onNextFunc(x);
3103
+ tapObserver.onNext(x);
2877
3104
  } catch (e) {
2878
3105
  observer.onError(e);
2879
3106
  }
2880
3107
  observer.onNext(x);
2881
3108
  }, function (err) {
2882
- if (onError) {
2883
3109
  try {
2884
- onError(err);
3110
+ tapObserver.onError(err);
2885
3111
  } catch (e) {
2886
3112
  observer.onError(e);
2887
3113
  }
2888
- }
2889
3114
  observer.onError(err);
2890
3115
  }, function () {
2891
- if (onCompleted) {
2892
- try {
2893
- onCompleted();
2894
- } catch (e) {
2895
- observer.onError(e);
2896
- }
3116
+ try {
3117
+ tapObserver.onCompleted();
3118
+ } catch (e) {
3119
+ observer.onError(e);
2897
3120
  }
2898
3121
  observer.onCompleted();
2899
3122
  });
2900
3123
  }, this);
2901
3124
  };
2902
3125
 
2903
- /** @deprecated use #do or #tap instead. */
2904
- observableProto.doAction = function () {
2905
- deprecate('doAction', 'do or tap');
2906
- return this.tap.apply(this, arguments);
2907
- };
2908
-
2909
3126
  /**
2910
3127
  * Invokes an action for each element in the observable sequence.
2911
3128
  * This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
@@ -2914,7 +3131,7 @@
2914
3131
  * @returns {Observable} The source sequence with the side-effecting behavior applied.
2915
3132
  */
2916
3133
  observableProto.doOnNext = observableProto.tapOnNext = function (onNext, thisArg) {
2917
- return this.tap(arguments.length === 2 ? function (x) { onNext.call(thisArg, x); } : onNext);
3134
+ return this.tap(typeof thisArg !== 'undefined' ? function (x) { onNext.call(thisArg, x); } : onNext);
2918
3135
  };
2919
3136
 
2920
3137
  /**
@@ -2925,7 +3142,7 @@
2925
3142
  * @returns {Observable} The source sequence with the side-effecting behavior applied.
2926
3143
  */
2927
3144
  observableProto.doOnError = observableProto.tapOnError = function (onError, thisArg) {
2928
- return this.tap(noop, arguments.length === 2 ? function (e) { onError.call(thisArg, e); } : onError);
3145
+ return this.tap(noop, typeof thisArg !== 'undefined' ? function (e) { onError.call(thisArg, e); } : onError);
2929
3146
  };
2930
3147
 
2931
3148
  /**
@@ -2936,7 +3153,7 @@
2936
3153
  * @returns {Observable} The source sequence with the side-effecting behavior applied.
2937
3154
  */
2938
3155
  observableProto.doOnCompleted = observableProto.tapOnCompleted = function (onCompleted, thisArg) {
2939
- return this.tap(noop, null, arguments.length === 2 ? function () { onCompleted.call(thisArg); } : onCompleted);
3156
+ return this.tap(noop, null, typeof thisArg !== 'undefined' ? function () { onCompleted.call(thisArg); } : onCompleted);
2940
3157
  };
2941
3158
 
2942
3159
  /**
@@ -2970,7 +3187,7 @@
2970
3187
  * @deprecated use #finally or #ensure instead.
2971
3188
  */
2972
3189
  observableProto.finallyAction = function (action) {
2973
- deprecate('finallyAction', 'finally or ensure');
3190
+ //deprecate('finallyAction', 'finally or ensure');
2974
3191
  return this.ensure(action);
2975
3192
  };
2976
3193
 
@@ -2980,8 +3197,8 @@
2980
3197
  */
2981
3198
  observableProto.ignoreElements = function () {
2982
3199
  var source = this;
2983
- return new AnonymousObservable(function (observer) {
2984
- return source.subscribe(noop, observer.onError.bind(observer), observer.onCompleted.bind(observer));
3200
+ return new AnonymousObservable(function (o) {
3201
+ return source.subscribe(noop, function (e) { o.onError(e); }, function () { o.onCompleted(); });
2985
3202
  }, source);
2986
3203
  };
2987
3204
 
@@ -3026,7 +3243,20 @@
3026
3243
  observableProto.retry = function (retryCount) {
3027
3244
  return enumerableRepeat(this, retryCount).catchError();
3028
3245
  };
3029
-
3246
+
3247
+ /**
3248
+ * Repeats the source observable sequence upon error each time the notifier emits or until it successfully terminates.
3249
+ * if the notifier completes, the observable sequence completes.
3250
+ *
3251
+ * @example
3252
+ * var timer = Observable.timer(500);
3253
+ * var source = observable.retryWhen(timer);
3254
+ * @param {Observable} [notifier] An observable that triggers the retries or completes the observable with onNext or onCompleted respectively.
3255
+ * @returns {Observable} An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.
3256
+ */
3257
+ observableProto.retryWhen = function (notifier) {
3258
+ return enumerableRepeat(this).catchErrorWhen(notifier);
3259
+ };
3030
3260
  /**
3031
3261
  * Applies an accumulator function over an observable sequence and returns each intermediate result. The optional seed value is used as the initial accumulator value.
3032
3262
  * For aggregation behavior with no intermediate results, see Observable.aggregate.
@@ -3046,7 +3276,7 @@
3046
3276
  } else {
3047
3277
  accumulator = arguments[0];
3048
3278
  }
3049
- return new AnonymousObservable(function (observer) {
3279
+ return new AnonymousObservable(function (o) {
3050
3280
  var hasAccumulation, accumulation, hasValue;
3051
3281
  return source.subscribe (
3052
3282
  function (x) {
@@ -3059,16 +3289,16 @@
3059
3289
  hasAccumulation = true;
3060
3290
  }
3061
3291
  } catch (e) {
3062
- observer.onError(e);
3292
+ o.onError(e);
3063
3293
  return;
3064
3294
  }
3065
3295
 
3066
- observer.onNext(accumulation);
3296
+ o.onNext(accumulation);
3067
3297
  },
3068
- observer.onError.bind(observer),
3298
+ function (e) { o.onError(e); },
3069
3299
  function () {
3070
- !hasValue && hasSeed && observer.onNext(seed);
3071
- observer.onCompleted();
3300
+ !hasValue && hasSeed && o.onNext(seed);
3301
+ o.onCompleted();
3072
3302
  }
3073
3303
  );
3074
3304
  }, source);
@@ -3084,12 +3314,12 @@
3084
3314
  */
3085
3315
  observableProto.skipLast = function (count) {
3086
3316
  var source = this;
3087
- return new AnonymousObservable(function (observer) {
3317
+ return new AnonymousObservable(function (o) {
3088
3318
  var q = [];
3089
3319
  return source.subscribe(function (x) {
3090
3320
  q.push(x);
3091
- q.length > count && observer.onNext(q.shift());
3092
- }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
3321
+ q.length > count && o.onNext(q.shift());
3322
+ }, function (e) { o.onError(e); }, function () { o.onCompleted(); });
3093
3323
  }, source);
3094
3324
  };
3095
3325
 
@@ -3109,8 +3339,8 @@
3109
3339
  } else {
3110
3340
  scheduler = immediateScheduler;
3111
3341
  }
3112
- values = slice.call(arguments, start);
3113
- return enumerableOf([observableFromArray(values, scheduler), this]).concat();
3342
+ for(var args = [], i = start, len = arguments.length; i < len; i++) { args.push(arguments[i]); }
3343
+ return enumerableOf([observableFromArray(args, scheduler), this]).concat();
3114
3344
  };
3115
3345
 
3116
3346
  /**
@@ -3123,21 +3353,22 @@
3123
3353
  */
3124
3354
  observableProto.takeLast = function (count) {
3125
3355
  var source = this;
3126
- return new AnonymousObservable(function (observer) {
3356
+ return new AnonymousObservable(function (o) {
3127
3357
  var q = [];
3128
3358
  return source.subscribe(function (x) {
3129
3359
  q.push(x);
3130
3360
  q.length > count && q.shift();
3131
- }, observer.onError.bind(observer), function () {
3132
- while (q.length > 0) { observer.onNext(q.shift()); }
3133
- observer.onCompleted();
3361
+ }, function (e) { o.onError(e); }, function () {
3362
+ while (q.length > 0) { o.onNext(q.shift()); }
3363
+ o.onCompleted();
3134
3364
  });
3135
3365
  }, source);
3136
3366
  };
3137
3367
 
3138
3368
  function concatMap(source, selector, thisArg) {
3369
+ var selectorFunc = bindCallback(selector, thisArg, 3);
3139
3370
  return source.map(function (x, i) {
3140
- var result = selector.call(thisArg, x, i, source);
3371
+ var result = selectorFunc(x, i, source);
3141
3372
  isPromise(result) && (result = observableFromPromise(result));
3142
3373
  (isArrayLike(result) || isIterable(result)) && (result = observableFrom(result));
3143
3374
  return result;
@@ -3180,42 +3411,102 @@
3180
3411
  concatMap(this, function () { return selector; });
3181
3412
  };
3182
3413
 
3414
+ var MapObservable = (function (__super__) {
3415
+ inherits(MapObservable, __super__);
3416
+
3417
+ function MapObservable(source, selector, thisArg) {
3418
+ this.source = source;
3419
+ this.selector = bindCallback(selector, thisArg, 3);
3420
+ __super__.call(this);
3421
+ }
3422
+
3423
+ MapObservable.prototype.internalMap = function (selector, thisArg) {
3424
+ var self = this;
3425
+ return new MapObservable(this.source, function (x, i, o) { return selector(self.selector(x, i, o), i, o); }, thisArg)
3426
+ };
3427
+
3428
+ MapObservable.prototype.subscribeCore = function (observer) {
3429
+ return this.source.subscribe(new MapObserver(observer, this.selector, this));
3430
+ };
3431
+
3432
+ return MapObservable;
3433
+
3434
+ }(ObservableBase));
3435
+
3436
+ function MapObserver(observer, selector, source) {
3437
+ this.observer = observer;
3438
+ this.selector = selector;
3439
+ this.source = source;
3440
+ this.i = 0;
3441
+ this.isStopped = false;
3442
+ }
3443
+
3444
+ MapObserver.prototype.onNext = function(x) {
3445
+ if (this.isStopped) { return; }
3446
+ try {
3447
+ var result = this.selector(x, this.i++, this.source);
3448
+ } catch (e) {
3449
+ return this.observer.onError(e);
3450
+ }
3451
+ this.observer.onNext(result);
3452
+ };
3453
+ MapObserver.prototype.onError = function (e) {
3454
+ if(!this.isStopped) { this.isStopped = true; this.observer.onError(e); }
3455
+ };
3456
+ MapObserver.prototype.onCompleted = function () {
3457
+ if(!this.isStopped) { this.isStopped = true; this.observer.onCompleted(); }
3458
+ };
3459
+ MapObserver.prototype.dispose = function() { this.isStopped = true; };
3460
+ MapObserver.prototype.fail = function (e) {
3461
+ if (!this.isStopped) {
3462
+ this.isStopped = true;
3463
+ this.observer.onError(e);
3464
+ return true;
3465
+ }
3466
+
3467
+ return false;
3468
+ };
3469
+
3183
3470
  /**
3184
- * Projects each element of an observable sequence into a new form by incorporating the element's index.
3185
- * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
3186
- * @param {Any} [thisArg] Object to use as this when executing callback.
3187
- * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source.
3188
- */
3189
- observableProto.select = observableProto.map = function (selector, thisArg) {
3190
- var selectorFn = isFunction(selector) ? selector : function () { return selector; },
3191
- source = this;
3192
- return new AnonymousObservable(function (observer) {
3193
- var count = 0;
3194
- return source.subscribe(function (value) {
3195
- var result;
3196
- try {
3197
- result = selectorFn.call(thisArg, value, count++, source);
3198
- } catch (e) {
3199
- observer.onError(e);
3200
- return;
3201
- }
3202
- observer.onNext(result);
3203
- }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
3204
- }, source);
3471
+ * Projects each element of an observable sequence into a new form by incorporating the element's index.
3472
+ * @param {Function} selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element.
3473
+ * @param {Any} [thisArg] Object to use as this when executing callback.
3474
+ * @returns {Observable} An observable sequence whose elements are the result of invoking the transform function on each element of source.
3475
+ */
3476
+ observableProto.map = observableProto.select = function (selector, thisArg) {
3477
+ var selectorFn = typeof selector === 'function' ? selector : function () { return selector; };
3478
+ return this instanceof MapObservable ?
3479
+ this.internalMap(selectorFn, thisArg) :
3480
+ new MapObservable(this, selectorFn, thisArg);
3205
3481
  };
3206
3482
 
3207
3483
  /**
3208
- * Retrieves the value of a specified property from all elements in the Observable sequence.
3209
- * @param {String} prop The property to pluck.
3484
+ * Retrieves the value of a specified nested property from all elements in
3485
+ * the Observable sequence.
3486
+ * @param {Arguments} arguments The nested properties to pluck.
3210
3487
  * @returns {Observable} Returns a new Observable sequence of property values.
3211
3488
  */
3212
- observableProto.pluck = function (prop) {
3213
- return this.map(function (x) { return x[prop]; });
3489
+ observableProto.pluck = function () {
3490
+ var args = arguments, len = arguments.length;
3491
+ if (len === 0) { throw new Error('List of properties cannot be empty.'); }
3492
+ return this.map(function (x) {
3493
+ var currentProp = x;
3494
+ for (var i = 0; i < len; i++) {
3495
+ var p = currentProp[args[i]];
3496
+ if (typeof p !== 'undefined') {
3497
+ currentProp = p;
3498
+ } else {
3499
+ return undefined;
3500
+ }
3501
+ }
3502
+ return currentProp;
3503
+ });
3214
3504
  };
3215
3505
 
3216
3506
  function flatMap(source, selector, thisArg) {
3507
+ var selectorFunc = bindCallback(selector, thisArg, 3);
3217
3508
  return source.map(function (x, i) {
3218
- var result = selector.call(thisArg, x, i, source);
3509
+ var result = selectorFunc(x, i, source);
3219
3510
  isPromise(result) && (result = observableFromPromise(result));
3220
3511
  (isArrayLike(result) || isIterable(result)) && (result = observableFrom(result));
3221
3512
  return result;
@@ -3278,15 +3569,15 @@
3278
3569
  observableProto.skip = function (count) {
3279
3570
  if (count < 0) { throw new Error(argumentOutOfRange); }
3280
3571
  var source = this;
3281
- return new AnonymousObservable(function (observer) {
3572
+ return new AnonymousObservable(function (o) {
3282
3573
  var remaining = count;
3283
3574
  return source.subscribe(function (x) {
3284
3575
  if (remaining <= 0) {
3285
- observer.onNext(x);
3576
+ o.onNext(x);
3286
3577
  } else {
3287
3578
  remaining--;
3288
3579
  }
3289
- }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
3580
+ }, function (e) { o.onError(e); }, function () { o.onCompleted(); });
3290
3581
  }, source);
3291
3582
  };
3292
3583
 
@@ -3301,20 +3592,21 @@
3301
3592
  * @returns {Observable} An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.
3302
3593
  */
3303
3594
  observableProto.skipWhile = function (predicate, thisArg) {
3304
- var source = this;
3305
- return new AnonymousObservable(function (observer) {
3595
+ var source = this,
3596
+ callback = bindCallback(predicate, thisArg, 3);
3597
+ return new AnonymousObservable(function (o) {
3306
3598
  var i = 0, running = false;
3307
3599
  return source.subscribe(function (x) {
3308
3600
  if (!running) {
3309
3601
  try {
3310
- running = !predicate.call(thisArg, x, i++, source);
3602
+ running = !callback(x, i++, source);
3311
3603
  } catch (e) {
3312
- observer.onError(e);
3604
+ o.onError(e);
3313
3605
  return;
3314
3606
  }
3315
3607
  }
3316
- running && observer.onNext(x);
3317
- }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
3608
+ running && o.onNext(x);
3609
+ }, function (e) { o.onError(e); }, function () { o.onCompleted(); });
3318
3610
  }, source);
3319
3611
  };
3320
3612
 
@@ -3331,14 +3623,14 @@
3331
3623
  if (count < 0) { throw new RangeError(argumentOutOfRange); }
3332
3624
  if (count === 0) { return observableEmpty(scheduler); }
3333
3625
  var source = this;
3334
- return new AnonymousObservable(function (observer) {
3626
+ return new AnonymousObservable(function (o) {
3335
3627
  var remaining = count;
3336
3628
  return source.subscribe(function (x) {
3337
3629
  if (remaining-- > 0) {
3338
- observer.onNext(x);
3339
- remaining === 0 && observer.onCompleted();
3630
+ o.onNext(x);
3631
+ remaining === 0 && o.onCompleted();
3340
3632
  }
3341
- }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
3633
+ }, function (e) { o.onError(e); }, function () { o.onCompleted(); });
3342
3634
  }, source);
3343
3635
  };
3344
3636
 
@@ -3350,52 +3642,92 @@
3350
3642
  * @returns {Observable} An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes.
3351
3643
  */
3352
3644
  observableProto.takeWhile = function (predicate, thisArg) {
3353
- var source = this;
3354
- return new AnonymousObservable(function (observer) {
3645
+ var source = this,
3646
+ callback = bindCallback(predicate, thisArg, 3);
3647
+ return new AnonymousObservable(function (o) {
3355
3648
  var i = 0, running = true;
3356
3649
  return source.subscribe(function (x) {
3357
3650
  if (running) {
3358
3651
  try {
3359
- running = predicate.call(thisArg, x, i++, source);
3652
+ running = callback(x, i++, source);
3360
3653
  } catch (e) {
3361
- observer.onError(e);
3654
+ o.onError(e);
3362
3655
  return;
3363
3656
  }
3364
3657
  if (running) {
3365
- observer.onNext(x);
3658
+ o.onNext(x);
3366
3659
  } else {
3367
- observer.onCompleted();
3660
+ o.onCompleted();
3368
3661
  }
3369
3662
  }
3370
- }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
3663
+ }, function (e) { o.onError(e); }, function () { o.onCompleted(); });
3371
3664
  }, source);
3372
3665
  };
3373
3666
 
3667
+ var FilterObservable = (function (__super__) {
3668
+ inherits(FilterObservable, __super__);
3669
+
3670
+ function FilterObservable(source, predicate, thisArg) {
3671
+ this.source = source;
3672
+ this.predicate = bindCallback(predicate, thisArg, 3);
3673
+ __super__.call(this);
3674
+ }
3675
+
3676
+ FilterObservable.prototype.subscribeCore = function (observer) {
3677
+ return this.source.subscribe(new FilterObserver(observer, this.predicate, this));
3678
+ };
3679
+
3680
+ FilterObservable.prototype.internalFilter = function(predicate, thisArg) {
3681
+ var self = this;
3682
+ return new FilterObservable(this.source, function(x, i, o) { return self.predicate(x, i, o) && predicate(x, i, o); }, thisArg);
3683
+ };
3684
+
3685
+ return FilterObservable;
3686
+
3687
+ }(ObservableBase));
3688
+
3689
+ function FilterObserver(observer, predicate, source) {
3690
+ this.observer = observer;
3691
+ this.predicate = predicate;
3692
+ this.source = source;
3693
+ this.i = 0;
3694
+ this.isStopped = false;
3695
+ }
3696
+
3697
+ FilterObserver.prototype.onNext = function(x) {
3698
+ if (this.isStopped) { return; }
3699
+ try {
3700
+ var shouldYield = this.predicate(x, this.i++, this.source);
3701
+ } catch (e) {
3702
+ return this.observer.onError(e);
3703
+ }
3704
+ shouldYield && this.observer.onNext(x);
3705
+ };
3706
+ FilterObserver.prototype.onError = function (e) {
3707
+ if(!this.isStopped) { this.isStopped = true; this.observer.onError(e); }
3708
+ };
3709
+ FilterObserver.prototype.onCompleted = function () {
3710
+ if(!this.isStopped) { this.isStopped = true; this.observer.onCompleted(); }
3711
+ };
3712
+ FilterObserver.prototype.dispose = function() { this.isStopped = true; };
3713
+ FilterObserver.prototype.fail = function (e) {
3714
+ if (!this.isStopped) {
3715
+ this.isStopped = true;
3716
+ this.observer.onError(e);
3717
+ return true;
3718
+ }
3719
+ return false;
3720
+ };
3721
+
3374
3722
  /**
3375
- * Filters the elements of an observable sequence based on a predicate by incorporating the element's index.
3376
- *
3377
- * @example
3378
- * var res = source.where(function (value) { return value < 10; });
3379
- * var res = source.where(function (value, index) { return value < 10 || index < 10; });
3380
- * @param {Function} predicate A function to test each source element for a condition; the second parameter of the function represents the index of the source element.
3381
- * @param {Any} [thisArg] Object to use as this when executing callback.
3382
- * @returns {Observable} An observable sequence that contains elements from the input sequence that satisfy the condition.
3383
- */
3384
- observableProto.where = observableProto.filter = function (predicate, thisArg) {
3385
- var source = this;
3386
- return new AnonymousObservable(function (observer) {
3387
- var count = 0;
3388
- return source.subscribe(function (value) {
3389
- var shouldRun;
3390
- try {
3391
- shouldRun = predicate.call(thisArg, value, count++, source);
3392
- } catch (e) {
3393
- observer.onError(e);
3394
- return;
3395
- }
3396
- shouldRun && observer.onNext(value);
3397
- }, observer.onError.bind(observer), observer.onCompleted.bind(observer));
3398
- }, source);
3723
+ * Filters the elements of an observable sequence based on a predicate by incorporating the element's index.
3724
+ * @param {Function} predicate A function to test each source element for a condition; the second parameter of the function represents the index of the source element.
3725
+ * @param {Any} [thisArg] Object to use as this when executing callback.
3726
+ * @returns {Observable} An observable sequence that contains elements from the input sequence that satisfy the condition.
3727
+ */
3728
+ observableProto.filter = observableProto.where = function (predicate, thisArg) {
3729
+ return this instanceof FilterObservable ? this.internalFilter(predicate, thisArg) :
3730
+ new FilterObservable(this, predicate, thisArg);
3399
3731
  };
3400
3732
 
3401
3733
  /**
@@ -3408,7 +3740,7 @@
3408
3740
  */
3409
3741
  Observable.fromCallback = function (func, context, selector) {
3410
3742
  return function () {
3411
- var args = slice.call(arguments, 0);
3743
+ for(var args = [], i = 0, len = arguments.length; i < len; i++) { args.push(arguments[i]); }
3412
3744
 
3413
3745
  return new AnonymousObservable(function (observer) {
3414
3746
  function handler() {
@@ -3418,8 +3750,7 @@
3418
3750
  try {
3419
3751
  results = selector(results);
3420
3752
  } catch (err) {
3421
- observer.onError(err);
3422
- return;
3753
+ return observer.onError(err);
3423
3754
  }
3424
3755
 
3425
3756
  observer.onNext(results);
@@ -3449,7 +3780,7 @@
3449
3780
  */
3450
3781
  Observable.fromNodeCallback = function (func, context, selector) {
3451
3782
  return function () {
3452
- var args = slice.call(arguments, 0);
3783
+ for(var args = [], i = 0, len = arguments.length; i < len; i++) { args.push(arguments[i]); }
3453
3784
 
3454
3785
  return new AnonymousObservable(function (observer) {
3455
3786
  function handler(err) {
@@ -3458,14 +3789,13 @@
3458
3789
  return;
3459
3790
  }
3460
3791
 
3461
- var results = slice.call(arguments, 1);
3792
+ for(var results = [], i = 1, len = arguments.length; i < len; i++) { results.push(arguments[i]); }
3462
3793
 
3463
3794
  if (selector) {
3464
3795
  try {
3465
3796
  results = selector(results);
3466
3797
  } catch (e) {
3467
- observer.onError(e);
3468
- return;
3798
+ return observer.onError(e);
3469
3799
  }
3470
3800
  observer.onNext(results);
3471
3801
  } else {
@@ -3515,19 +3845,6 @@
3515
3845
  */
3516
3846
  Rx.config.useNativeEvents = false;
3517
3847
 
3518
- // Check for Angular/jQuery/Zepto support
3519
- var jq =
3520
- !!root.angular && !!angular.element ? angular.element :
3521
- (!!root.jQuery ? root.jQuery : (
3522
- !!root.Zepto ? root.Zepto : null));
3523
-
3524
- // Check for ember
3525
- var ember = !!root.Ember && typeof root.Ember.addListener === 'function';
3526
-
3527
- // Check for Backbone.Marionette. Note if using AMD add Marionette as a dependency of rxjs
3528
- // for proper loading order!
3529
- var marionette = !!root.Backbone && !!root.Backbone.Marionette;
3530
-
3531
3848
  /**
3532
3849
  * Creates an observable sequence by adding an event listener to the matching DOMElement or each item in the NodeList.
3533
3850
  *
@@ -3550,25 +3867,13 @@
3550
3867
 
3551
3868
  // Use only if non-native events are allowed
3552
3869
  if (!Rx.config.useNativeEvents) {
3553
- if (marionette) {
3870
+ // Handles jq, Angular.js, Zepto, Marionette, Ember.js
3871
+ if (typeof element.on === 'function' && typeof element.off === 'function') {
3554
3872
  return fromEventPattern(
3555
3873
  function (h) { element.on(eventName, h); },
3556
3874
  function (h) { element.off(eventName, h); },
3557
3875
  selector);
3558
3876
  }
3559
- if (ember) {
3560
- return fromEventPattern(
3561
- function (h) { Ember.addListener(element, eventName, h); },
3562
- function (h) { Ember.removeListener(element, eventName, h); },
3563
- selector);
3564
- }
3565
- if (jq) {
3566
- var $elem = jq(element);
3567
- return fromEventPattern(
3568
- function (h) { $elem.on(eventName, h); },
3569
- function (h) { $elem.off(eventName, h); },
3570
- selector);
3571
- }
3572
3877
  }
3573
3878
  return new AnonymousObservable(function (observer) {
3574
3879
  return createEventListener(
@@ -3843,7 +4148,7 @@
3843
4148
  return subscription;
3844
4149
  };
3845
4150
 
3846
- __super__.call(this, subject.subscribe.bind(subject));
4151
+ __super__.call(this, function (o) { return subject.subscribe(o); });
3847
4152
  }
3848
4153
 
3849
4154
  ConnectableObservable.prototype.refCount = function () {
@@ -3873,15 +4178,15 @@
3873
4178
 
3874
4179
  function observableTimerDateAndPeriod(dueTime, period, scheduler) {
3875
4180
  return new AnonymousObservable(function (observer) {
3876
- var count = 0, d = dueTime, p = normalizeTime(period);
3877
- return scheduler.scheduleRecursiveWithAbsolute(d, function (self) {
4181
+ var d = dueTime, p = normalizeTime(period);
4182
+ return scheduler.scheduleRecursiveWithAbsoluteAndState(0, d, function (count, self) {
3878
4183
  if (p > 0) {
3879
4184
  var now = scheduler.now();
3880
4185
  d = d + p;
3881
4186
  d <= now && (d = now + p);
3882
4187
  }
3883
- observer.onNext(count++);
3884
- self(d);
4188
+ observer.onNext(count);
4189
+ self(count + 1, d);
3885
4190
  });
3886
4191
  });
3887
4192
  }
@@ -4086,7 +4391,7 @@
4086
4391
  * @deprecated use #debounce or #throttleWithTimeout instead.
4087
4392
  */
4088
4393
  observableProto.throttle = function(dueTime, scheduler) {
4089
- deprecate('throttle', 'debounce or throttleWithTimeout');
4394
+ //deprecate('throttle', 'debounce or throttleWithTimeout');
4090
4395
  return this.debounce(dueTime, scheduler);
4091
4396
  };
4092
4397
 
@@ -4218,18 +4523,16 @@
4218
4523
  var duration = +windowDuration || 0;
4219
4524
  if (duration <= 0) { throw new RangeError('windowDuration cannot be less or equal zero.'); }
4220
4525
  var source = this;
4221
- return new AnonymousObservable(function (observer) {
4526
+ return new AnonymousObservable(function (o) {
4222
4527
  var lastOnNext = 0;
4223
4528
  return source.subscribe(
4224
4529
  function (x) {
4225
4530
  var now = scheduler.now();
4226
4531
  if (lastOnNext === 0 || now - lastOnNext >= duration) {
4227
4532
  lastOnNext = now;
4228
- observer.onNext(x);
4533
+ o.onNext(x);
4229
4534
  }
4230
- },
4231
- observer.onError.bind(observer),
4232
- observer.onCompleted.bind(observer)
4535
+ },function (e) { o.onError(e); }, function () { o.onCompleted(); }
4233
4536
  );
4234
4537
  }, source);
4235
4538
  };
@@ -4293,7 +4596,7 @@
4293
4596
  };
4294
4597
 
4295
4598
  function combineLatestSource(source, subject, resultSelector) {
4296
- return new AnonymousObservable(function (observer) {
4599
+ return new AnonymousObservable(function (o) {
4297
4600
  var hasValue = [false, false],
4298
4601
  hasValueAll = false,
4299
4602
  isDone = false,
@@ -4306,20 +4609,20 @@
4306
4609
  hasValue[i] = true;
4307
4610
  if (hasValueAll || (hasValueAll = hasValue.every(identity))) {
4308
4611
  if (err) {
4309
- observer.onError(err);
4612
+ o.onError(err);
4310
4613
  return;
4311
4614
  }
4312
4615
 
4313
4616
  try {
4314
4617
  res = resultSelector.apply(null, values);
4315
4618
  } catch (ex) {
4316
- observer.onError(ex);
4619
+ o.onError(ex);
4317
4620
  return;
4318
4621
  }
4319
- observer.onNext(res);
4622
+ o.onNext(res);
4320
4623
  }
4321
4624
  if (isDone && values[1]) {
4322
- observer.onCompleted();
4625
+ o.onCompleted();
4323
4626
  }
4324
4627
  }
4325
4628
 
@@ -4330,20 +4633,20 @@
4330
4633
  },
4331
4634
  function (e) {
4332
4635
  if (values[1]) {
4333
- observer.onError(e);
4636
+ o.onError(e);
4334
4637
  } else {
4335
4638
  err = e;
4336
4639
  }
4337
4640
  },
4338
4641
  function () {
4339
4642
  isDone = true;
4340
- values[1] && observer.onCompleted();
4643
+ values[1] && o.onCompleted();
4341
4644
  }),
4342
4645
  subject.subscribe(
4343
4646
  function (x) {
4344
4647
  next(x, 1);
4345
4648
  },
4346
- observer.onError.bind(observer),
4649
+ function (e) { o.onError(e); },
4347
4650
  function () {
4348
4651
  isDone = true;
4349
4652
  next(true, 1);
@@ -4356,7 +4659,7 @@
4356
4659
 
4357
4660
  inherits(PausableBufferedObservable, __super__);
4358
4661
 
4359
- function subscribe(observer) {
4662
+ function subscribe(o) {
4360
4663
  var q = [], previousShouldFire;
4361
4664
 
4362
4665
  var subscription =
@@ -4373,14 +4676,14 @@
4373
4676
  // change in shouldFire
4374
4677
  if (results.shouldFire) {
4375
4678
  while (q.length > 0) {
4376
- observer.onNext(q.shift());
4679
+ o.onNext(q.shift());
4377
4680
  }
4378
4681
  }
4379
4682
  } else {
4380
4683
  previousShouldFire = results.shouldFire;
4381
4684
  // new data
4382
4685
  if (results.shouldFire) {
4383
- observer.onNext(results.data);
4686
+ o.onNext(results.data);
4384
4687
  } else {
4385
4688
  q.push(results.data);
4386
4689
  }
@@ -4389,16 +4692,16 @@
4389
4692
  function (err) {
4390
4693
  // Empty buffer before sending error
4391
4694
  while (q.length > 0) {
4392
- observer.onNext(q.shift());
4695
+ o.onNext(q.shift());
4393
4696
  }
4394
- observer.onError(err);
4697
+ o.onError(err);
4395
4698
  },
4396
4699
  function () {
4397
4700
  // Empty buffer before sending completion
4398
4701
  while (q.length > 0) {
4399
- observer.onNext(q.shift());
4702
+ o.onNext(q.shift());
4400
4703
  }
4401
- observer.onCompleted();
4704
+ o.onCompleted();
4402
4705
  }
4403
4706
  );
4404
4707
  return subscription;
@@ -4621,31 +4924,29 @@
4621
4924
  disposableEmpty;
4622
4925
  }
4623
4926
 
4927
+ function setDisposable(s, state) {
4928
+ var ado = state[0], subscribe = state[1];
4929
+ try {
4930
+ ado.setDisposable(fixSubscriber(subscribe(ado)));
4931
+ } catch (e) {
4932
+ if (!ado.fail(e)) { throw e; }
4933
+ }
4934
+ }
4935
+
4624
4936
  function AnonymousObservable(subscribe, parent) {
4625
4937
  this.source = parent;
4626
- if (!(this instanceof AnonymousObservable)) {
4627
- return new AnonymousObservable(subscribe);
4628
- }
4629
4938
 
4630
4939
  function s(observer) {
4631
- var setDisposable = function () {
4632
- try {
4633
- autoDetachObserver.setDisposable(fixSubscriber(subscribe(autoDetachObserver)));
4634
- } catch (e) {
4635
- if (!autoDetachObserver.fail(e)) {
4636
- throw e;
4637
- }
4638
- }
4639
- };
4640
4940
 
4641
- var autoDetachObserver = new AutoDetachObserver(observer);
4941
+ var ado = new AutoDetachObserver(observer), state = [ado, subscribe];
4942
+
4642
4943
  if (currentThreadScheduler.scheduleRequired()) {
4643
- currentThreadScheduler.schedule(setDisposable);
4944
+ currentThreadScheduler.scheduleWithState(state, setDisposable);
4644
4945
  } else {
4645
- setDisposable();
4946
+ setDisposable(null, state);
4646
4947
  }
4647
4948
 
4648
- return autoDetachObserver;
4949
+ return ado;
4649
4950
  }
4650
4951
 
4651
4952
  __super__.call(this, s);
@@ -4672,7 +4973,7 @@
4672
4973
  this.observer.onNext(value);
4673
4974
  noError = true;
4674
4975
  } catch (e) {
4675
- throw e;
4976
+ return thrower(e);
4676
4977
  } finally {
4677
4978
  !noError && this.dispose();
4678
4979
  }
@@ -4682,7 +4983,7 @@
4682
4983
  try {
4683
4984
  this.observer.onError(err);
4684
4985
  } catch (e) {
4685
- throw e;
4986
+ return thrower(e);
4686
4987
  } finally {
4687
4988
  this.dispose();
4688
4989
  }
@@ -4692,7 +4993,7 @@
4692
4993
  try {
4693
4994
  this.observer.onCompleted();
4694
4995
  } catch (e) {
4695
- throw e;
4996
+ return thrower(e);
4696
4997
  } finally {
4697
4998
  this.dispose();
4698
4999
  }
@@ -4709,130 +5010,121 @@
4709
5010
  return AutoDetachObserver;
4710
5011
  }(AbstractObserver));
4711
5012
 
4712
- /** @private */
4713
- var InnerSubscription = function (subject, observer) {
4714
- this.subject = subject;
4715
- this.observer = observer;
4716
- };
5013
+ var InnerSubscription = function (subject, observer) {
5014
+ this.subject = subject;
5015
+ this.observer = observer;
5016
+ };
4717
5017
 
4718
- /**
4719
- * @private
4720
- * @memberOf InnerSubscription
4721
- */
4722
- InnerSubscription.prototype.dispose = function () {
4723
- if (!this.subject.isDisposed && this.observer !== null) {
4724
- var idx = this.subject.observers.indexOf(this.observer);
4725
- this.subject.observers.splice(idx, 1);
4726
- this.observer = null;
4727
- }
4728
- };
5018
+ InnerSubscription.prototype.dispose = function () {
5019
+ if (!this.subject.isDisposed && this.observer !== null) {
5020
+ var idx = this.subject.observers.indexOf(this.observer);
5021
+ this.subject.observers.splice(idx, 1);
5022
+ this.observer = null;
5023
+ }
5024
+ };
5025
+
5026
+ /**
5027
+ * Represents an object that is both an observable sequence as well as an observer.
5028
+ * Each notification is broadcasted to all subscribed observers.
5029
+ */
5030
+ var Subject = Rx.Subject = (function (__super__) {
5031
+ function subscribe(observer) {
5032
+ checkDisposed(this);
5033
+ if (!this.isStopped) {
5034
+ this.observers.push(observer);
5035
+ return new InnerSubscription(this, observer);
5036
+ }
5037
+ if (this.hasError) {
5038
+ observer.onError(this.error);
5039
+ return disposableEmpty;
5040
+ }
5041
+ observer.onCompleted();
5042
+ return disposableEmpty;
5043
+ }
5044
+
5045
+ inherits(Subject, __super__);
4729
5046
 
4730
5047
  /**
4731
- * Represents an object that is both an observable sequence as well as an observer.
4732
- * Each notification is broadcasted to all subscribed observers.
5048
+ * Creates a subject.
4733
5049
  */
4734
- var Subject = Rx.Subject = (function (_super) {
4735
- function subscribe(observer) {
4736
- checkDisposed.call(this);
4737
- if (!this.isStopped) {
4738
- this.observers.push(observer);
4739
- return new InnerSubscription(this, observer);
4740
- }
4741
- if (this.exception) {
4742
- observer.onError(this.exception);
4743
- return disposableEmpty;
4744
- }
4745
- observer.onCompleted();
4746
- return disposableEmpty;
4747
- }
5050
+ function Subject() {
5051
+ __super__.call(this, subscribe);
5052
+ this.isDisposed = false,
5053
+ this.isStopped = false,
5054
+ this.observers = [];
5055
+ this.hasError = false;
5056
+ }
5057
+
5058
+ addProperties(Subject.prototype, Observer.prototype, {
5059
+ /**
5060
+ * Indicates whether the subject has observers subscribed to it.
5061
+ * @returns {Boolean} Indicates whether the subject has observers subscribed to it.
5062
+ */
5063
+ hasObservers: function () { return this.observers.length > 0; },
5064
+ /**
5065
+ * Notifies all subscribed observers about the end of the sequence.
5066
+ */
5067
+ onCompleted: function () {
5068
+ checkDisposed(this);
5069
+ if (!this.isStopped) {
5070
+ this.isStopped = true;
5071
+ for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {
5072
+ os[i].onCompleted();
5073
+ }
4748
5074
 
4749
- inherits(Subject, _super);
4750
-
4751
- /**
4752
- * Creates a subject.
4753
- * @constructor
4754
- */
4755
- function Subject() {
4756
- _super.call(this, subscribe);
4757
- this.isDisposed = false,
4758
- this.isStopped = false,
4759
- this.observers = [];
5075
+ this.observers.length = 0;
4760
5076
  }
5077
+ },
5078
+ /**
5079
+ * Notifies all subscribed observers about the exception.
5080
+ * @param {Mixed} error The exception to send to all observers.
5081
+ */
5082
+ onError: function (error) {
5083
+ checkDisposed(this);
5084
+ if (!this.isStopped) {
5085
+ this.isStopped = true;
5086
+ this.error = error;
5087
+ this.hasError = true;
5088
+ for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {
5089
+ os[i].onError(error);
5090
+ }
4761
5091
 
4762
- addProperties(Subject.prototype, Observer, {
4763
- /**
4764
- * Indicates whether the subject has observers subscribed to it.
4765
- * @returns {Boolean} Indicates whether the subject has observers subscribed to it.
4766
- */
4767
- hasObservers: function () {
4768
- return this.observers.length > 0;
4769
- },
4770
- /**
4771
- * Notifies all subscribed observers about the end of the sequence.
4772
- */
4773
- onCompleted: function () {
4774
- checkDisposed.call(this);
4775
- if (!this.isStopped) {
4776
- var os = this.observers.slice(0);
4777
- this.isStopped = true;
4778
- for (var i = 0, len = os.length; i < len; i++) {
4779
- os[i].onCompleted();
4780
- }
4781
-
4782
- this.observers = [];
4783
- }
4784
- },
4785
- /**
4786
- * Notifies all subscribed observers about the exception.
4787
- * @param {Mixed} error The exception to send to all observers.
4788
- */
4789
- onError: function (exception) {
4790
- checkDisposed.call(this);
4791
- if (!this.isStopped) {
4792
- var os = this.observers.slice(0);
4793
- this.isStopped = true;
4794
- this.exception = exception;
4795
- for (var i = 0, len = os.length; i < len; i++) {
4796
- os[i].onError(exception);
4797
- }
4798
-
4799
- this.observers = [];
4800
- }
4801
- },
4802
- /**
4803
- * Notifies all subscribed observers about the arrival of the specified element in the sequence.
4804
- * @param {Mixed} value The value to send to all observers.
4805
- */
4806
- onNext: function (value) {
4807
- checkDisposed.call(this);
4808
- if (!this.isStopped) {
4809
- var os = this.observers.slice(0);
4810
- for (var i = 0, len = os.length; i < len; i++) {
4811
- os[i].onNext(value);
4812
- }
4813
- }
4814
- },
4815
- /**
4816
- * Unsubscribe all observers and release resources.
4817
- */
4818
- dispose: function () {
4819
- this.isDisposed = true;
4820
- this.observers = null;
4821
- }
4822
- });
5092
+ this.observers.length = 0;
5093
+ }
5094
+ },
5095
+ /**
5096
+ * Notifies all subscribed observers about the arrival of the specified element in the sequence.
5097
+ * @param {Mixed} value The value to send to all observers.
5098
+ */
5099
+ onNext: function (value) {
5100
+ checkDisposed(this);
5101
+ if (!this.isStopped) {
5102
+ for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {
5103
+ os[i].onNext(value);
5104
+ }
5105
+ }
5106
+ },
5107
+ /**
5108
+ * Unsubscribe all observers and release resources.
5109
+ */
5110
+ dispose: function () {
5111
+ this.isDisposed = true;
5112
+ this.observers = null;
5113
+ }
5114
+ });
4823
5115
 
4824
- /**
4825
- * Creates a subject from the specified observer and observable.
4826
- * @param {Observer} observer The observer used to send messages to the subject.
4827
- * @param {Observable} observable The observable used to subscribe to messages sent from the subject.
4828
- * @returns {Subject} Subject implemented using the given observer and observable.
4829
- */
4830
- Subject.create = function (observer, observable) {
4831
- return new AnonymousSubject(observer, observable);
4832
- };
5116
+ /**
5117
+ * Creates a subject from the specified observer and observable.
5118
+ * @param {Observer} observer The observer used to send messages to the subject.
5119
+ * @param {Observable} observable The observable used to subscribe to messages sent from the subject.
5120
+ * @returns {Subject} Subject implemented using the given observer and observable.
5121
+ */
5122
+ Subject.create = function (observer, observable) {
5123
+ return new AnonymousSubject(observer, observable);
5124
+ };
4833
5125
 
4834
- return Subject;
4835
- }(Observable));
5126
+ return Subject;
5127
+ }(Observable));
4836
5128
 
4837
5129
  /**
4838
5130
  * Represents the result of an asynchronous operation.
@@ -4841,21 +5133,17 @@
4841
5133
  var AsyncSubject = Rx.AsyncSubject = (function (__super__) {
4842
5134
 
4843
5135
  function subscribe(observer) {
4844
- checkDisposed.call(this);
5136
+ checkDisposed(this);
4845
5137
 
4846
5138
  if (!this.isStopped) {
4847
5139
  this.observers.push(observer);
4848
5140
  return new InnerSubscription(this, observer);
4849
5141
  }
4850
5142
 
4851
- var ex = this.exception,
4852
- hv = this.hasValue,
4853
- v = this.value;
4854
-
4855
- if (ex) {
4856
- observer.onError(ex);
4857
- } else if (hv) {
4858
- observer.onNext(v);
5143
+ if (this.hasError) {
5144
+ observer.onError(this.error);
5145
+ } else if (this.hasValue) {
5146
+ observer.onNext(this.value);
4859
5147
  observer.onCompleted();
4860
5148
  } else {
4861
5149
  observer.onCompleted();
@@ -4875,10 +5163,9 @@
4875
5163
 
4876
5164
  this.isDisposed = false;
4877
5165
  this.isStopped = false;
4878
- this.value = null;
4879
5166
  this.hasValue = false;
4880
5167
  this.observers = [];
4881
- this.exception = null;
5168
+ this.hasError = false;
4882
5169
  }
4883
5170
 
4884
5171
  addProperties(AsyncSubject.prototype, Observer, {
@@ -4887,34 +5174,32 @@
4887
5174
  * @returns {Boolean} Indicates whether the subject has observers subscribed to it.
4888
5175
  */
4889
5176
  hasObservers: function () {
4890
- checkDisposed.call(this);
5177
+ checkDisposed(this);
4891
5178
  return this.observers.length > 0;
4892
5179
  },
4893
5180
  /**
4894
5181
  * Notifies all subscribed observers about the end of the sequence, also causing the last received value to be sent out (if any).
4895
5182
  */
4896
5183
  onCompleted: function () {
4897
- var o, i, len;
4898
- checkDisposed.call(this);
5184
+ var i, len;
5185
+ checkDisposed(this);
4899
5186
  if (!this.isStopped) {
4900
5187
  this.isStopped = true;
4901
- var os = this.observers.slice(0),
4902
- v = this.value,
4903
- hv = this.hasValue;
4904
-
4905
- if (hv) {
4906
- for (i = 0, len = os.length; i < len; i++) {
4907
- o = os[i];
4908
- o.onNext(v);
5188
+ var os = cloneArray(this.observers), len = os.length;
5189
+
5190
+ if (this.hasValue) {
5191
+ for (i = 0; i < len; i++) {
5192
+ var o = os[i];
5193
+ o.onNext(this.value);
4909
5194
  o.onCompleted();
4910
5195
  }
4911
5196
  } else {
4912
- for (i = 0, len = os.length; i < len; i++) {
5197
+ for (i = 0; i < len; i++) {
4913
5198
  os[i].onCompleted();
4914
5199
  }
4915
5200
  }
4916
5201
 
4917
- this.observers = [];
5202
+ this.observers.length = 0;
4918
5203
  }
4919
5204
  },
4920
5205
  /**
@@ -4922,17 +5207,17 @@
4922
5207
  * @param {Mixed} error The Error to send to all observers.
4923
5208
  */
4924
5209
  onError: function (error) {
4925
- checkDisposed.call(this);
5210
+ checkDisposed(this);
4926
5211
  if (!this.isStopped) {
4927
- var os = this.observers.slice(0);
4928
5212
  this.isStopped = true;
4929
- this.exception = error;
5213
+ this.hasError = true;
5214
+ this.error = error;
4930
5215
 
4931
- for (var i = 0, len = os.length; i < len; i++) {
5216
+ for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {
4932
5217
  os[i].onError(error);
4933
5218
  }
4934
5219
 
4935
- this.observers = [];
5220
+ this.observers.length = 0;
4936
5221
  }
4937
5222
  },
4938
5223
  /**
@@ -4940,7 +5225,7 @@
4940
5225
  * @param {Mixed} value The value to store in the subject.
4941
5226
  */
4942
5227
  onNext: function (value) {
4943
- checkDisposed.call(this);
5228
+ checkDisposed(this);
4944
5229
  if (this.isStopped) { return; }
4945
5230
  this.value = value;
4946
5231
  this.hasValue = true;
@@ -4962,18 +5247,22 @@
4962
5247
  var AnonymousSubject = Rx.AnonymousSubject = (function (__super__) {
4963
5248
  inherits(AnonymousSubject, __super__);
4964
5249
 
5250
+ function subscribe(observer) {
5251
+ return this.observable.subscribe(observer);
5252
+ }
5253
+
4965
5254
  function AnonymousSubject(observer, observable) {
4966
5255
  this.observer = observer;
4967
5256
  this.observable = observable;
4968
- __super__.call(this, this.observable.subscribe.bind(this.observable));
5257
+ __super__.call(this, subscribe);
4969
5258
  }
4970
5259
 
4971
- addProperties(AnonymousSubject.prototype, Observer, {
5260
+ addProperties(AnonymousSubject.prototype, Observer.prototype, {
4972
5261
  onCompleted: function () {
4973
5262
  this.observer.onCompleted();
4974
5263
  },
4975
- onError: function (exception) {
4976
- this.observer.onError(exception);
5264
+ onError: function (error) {
5265
+ this.observer.onError(error);
4977
5266
  },
4978
5267
  onNext: function (value) {
4979
5268
  this.observer.onNext(value);
@@ -4989,15 +5278,14 @@
4989
5278
  */
4990
5279
  var BehaviorSubject = Rx.BehaviorSubject = (function (__super__) {
4991
5280
  function subscribe(observer) {
4992
- checkDisposed.call(this);
5281
+ checkDisposed(this);
4993
5282
  if (!this.isStopped) {
4994
5283
  this.observers.push(observer);
4995
5284
  observer.onNext(this.value);
4996
5285
  return new InnerSubscription(this, observer);
4997
5286
  }
4998
- var ex = this.exception;
4999
- if (ex) {
5000
- observer.onError(ex);
5287
+ if (this.hasError) {
5288
+ observer.onError(this.error);
5001
5289
  } else {
5002
5290
  observer.onCompleted();
5003
5291
  }
@@ -5007,7 +5295,6 @@
5007
5295
  inherits(BehaviorSubject, __super__);
5008
5296
 
5009
5297
  /**
5010
- * @constructor
5011
5298
  * Initializes a new instance of the BehaviorSubject class which creates a subject that caches its last value and starts with the specified value.
5012
5299
  * @param {Mixed} value Initial value sent to observers when no other value has been received by the subject yet.
5013
5300
  */
@@ -5017,7 +5304,7 @@
5017
5304
  this.observers = [],
5018
5305
  this.isDisposed = false,
5019
5306
  this.isStopped = false,
5020
- this.exception = null;
5307
+ this.hasError = false;
5021
5308
  }
5022
5309
 
5023
5310
  addProperties(BehaviorSubject.prototype, Observer, {
@@ -5025,47 +5312,46 @@
5025
5312
  * Indicates whether the subject has observers subscribed to it.
5026
5313
  * @returns {Boolean} Indicates whether the subject has observers subscribed to it.
5027
5314
  */
5028
- hasObservers: function () {
5029
- return this.observers.length > 0;
5030
- },
5315
+ hasObservers: function () { return this.observers.length > 0; },
5031
5316
  /**
5032
5317
  * Notifies all subscribed observers about the end of the sequence.
5033
5318
  */
5034
5319
  onCompleted: function () {
5035
- checkDisposed.call(this);
5320
+ checkDisposed(this);
5036
5321
  if (this.isStopped) { return; }
5037
5322
  this.isStopped = true;
5038
- for (var i = 0, os = this.observers.slice(0), len = os.length; i < len; i++) {
5323
+ for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {
5039
5324
  os[i].onCompleted();
5040
5325
  }
5041
5326
 
5042
- this.observers = [];
5327
+ this.observers.length = 0;
5043
5328
  },
5044
5329
  /**
5045
5330
  * Notifies all subscribed observers about the exception.
5046
5331
  * @param {Mixed} error The exception to send to all observers.
5047
5332
  */
5048
5333
  onError: function (error) {
5049
- checkDisposed.call(this);
5334
+ checkDisposed(this);
5050
5335
  if (this.isStopped) { return; }
5051
5336
  this.isStopped = true;
5052
- this.exception = error;
5337
+ this.hasError = true;
5338
+ this.error = error;
5053
5339
 
5054
- for (var i = 0, os = this.observers.slice(0), len = os.length; i < len; i++) {
5340
+ for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {
5055
5341
  os[i].onError(error);
5056
5342
  }
5057
5343
 
5058
- this.observers = [];
5344
+ this.observers.length = 0;
5059
5345
  },
5060
5346
  /**
5061
5347
  * Notifies all subscribed observers about the arrival of the specified element in the sequence.
5062
5348
  * @param {Mixed} value The value to send to all observers.
5063
5349
  */
5064
5350
  onNext: function (value) {
5065
- checkDisposed.call(this);
5351
+ checkDisposed(this);
5066
5352
  if (this.isStopped) { return; }
5067
5353
  this.value = value;
5068
- for (var i = 0, os = this.observers.slice(0), len = os.length; i < len; i++) {
5354
+ for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {
5069
5355
  os[i].onNext(value);
5070
5356
  }
5071
5357
  },
@@ -5099,7 +5385,7 @@
5099
5385
  function subscribe(observer) {
5100
5386
  var so = new ScheduledObserver(this.scheduler, observer),
5101
5387
  subscription = createRemovableDisposable(this, so);
5102
- checkDisposed.call(this);
5388
+ checkDisposed(this);
5103
5389
  this._trim(this.scheduler.now());
5104
5390
  this.observers.push(so);
5105
5391
 
@@ -5138,7 +5424,7 @@
5138
5424
  __super__.call(this, subscribe);
5139
5425
  }
5140
5426
 
5141
- addProperties(ReplaySubject.prototype, Observer, {
5427
+ addProperties(ReplaySubject.prototype, Observer.prototype, {
5142
5428
  /**
5143
5429
  * Indicates whether the subject has observers subscribed to it.
5144
5430
  * @returns {Boolean} Indicates whether the subject has observers subscribed to it.
@@ -5159,15 +5445,14 @@
5159
5445
  * @param {Mixed} value The value to send to all observers.
5160
5446
  */
5161
5447
  onNext: function (value) {
5162
- checkDisposed.call(this);
5448
+ checkDisposed(this);
5163
5449
  if (this.isStopped) { return; }
5164
5450
  var now = this.scheduler.now();
5165
5451
  this.q.push({ interval: now, value: value });
5166
5452
  this._trim(now);
5167
5453
 
5168
- var o = this.observers.slice(0);
5169
- for (var i = 0, len = o.length; i < len; i++) {
5170
- var observer = o[i];
5454
+ for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {
5455
+ var observer = os[i];
5171
5456
  observer.onNext(value);
5172
5457
  observer.ensureActive();
5173
5458
  }
@@ -5177,37 +5462,35 @@
5177
5462
  * @param {Mixed} error The exception to send to all observers.
5178
5463
  */
5179
5464
  onError: function (error) {
5180
- checkDisposed.call(this);
5465
+ checkDisposed(this);
5181
5466
  if (this.isStopped) { return; }
5182
5467
  this.isStopped = true;
5183
5468
  this.error = error;
5184
5469
  this.hasError = true;
5185
5470
  var now = this.scheduler.now();
5186
5471
  this._trim(now);
5187
- var o = this.observers.slice(0);
5188
- for (var i = 0, len = o.length; i < len; i++) {
5189
- var observer = o[i];
5472
+ for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {
5473
+ var observer = os[i];
5190
5474
  observer.onError(error);
5191
5475
  observer.ensureActive();
5192
5476
  }
5193
- this.observers = [];
5477
+ this.observers.length = 0;
5194
5478
  },
5195
5479
  /**
5196
5480
  * Notifies all subscribed observers about the end of the sequence.
5197
5481
  */
5198
5482
  onCompleted: function () {
5199
- checkDisposed.call(this);
5483
+ checkDisposed(this);
5200
5484
  if (this.isStopped) { return; }
5201
5485
  this.isStopped = true;
5202
5486
  var now = this.scheduler.now();
5203
5487
  this._trim(now);
5204
- var o = this.observers.slice(0);
5205
- for (var i = 0, len = o.length; i < len; i++) {
5206
- var observer = o[i];
5488
+ for (var i = 0, os = cloneArray(this.observers), len = os.length; i < len; i++) {
5489
+ var observer = os[i];
5207
5490
  observer.onCompleted();
5208
5491
  observer.ensureActive();
5209
5492
  }
5210
- this.observers = [];
5493
+ this.observers.length = 0;
5211
5494
  },
5212
5495
  /**
5213
5496
  * Unsubscribe all observers and release resources.
@@ -5221,23 +5504,46 @@
5221
5504
  return ReplaySubject;
5222
5505
  }(Observable));
5223
5506
 
5224
- if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
5225
- root.Rx = Rx;
5507
+ /**
5508
+ * Used to pause and resume streams.
5509
+ */
5510
+ Rx.Pauser = (function (__super__) {
5511
+ inherits(Pauser, __super__);
5226
5512
 
5227
- define(function() {
5228
- return Rx;
5229
- });
5230
- } else if (freeExports && freeModule) {
5231
- // in Node.js or RingoJS
5232
- if (moduleExports) {
5233
- (freeModule.exports = Rx).Rx = Rx;
5234
- } else {
5235
- freeExports.Rx = Rx;
5236
- }
5513
+ function Pauser() {
5514
+ __super__.call(this);
5515
+ }
5516
+
5517
+ /**
5518
+ * Pauses the underlying sequence.
5519
+ */
5520
+ Pauser.prototype.pause = function () { this.onNext(false); };
5521
+
5522
+ /**
5523
+ * Resumes the underlying sequence.
5524
+ */
5525
+ Pauser.prototype.resume = function () { this.onNext(true); };
5526
+
5527
+ return Pauser;
5528
+ }(Subject));
5529
+
5530
+ if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
5531
+ root.Rx = Rx;
5532
+
5533
+ define(function() {
5534
+ return Rx;
5535
+ });
5536
+ } else if (freeExports && freeModule) {
5537
+ // in Node.js or RingoJS
5538
+ if (moduleExports) {
5539
+ (freeModule.exports = Rx).Rx = Rx;
5237
5540
  } else {
5238
- // in a browser or Rhino
5239
- root.Rx = Rx;
5541
+ freeExports.Rx = Rx;
5240
5542
  }
5543
+ } else {
5544
+ // in a browser or Rhino
5545
+ root.Rx = Rx;
5546
+ }
5241
5547
 
5242
5548
  // All code before this point will be filtered from stack traces.
5243
5549
  var rEndingLine = captureLine();