3 lines
14 KiB
JavaScript
3 lines
14 KiB
JavaScript
/* Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.*/
|
|
(function(a){function b(a){return a&&a.Object===Object?a:null}var c={"function":!0,object:!0},d=c[typeof exports]&&exports&&!exports.nodeType?exports:null,e=c[typeof module]&&module&&!module.nodeType?module:null,f=b(d&&e&&"object"==typeof global&&global),g=b(c[typeof self]&&self),h=b(c[typeof window]&&window),i=(e&&e.exports===d?d:null,b(c[typeof this]&&this)),j=f||h!==(i&&i.window)&&h||g||i||Function("return this")();"function"==typeof define&&define.amd?define(["./rx.core"],function(b,c){return a(j,c,b)}):"object"==typeof module&&module&&module.exports===d?module.exports=a(j,module.exports,require("./rx.core")):j.Rx=a(j,{},j.Rx)}).call(this,function(a,b,c,d){function e(a,b,c,e,f,g){var h=ja(a),i=h.length,j=ja(b),k=j.length;if(i!==k&&!e)return!1;for(var l,m=i;m--;)if(l=h[m],!(e?l in b:ga.call(b,l)))return!1;for(var n=e;++m<i;){l=h[m];var o,p=a[l],q=b[l];if(!(o===d?c(p,q,e,f,g):o))return!1;n||(n="constructor"===l)}if(!n){var r=a.constructor,s=b.constructor;if(r!==s&&"constructor"in a&&"constructor"in b&&!("function"==typeof r&&r instanceof r&&"function"==typeof s&&s instanceof s))return!1}return!0}function f(a,b,c){switch(c){case L:case M:return+a===+b;case N:return a.name===b.name&&a.message===b.message;case Q:return a!==+a?b!==+b:a===+b;case S:case U:return a===b+""}return!1}function g(a){return!!a&&"object"==typeof a}function h(a){return"number"==typeof a&&a>-1&&a%1===0&&ia>=a}function i(a){return g(a)&&h(a.length)&&!!ea[ha.call(a)]}function j(a,b){for(var c=-1,d=a.length;++c<d;)if(b(a[c],c,a))return!0;return!1}function k(a,b,c,e,f,g){var h=-1,i=a.length,k=b.length;if(i!==k&&!(e&&k>i))return!1;for(;++h<i;){var l,m=a[h],n=b[h];if(l!==d){if(l)continue;return!1}if(e){if(!j(b,function(a){return m===a||c(m,a,e,f,g)}))return!1}else if(m!==n&&!c(m,n,e,f,g))return!1}return!0}function l(a,b,c,d,g,h){var j=ma(a),l=ma(b),m=K,n=K;j||(m=ha.call(a),m===J?m=R:m!==R&&(j=i(a))),l||(n=ha.call(b),n===J&&(n=R));var o=m===R&&!la(a),p=n===R&&!la(b),q=m===n;if(q&&!j&&!o)return f(a,b,m);if(!d){var r=o&&ga.call(a,"__wrapped__"),s=p&&ga.call(b,"__wrapped__");if(r||s)return c(r?a.value():a,s?b.value():b,d,g,h)}if(!q)return!1;g||(g=[]),h||(h=[]);for(var t=g.length;t--;)if(g[t]===a)return h[t]===b;g.push(a),h.push(b);var u=(j?k:e)(a,b,c,d,g,h);return g.pop(),h.pop(),u}function m(a,b,c,d,e){return a===b?!0:null==a||null==b||!ka(a)&&!g(b)?a!==a&&b!==b:l(a,b,m,c,d,e)}function n(a){this.predicate=a}function o(a){this.predicate=a}function p(a,b){var c=this;this.scheduler=a,this.messages=b,this.subscriptions=[],this.observers=[];for(var d=0,e=this.messages.length;e>d;d++){var f=this.messages[d],g=f.value;!function(b){a.scheduleAbsolute(null,f.time,function(){for(var a=c.observers.slice(0),d=0,e=a.length;e>d;d++)b.accept(a[d]);return t})}(g)}}var q=c.Observer,r=c.Observable,s=c.Disposable,t=s.empty,u=s.create,v=c.CompositeDisposable,w=c.SingleAssignmentDisposable,x=c.Scheduler,y=c.internals.ScheduledItem,z=c.internals.SchedulePeriodicRecursive,A=c.internals.PriorityQueue,B=c.internals.inherits,C=c.helpers.notImplemented,D=c.helpers.defaultComparer=function(a,b){return na(a,b)},E=c.Notification=function(){function a(){}return a.prototype._accept=function(a,b,c){throw new NotImplementedError},a.prototype._acceptObserver=function(a,b,c){throw new NotImplementedError},a.prototype.accept=function(a,b,c){return a&&"object"==typeof a?this._acceptObserver(a):this._accept(a,b,c)},a.prototype.toObservable=function(a){var b=this;return isScheduler(a)||(a=immediateScheduler),new AnonymousObservable(function(c){return a.schedule(b,function(a,b){b._acceptObserver(c),"N"===b.kind&&c.onCompleted()})})},a}(),F=function(a){function b(a){this.value=a,this.kind="N"}return B(b,a),b.prototype._accept=function(a){return a(this.value)},b.prototype._acceptObserver=function(a){return a.onNext(this.value)},b.prototype.toString=function(){return"OnNext("+this.value+")"},b}(E),G=function(a){function b(a){this.error=a,this.kind="E"}return B(b,a),b.prototype._accept=function(a,b){return b(this.error)},b.prototype._acceptObserver=function(a){return a.onError(this.error)},b.prototype.toString=function(){return"OnError("+this.error+")"},b}(E),H=function(a){function b(){this.kind="C"}return B(b,a),b.prototype._accept=function(a,b,c){return c()},b.prototype._acceptObserver=function(a){return a.onCompleted()},b.prototype.toString=function(){return"OnCompleted()"},b}(E),I=(E.createOnNext=function(a){return new F(a)},E.createOnError=function(a){return new G(a)},E.createOnCompleted=function(){return new H},["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"]),J=(I.length,"[object Arguments]"),K="[object Array]",L="[object Boolean]",M="[object Date]",N="[object Error]",O="[object Function]",P="[object Map]",Q="[object Number]",R="[object Object]",S="[object RegExp]",T="[object Set]",U="[object String]",V="[object WeakMap]",W="[object ArrayBuffer]",X="[object Float32Array]",Y="[object Float64Array]",Z="[object Int8Array]",$="[object Int16Array]",_="[object Int32Array]",aa="[object Uint8Array]",ba="[object Uint8ClampedArray]",ca="[object Uint16Array]",da="[object Uint32Array]",ea={};ea[X]=ea[Y]=ea[Z]=ea[$]=ea[_]=ea[aa]=ea[ba]=ea[ca]=ea[da]=!0,ea[J]=ea[K]=ea[W]=ea[L]=ea[M]=ea[N]=ea[O]=ea[P]=ea[Q]=ea[R]=ea[S]=ea[T]=ea[U]=ea[V]=!1;var fa=Object.prototype,ga=fa.hasOwnProperty,ha=fa.toString,ia=Math.pow(2,53)-1,ja=Object.keys||function(){var a=Object.prototype.hasOwnProperty,b=!{toString:null}.propertyIsEnumerable("toString"),c=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],d=c.length;return function(e){if("object"!=typeof e&&("function"!=typeof e||null===e))throw new TypeError("Object.keys called on non-object");var f,g,h=[];for(f in e)a.call(e,f)&&h.push(f);if(b)for(g=0;d>g;g++)a.call(e,c[g])&&h.push(c[g]);return h}}(),ka=c.internals.isObject=function(a){var b=typeof a;return!!a&&("object"===b||"function"===b)},la=function(){try{Object({toString:0}+"")}catch(a){return function(){return!1}}return function(a){return"function"!=typeof a.toString&&"string"==typeof(a+"")}}(),ma=Array.isArray||function(a){return g(a)&&h(a.length)&&ha.call(a)===K},na=c.internals.isEqual=function(a,b){return m(a,b)},z=c.internals.SchedulePeriodicRecursive=function(){function a(a){return function(b,c){c(0,a._period);var d=tryCatch(a._action)(a._state);d===errorObj&&(a._cancel.dispose(),thrower(d.e)),a._state=d}}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 w;return this._cancel=b,b.setDisposable(this._scheduler.scheduleRecursiveFuture(0,this._period,a(this))),b},b}(),oa=c.VirtualTimeScheduler=function(a){function b(b,c){this.clock=b,this.comparer=c,this.isEnabled=!1,this.queue=new A(1024),a.call(this)}B(b,a);var c=b.prototype;return c.now=function(){return this.toAbsoluteTime(this.clock)},c.schedule=function(a,b){return this.scheduleAbsolute(a,this.clock,b)},c.scheduleFuture=function(a,b,c){var d=b instanceof Date?this.toRelativeTime(b-this.now()):this.toRelativeTime(b);return this.scheduleRelative(a,d,c)},c.add=C,c.toAbsoluteTime=C,c.toRelativeTime=C,c.schedulePeriodic=function(a,b,c){var d=new z(this,a,b,c);return d.start()},c.scheduleRelative=function(a,b,c){var d=this.add(this.clock,b);return this.scheduleAbsolute(a,d,c)},c.start=function(){if(!this.isEnabled){this.isEnabled=!0;do{var a=this.getNext();null!==a?(this.comparer(a.dueTime,this.clock)>0&&(this.clock=a.dueTime),a.invoke()):this.isEnabled=!1}while(this.isEnabled)}},c.stop=function(){this.isEnabled=!1},c.advanceTo=function(a){var b=this.comparer(this.clock,a);if(this.comparer(this.clock,a)>0)throw new ArgumentOutOfRangeError;if(0!==b&&!this.isEnabled){this.isEnabled=!0;do{var c=this.getNext();null!==c&&this.comparer(c.dueTime,a)<=0?(this.comparer(c.dueTime,this.clock)>0&&(this.clock=c.dueTime),c.invoke()):this.isEnabled=!1}while(this.isEnabled);this.clock=a}},c.advanceBy=function(a){var b=this.add(this.clock,a),c=this.comparer(this.clock,b);if(c>0)throw new ArgumentOutOfRangeError;0!==c&&this.advanceTo(b)},c.sleep=function(a){var b=this.add(this.clock,a);if(this.comparer(this.clock,b)>=0)throw new ArgumentOutOfRangeError;this.clock=b},c.getNext=function(){for(;this.queue.length>0;){var a=this.queue.peek();if(!a.isCancelled())return a;this.queue.dequeue()}return null},c.scheduleAbsolute=function(a,b,c){function d(a,b){return e.queue.remove(f),c(a,b)}var e=this,f=new y(this,a,d,b,this.comparer);return this.queue.enqueue(f),f.disposable},b}(x);n.prototype.equals=function(a){return a===this?!0:null==a?!1:"N"!==a.kind?!1:this.predicate(a.value)},o.prototype.equals=function(a){return a===this?!0:null==a?!1:"E"!==a.kind?!1:this.predicate(a.error)};var pa=c.ReactiveTest={created:100,subscribed:200,disposed:1e3,onNext:function(a,b){return"function"==typeof b?new qa(a,new n(b)):new qa(a,E.createOnNext(b))},onError:function(a,b){return"function"==typeof b?new qa(a,new o(b)):new qa(a,E.createOnError(b))},onCompleted:function(a){return new qa(a,E.createOnCompleted())},subscribe:function(a,b){return new ra(a,b)}},qa=c.Recorded=function(a,b,c){this.time=a,this.value=b,this.comparer=c||D};qa.prototype.equals=function(a){return this.time===a.time&&this.comparer(this.value,a.value)},qa.prototype.toString=function(){return this.value.toString()+"@"+this.time};var ra=c.Subscription=function(a,b){this.subscribe=a,this.unsubscribe=b||Number.MAX_VALUE};ra.prototype.equals=function(a){return this.subscribe===a.subscribe&&this.unsubscribe===a.unsubscribe},ra.prototype.toString=function(){return"("+this.subscribe+", "+(this.unsubscribe===Number.MAX_VALUE?"Infinite":this.unsubscribe)+")"};var sa=c.MockDisposable=function(a){this.scheduler=a,this.disposes=[],this.disposes.push(this.scheduler.clock)};sa.prototype.dispose=function(){this.disposes.push(this.scheduler.clock)};var ta=function(a){function b(b){a.call(this),this.scheduler=b,this.messages=[]}B(b,a);var c=b.prototype;return c.onNext=function(a){this.messages.push(new qa(this.scheduler.clock,E.createOnNext(a)))},c.onError=function(a){this.messages.push(new qa(this.scheduler.clock,E.createOnError(a)))},c.onCompleted=function(){this.messages.push(new qa(this.scheduler.clock,E.createOnCompleted()))},b}(q);p.prototype.then=function(a,b){var e=this;this.subscriptions.push(new ra(this.scheduler.clock));var f,g=this.subscriptions.length-1,h=c.Observer.create(function(b){var i=a(b);if(i&&"function"==typeof i.then)f=i;else{var j=e.scheduler.clock;f=new p(e.scheduler,[c.ReactiveTest.onNext(j,d),c.ReactiveTest.onCompleted(j)])}var k=e.observers.indexOf(h);e.observers.splice(k,1),e.subscriptions[g]=new ra(e.subscriptions[g].subscribe,e.scheduler.clock)},function(a){b(a);var c=e.observers.indexOf(h);e.observers.splice(c,1),e.subscriptions[g]=new ra(e.subscriptions[g].subscribe,e.scheduler.clock)});return this.observers.push(h),f||new p(this.scheduler,this.messages)};var ua=function(a){function b(b,c){a.call(this);var d,e,f=this;this.scheduler=b,this.messages=c,this.subscriptions=[],this.observers=[];for(var g=0,h=this.messages.length;h>g;g++)d=this.messages[g],e=d.value,function(a){b.scheduleAbsolute(null,d.time,function(){for(var b=f.observers.slice(0),c=0,d=b.length;d>c;c++)a.accept(b[c]);return t})}(e)}return B(b,a),b.prototype._subscribe=function(a){var b=this;this.observers.push(a),this.subscriptions.push(new ra(this.scheduler.clock));var c=this.subscriptions.length-1;return u(function(){var d=b.observers.indexOf(a);b.observers.splice(d,1),b.subscriptions[c]=new ra(b.subscriptions[c].subscribe,b.scheduler.clock)})},b}(r),va=function(a){function b(b,c){a.call(this),this.scheduler=b,this.messages=c,this.subscriptions=[]}return B(b,a),b.prototype._subscribe=function(a){var b,c,d=this;this.subscriptions.push(new ra(this.scheduler.clock));for(var e=this.subscriptions.length-1,f=new v,g=0,h=this.messages.length;h>g;g++)b=this.messages[g],c=b.value,function(c){f.add(d.scheduler.scheduleRelative(null,b.time,function(){return c.accept(a),t}))}(c);return u(function(){d.subscriptions[e]=new ra(d.subscriptions[e].subscribe,d.scheduler.clock),f.dispose()})},b}(r);return c.TestScheduler=function(a){function b(a,b){return a>b?1:b>a?-1:0}function d(){a.call(this,0,b)}return B(d,a),d.prototype.scheduleAbsolute=function(b,c,d){return c<=this.clock&&(c=this.clock+1),a.prototype.scheduleAbsolute.call(this,b,c,d)},d.prototype.add=function(a,b){return a+b},d.prototype.toAbsoluteTime=function(a){return new Date(a).getTime()},d.prototype.toRelativeTime=function(a){return a},d.prototype.startScheduler=function(a,b){b||(b={}),null==b.created&&(b.created=pa.created),null==b.subscribed&&(b.subscribed=pa.subscribed),null==b.disposed&&(b.disposed=pa.disposed);var c,d,e=this.createObserver();return this.scheduleAbsolute(null,b.created,function(){return c=a(),t}),this.scheduleAbsolute(null,b.subscribed,function(){return d=c.subscribe(e),t}),this.scheduleAbsolute(null,b.disposed,function(){return d.dispose(),t}),this.start(),e},d.prototype.createHotObservable=function(){var a,b=arguments.length;if(Array.isArray(arguments[0]))a=arguments[0];else{a=new Array(b);for(var c=0;b>c;c++)a[c]=arguments[c]}return new ua(this,a)},d.prototype.createColdObservable=function(){var a,b=arguments.length;if(Array.isArray(arguments[0]))a=arguments[0];else{a=new Array(b);for(var c=0;b>c;c++)a[c]=arguments[c]}return new va(this,a)},d.prototype.createResolvedPromise=function(a,b){return new p(this,[c.ReactiveTest.onNext(a,b),c.ReactiveTest.onCompleted(a)])},d.prototype.createRejectedPromise=function(a,b){return new p(this,[c.ReactiveTest.onError(a,b)])},d.prototype.createObserver=function(){return new ta(this)},d}(oa),c});
|
|
//# sourceMappingURL=rx.core.testing.map
|