UNPKG

webappengine

Version:

A web application platform that can host multiple web apps running with Node.js.

3 lines 4.6 kB
/* Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.*/ (function(a){var b={"function":!0,object:!0},c=b[typeof exports]&&exports&&!exports.nodeType&&exports,d=b[typeof self]&&self.Object&&self,e=b[typeof window]&&window&&window.Object&&window,f=b[typeof module]&&module&&!module.nodeType&&module,g=(f&&f.exports===c&&c,c&&f&&"object"==typeof global&&global&&global.Object&&global),h=h=g||e!==(this&&this.window)&&e||d||this;"function"==typeof define&&define.amd?define(["rx"],function(b,c){return a(h,c,b)}):"object"==typeof module&&module&&module.exports===c?module.exports=a(h,module.exports,require("./rx")):h.Rx=a(h,{},h.Rx)}).call(this,function(a,b,c,d){function e(a,b){this.id=a,this.value=b}var f=c.Scheduler,g=c.internals.ScheduledItem,h=c.internals.SchedulePeriodicRecursive,i=c.Disposable.empty,j=c.internals.inherits,k=c.helpers.defaultSubComparer,l=c.helpers.notImplemented;e.prototype.compareTo=function(a){var b=this.value.compareTo(a.value);return 0===b&&(b=this.id-a.id),b};var m=c.internals.PriorityQueue=function(a){this.items=new Array(a),this.length=0},n=m.prototype;n.isHigherPriority=function(a,b){return this.items[a].compareTo(this.items[b])<0},n.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)}}},n.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)}}},n.peek=function(){return this.items[0].value},n.removeAt=function(a){this.items[a]=this.items[--this.length],this.items[this.length]=d,this.heapify()},n.dequeue=function(){var a=this.peek();return this.removeAt(0),a},n.enqueue=function(a){var b=this.length++;this.items[b]=new e(m.count++,a),this.percolate(b)},n.remove=function(a){for(var b=0;b<this.length;b++)if(this.items[b].value===a)return this.removeAt(b),!0;return!1},m.count=0;c.VirtualTimeScheduler=function(a){function b(){return this.toDateTimeOffset(this.clock)}function c(a,b){return this.scheduleAbsoluteWithState(a,this.clock,b)}function d(a,b,c){return this.scheduleRelativeWithState(a,this.toRelative(b),c)}function e(a,b,c){return this.scheduleRelativeWithState(a,this.toRelative(b-this.now()),c)}function f(a,b){return b(),i}function k(f,g){this.clock=f,this.comparer=g,this.isEnabled=!1,this.queue=new m(1024),a.call(this,b,c,d,e)}j(k,a);var n=k.prototype;return n.add=l,n.toDateTimeOffset=l,n.toRelative=l,n.schedulePeriodicWithState=function(a,b,c){var d=new h(this,a,b,c);return d.start()},n.scheduleRelativeWithState=function(a,b,c){var d=this.add(this.clock,b);return this.scheduleAbsoluteWithState(a,d,c)},n.scheduleRelative=function(a,b){return this.scheduleRelativeWithState(b,a,f)},n.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)}},n.stop=function(){this.isEnabled=!1},n.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}},n.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)},n.sleep=function(a){var b=this.add(this.clock,a);if(this.comparer(this.clock,b)>=0)throw new ArgumentOutOfRangeError;this.clock=b},n.getNext=function(){for(;this.queue.length>0;){var a=this.queue.peek();if(!a.isCancelled())return a;this.queue.dequeue()}return null},n.scheduleAbsolute=function(a,b){return this.scheduleAbsoluteWithState(b,a,f)},n.scheduleAbsoluteWithState=function(a,b,c){function d(a,b){return e.queue.remove(f),c(a,b)}var e=this,f=new g(this,a,d,b,this.comparer);return this.queue.enqueue(f),f.disposable},k}(f);return c.HistoricalScheduler=function(a){function b(b,c){var d=null==b?0:b,e=c||k;a.call(this,d,e)}j(b,a);var c=b.prototype;return c.add=function(a,b){return a+b},c.toDateTimeOffset=function(a){return new Date(a).getTime()},c.toRelative=function(a){return a},b}(c.VirtualTimeScheduler),c}); //# sourceMappingURL=rx.virtualtime.map