3 lines
3.1 KiB
JavaScript
3 lines
3.1 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"],function(b,c){return a(j,c,b)}):"object"==typeof module&&module&&module.exports===d?module.exports=a(j,module.exports,require("./rx")):j.Rx=a(j,{},j.Rx)}).call(this,function(a,b,c,d){var e=c.Scheduler,f=c.internals.ScheduledItem,g=c.internals.SchedulePeriodicRecursive,h=c.internals.PriorityQueue,i=c.internals.inherits,j=c.helpers.defaultSubComparer,k=c.helpers.notImplemented;c.VirtualTimeScheduler=function(a){function b(b,c){this.clock=b,this.comparer=c,this.isEnabled=!1,this.queue=new h(1024),a.call(this)}i(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=k,c.toAbsoluteTime=k,c.toRelativeTime=k,c.schedulePeriodic=function(a,b,c){var d=new g(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(g),c(a,b)}var e=this,g=new f(this,a,d,b,this.comparer);return this.queue.enqueue(g),g.disposable},b}(e);return c.HistoricalScheduler=function(a){function b(b,c){var d=null==b?0:b,e=c||j;a.call(this,d,e)}i(b,a);var c=b.prototype;return c.add=function(a,b){return a+b},c.toAbsoluteTime=function(a){return new Date(a).getTime()},c.toRelativeTime=function(a){return a},b}(c.VirtualTimeScheduler),c});
|
||
|
//# sourceMappingURL=rx.virtualtime.map
|