@most/scheduler
Advanced tools
Comparing version 0.9.0 to 0.9.1
/** @license MIT License (c) copyright 2010-2016 original author or authors */ | ||
// Non-mutating array operations | ||
// Non-mutating array operations | ||
// cons :: a -> [a] -> [a] | ||
// a with x prepended | ||
// removeAll :: (a -> boolean) -> [a] -> [a] | ||
// remove all elements matching a predicate | ||
function removeAll (f, a) { | ||
var l = a.length; | ||
var b = new Array(l); | ||
var j = 0; | ||
for (var x, i = 0; i < l; ++i) { | ||
x = a[i]; | ||
if (!f(x)) { | ||
b[j] = x; | ||
++j; | ||
} | ||
// cons :: a -> [a] -> [a] | ||
// a with x prepended | ||
// removeAll :: (a -> boolean) -> [a] -> [a] | ||
// remove all elements matching a predicate | ||
function removeAll (f, a) { | ||
var l = a.length; | ||
var b = new Array(l); | ||
var j = 0; | ||
for (var x = (void 0), i = 0; i < l; ++i) { | ||
x = a[i]; | ||
if (!f(x)) { | ||
b[j] = x; | ||
++j; | ||
} | ||
b.length = j; | ||
return b | ||
} | ||
// findIndex :: a -> [a] -> Int | ||
// find index of x in a, from the left | ||
function findIndex (x, a) { | ||
for (var i = 0, l = a.length; i < l; ++i) { | ||
if (x === a[i]) { | ||
return i | ||
} | ||
b.length = j; | ||
return b | ||
} | ||
// findIndex :: a -> [a] -> Int | ||
// find index of x in a, from the left | ||
function findIndex (x, a) { | ||
for (var i = 0, l = a.length; i < l; ++i) { | ||
if (x === a[i]) { | ||
return i | ||
} | ||
return -1 | ||
} | ||
return -1 | ||
} | ||
// curry2 :: ((a, b) -> c) -> (a -> b -> c) | ||
function curry2 (f) { | ||
function curried (a, b) { | ||
switch (arguments.length) { | ||
case 0: return curried | ||
case 1: return function (b) { return f(a, b); } | ||
default: return f(a, b) | ||
} | ||
// curry2 :: ((a, b) -> c) -> (a -> b -> c) | ||
function curry2 (f) { | ||
function curried (a, b) { | ||
switch (arguments.length) { | ||
case 0: return curried | ||
case 1: return function (b) { return f(a, b); } | ||
default: return f(a, b) | ||
} | ||
return curried | ||
} | ||
return curried | ||
} | ||
// curry3 :: ((a, b, c) -> d) -> (a -> b -> c -> d) | ||
function curry3 (f) { | ||
function curried (a, b, c) { // eslint-disable-line complexity | ||
switch (arguments.length) { | ||
case 0: return curried | ||
case 1: return curry2(function (b, c) { return f(a, b, c); }) | ||
case 2: return function (c) { return f(a, b, c); } | ||
default:return f(a, b, c) | ||
} | ||
// curry3 :: ((a, b, c) -> d) -> (a -> b -> c -> d) | ||
function curry3 (f) { | ||
function curried (a, b, c) { // eslint-disable-line complexity | ||
switch (arguments.length) { | ||
case 0: return curried | ||
case 1: return curry2(function (b, c) { return f(a, b, c); }) | ||
case 2: return function (c) { return f(a, b, c); } | ||
default:return f(a, b, c) | ||
} | ||
return curried | ||
} | ||
return curried | ||
} | ||
@@ -61,0 +61,0 @@ /** @license MIT License (c) copyright 2010-2017 original author or authors */ |
@@ -9,59 +9,59 @@ (function (global, factory) { | ||
// Non-mutating array operations | ||
// Non-mutating array operations | ||
// cons :: a -> [a] -> [a] | ||
// a with x prepended | ||
// removeAll :: (a -> boolean) -> [a] -> [a] | ||
// remove all elements matching a predicate | ||
function removeAll (f, a) { | ||
var l = a.length; | ||
var b = new Array(l); | ||
var j = 0; | ||
for (var x, i = 0; i < l; ++i) { | ||
x = a[i]; | ||
if (!f(x)) { | ||
b[j] = x; | ||
++j; | ||
} | ||
// cons :: a -> [a] -> [a] | ||
// a with x prepended | ||
// removeAll :: (a -> boolean) -> [a] -> [a] | ||
// remove all elements matching a predicate | ||
function removeAll (f, a) { | ||
var l = a.length; | ||
var b = new Array(l); | ||
var j = 0; | ||
for (var x = (void 0), i = 0; i < l; ++i) { | ||
x = a[i]; | ||
if (!f(x)) { | ||
b[j] = x; | ||
++j; | ||
} | ||
b.length = j; | ||
return b | ||
} | ||
// findIndex :: a -> [a] -> Int | ||
// find index of x in a, from the left | ||
function findIndex (x, a) { | ||
for (var i = 0, l = a.length; i < l; ++i) { | ||
if (x === a[i]) { | ||
return i | ||
} | ||
b.length = j; | ||
return b | ||
} | ||
// findIndex :: a -> [a] -> Int | ||
// find index of x in a, from the left | ||
function findIndex (x, a) { | ||
for (var i = 0, l = a.length; i < l; ++i) { | ||
if (x === a[i]) { | ||
return i | ||
} | ||
return -1 | ||
} | ||
return -1 | ||
} | ||
// curry2 :: ((a, b) -> c) -> (a -> b -> c) | ||
function curry2 (f) { | ||
function curried (a, b) { | ||
switch (arguments.length) { | ||
case 0: return curried | ||
case 1: return function (b) { return f(a, b); } | ||
default: return f(a, b) | ||
} | ||
// curry2 :: ((a, b) -> c) -> (a -> b -> c) | ||
function curry2 (f) { | ||
function curried (a, b) { | ||
switch (arguments.length) { | ||
case 0: return curried | ||
case 1: return function (b) { return f(a, b); } | ||
default: return f(a, b) | ||
} | ||
return curried | ||
} | ||
return curried | ||
} | ||
// curry3 :: ((a, b, c) -> d) -> (a -> b -> c -> d) | ||
function curry3 (f) { | ||
function curried (a, b, c) { // eslint-disable-line complexity | ||
switch (arguments.length) { | ||
case 0: return curried | ||
case 1: return curry2(function (b, c) { return f(a, b, c); }) | ||
case 2: return function (c) { return f(a, b, c); } | ||
default:return f(a, b, c) | ||
} | ||
// curry3 :: ((a, b, c) -> d) -> (a -> b -> c -> d) | ||
function curry3 (f) { | ||
function curried (a, b, c) { // eslint-disable-line complexity | ||
switch (arguments.length) { | ||
case 0: return curried | ||
case 1: return curry2(function (b, c) { return f(a, b, c); }) | ||
case 2: return function (c) { return f(a, b, c); } | ||
default:return f(a, b, c) | ||
} | ||
return curried | ||
} | ||
return curried | ||
} | ||
@@ -68,0 +68,0 @@ /** @license MIT License (c) copyright 2010-2017 original author or authors */ |
@@ -1,1 +0,1 @@ | ||
(function(t,e){typeof exports==="object"&&typeof module!=="undefined"?e(exports):typeof define==="function"&&define.amd?define(["exports"],e):e(t.mostCore=t.mostCore||{})})(this,function(t){"use strict";function e(t,e){var n=e.length;var r=new Array(n);var i=0;for(var o,s=0;s<n;++s){o=e[s];if(!t(o)){r[i]=o;++i}}r.length=i;return r}function n(t,e){for(var n=0,r=e.length;n<r;++n){if(t===e[n]){return n}}return-1}function r(t){function e(n,r){switch(arguments.length){case 0:return e;case 1:return function(e){return t(n,e)};default:return t(n,r)}}return e}function i(t){function e(n,i,o){switch(arguments.length){case 0:return e;case 1:return r(function(e,r){return t(n,e,r)});case 2:return function(e){return t(n,i,e)};default:return t(n,i,o)}}return e}var o=function t(e,n,r,i,o){this.time=e;this.localOffset=n;this.period=r;this.task=i;this.scheduler=o;this.active=true};o.prototype.run=function t(){return this.task.run(this.time-this.localOffset)};o.prototype.error=function t(e){return this.task.error(this.time-this.localOffset,e)};o.prototype.dispose=function t(){this.scheduler.cancel(this);return this.task.dispose()};var s=function t(){};s.prototype.asap=function t(e){return this.scheduleTask(0,0,-1,e)};s.prototype.delay=function t(e,n){return this.scheduleTask(0,e,-1,n)};s.prototype.periodic=function t(e,n){return this.scheduleTask(0,0,e,n)};s.prototype.schedule=function t(e,n,r){return this.scheduleTask(0,e,n,r)};var u=function(t){function e(e,n){t.call(this);this.origin=e;this.scheduler=n}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.now=function t(){return this.scheduler.now()-this.origin};e.prototype.scheduleTask=function t(e,n,r,i){return this.scheduler.scheduleTask(e+this.origin,n,r,i)};e.prototype.relative=function t(n){return new e(n+this.origin,this.scheduler)};e.prototype.cancel=function t(e){return this.scheduler.cancel(e)};e.prototype.cancelAll=function t(e){return this.scheduler.cancelAll(e)};return e}(s);var c=function(t){return Promise.resolve(t).then(a)};function a(t){try{return t.run()}catch(e){return t.error(e)}}var h=function(t){function e(e,n){var r=this;t.call(this);this.timer=e;this.timeline=n;this._timer=null;this._nextArrival=Infinity;this._runReadyTasksBound=function(){return r._runReadyTasks(r.now())}}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.now=function t(){return this.timer.now()};e.prototype.scheduleTask=function t(e,n,r,i){var s=this.now()+Math.max(0,n);var u=new o(s,e,r,i,this);this.timeline.add(u);this._scheduleNextRun();return u};e.prototype.relative=function t(e){return new u(e,this)};e.prototype.cancel=function t(e){e.active=false;if(this.timeline.remove(e)){this._reschedule()}};e.prototype.cancelAll=function t(e){this.timeline.removeAll(e);this._reschedule()};e.prototype._reschedule=function t(){if(this.timeline.isEmpty()){this._unschedule()}else{this._scheduleNextRun(this.now())}};e.prototype._unschedule=function t(){this.timer.clearTimer(this._timer);this._timer=null};e.prototype._scheduleNextRun=function t(){if(this.timeline.isEmpty()){return}var e=this.timeline.nextArrival();if(this._timer===null){this._scheduleNextArrival(e)}else if(e<this._nextArrival){this._unschedule();this._scheduleNextArrival(e)}};e.prototype._scheduleNextArrival=function t(e){this._nextArrival=e;var n=Math.max(0,e-this.now());this._timer=this.timer.setTimer(this._runReadyTasksBound,n)};e.prototype._runReadyTasks=function t(){this._timer=null;this.timeline.runTasks(this.now(),a);this._scheduleNextRun()};return e}(s);var f=function t(){this.tasks=[]};f.prototype.nextArrival=function t(){return this.isEmpty()?Infinity:this.tasks[0].time};f.prototype.isEmpty=function t(){return this.tasks.length===0};f.prototype.add=function t(e){p(e,this.tasks)};f.prototype.remove=function t(e){var r=w(y(e),this.tasks);if(r>=0&&r<this.tasks.length){var i=n(e,this.tasks[r].events);if(i>=0){this.tasks[r].events.splice(i,1);return true}}return false};f.prototype.removeAll=function t(e){var n=this;for(var r=0;r<this.tasks.length;++r){k(e,n.tasks[r])}};f.prototype.runTasks=function t(e,n){var r=this;var i=this.tasks;var o=i.length;var s=0;while(s<o&&i[s].time<=e){++s}this.tasks=i.slice(s);for(var u=0;u<s;++u){r.tasks=l(n,i[u].events,r.tasks)}};function l(t,e,n){for(var r=0;r<e.length;++r){var i=e[r];if(i.active){t(i);if(i.period>=0&&i.active){i.time=i.time+i.period;p(i,n)}}}return n}function p(t,e){var n=e.length;var r=y(t);if(n===0){e.push(_(r,[t]));return}var i=w(r,e);if(i>=n){e.push(_(r,[t]))}else{v(t,e,r,i)}}function v(t,e,n,r){var i=e[r];if(n===i.time){m(t,i.events,n)}else{e.splice(r,0,_(n,[t]))}}function m(t,e){if(e.length===0||t.time>=e[e.length-1].time){e.push(t)}else{d(t,e)}}function d(t,e){for(var n=0;n<e.length;n++){if(t.time<e[n].time){e.splice(n,0,t);break}}}function y(t){return Math.floor(t.time)}function k(t,n){n.events=e(t,n.events)}function w(t,e){var n=0;var r=e.length;var i,o;while(n<r){i=Math.floor((n+r)/2);o=e[i];if(t===o.time){return i}else if(t<o.time){r=i}else{n=i+1}}return r}var _=function(t,e){return{time:t,events:e}};var T=function t(e){this._clock=e};T.prototype.now=function t(){return this._clock.now()};T.prototype.setTimer=function t(e,n){return n<=0?x(e):setTimeout(e,n)};T.prototype.clearTimer=function t(e){return e instanceof g?e.cancel():clearTimeout(e)};var g=function t(e){this.f=e;this.active=true};g.prototype.run=function t(){return this.active&&this.f()};g.prototype.error=function t(e){throw e};g.prototype.cancel=function t(){this.active=false};function x(t){var e=new g(t);c(e);return e}var A=function t(e,n){this.origin=n;this.clock=e};A.prototype.now=function t(){return this.clock.now()-this.origin};var R=function t(e,n){this.origin=n;this.hrtime=e};R.prototype.now=function t(){var e=this.hrtime(this.origin);return(e[0]*1e9+e[1])/1e6};var C=function(t){return new A(t,t.now())};var N=function(){return C(performance)};var O=function(){return C(Date)};var b=function(){return new R(process.hrtime,process.hrtime())};var M=function(){if(typeof performance!=="undefined"&&typeof performance.now==="function"){return N()}else if(typeof process!=="undefined"&&typeof process.hrtime==="function"){return b()}return O()};var j=r(function(t,e){return e.asap(t)});var D=i(function(t,e,n){return n.delay(t,e)});var E=i(function(t,e,n){return n.periodic(t,e)});var P=r(function(t,e){return new u(t,e)});var B=r(function(t,e){return new h(t,e)});var H=function(){return new h(I(),new f)};var I=function(){return new T(M())};var S=function(t){return new T(t)};var q=function(){return new f};t.newScheduler=B;t.newDefaultScheduler=H;t.newDefaultTimer=I;t.newClockTimer=S;t.newTimeline=q;t.RelativeClock=A;t.HRTimeClock=R;t.clockRelativeTo=C;t.newPerformanceClock=N;t.newDateClock=O;t.newHRTimeClock=b;t.newPlatformClock=M;t.asap=j;t.delay=D;t.periodic=E;t.schedulerRelativeTo=P;Object.defineProperty(t,"__esModule",{value:true})}); | ||
(function(t,e){typeof exports==="object"&&typeof module!=="undefined"?e(exports):typeof define==="function"&&define.amd?define(["exports"],e):e(t.mostCore=t.mostCore||{})})(this,function(t){"use strict";function e(t,e){var n=e.length;var r=new Array(n);var i=0;for(var o=void 0,s=0;s<n;++s){o=e[s];if(!t(o)){r[i]=o;++i}}r.length=i;return r}function n(t,e){for(var n=0,r=e.length;n<r;++n){if(t===e[n]){return n}}return-1}function r(t){function e(n,r){switch(arguments.length){case 0:return e;case 1:return function(e){return t(n,e)};default:return t(n,r)}}return e}function i(t){function e(n,i,o){switch(arguments.length){case 0:return e;case 1:return r(function(e,r){return t(n,e,r)});case 2:return function(e){return t(n,i,e)};default:return t(n,i,o)}}return e}var o=function t(e,n,r,i,o){this.time=e;this.localOffset=n;this.period=r;this.task=i;this.scheduler=o;this.active=true};o.prototype.run=function t(){return this.task.run(this.time-this.localOffset)};o.prototype.error=function t(e){return this.task.error(this.time-this.localOffset,e)};o.prototype.dispose=function t(){this.scheduler.cancel(this);return this.task.dispose()};var s=function t(){};s.prototype.asap=function t(e){return this.scheduleTask(0,0,-1,e)};s.prototype.delay=function t(e,n){return this.scheduleTask(0,e,-1,n)};s.prototype.periodic=function t(e,n){return this.scheduleTask(0,0,e,n)};s.prototype.schedule=function t(e,n,r){return this.scheduleTask(0,e,n,r)};var u=function(t){function e(e,n){t.call(this);this.origin=e;this.scheduler=n}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.now=function t(){return this.scheduler.now()-this.origin};e.prototype.scheduleTask=function t(e,n,r,i){return this.scheduler.scheduleTask(e+this.origin,n,r,i)};e.prototype.relative=function t(n){return new e(n+this.origin,this.scheduler)};e.prototype.cancel=function t(e){return this.scheduler.cancel(e)};e.prototype.cancelAll=function t(e){return this.scheduler.cancelAll(e)};return e}(s);var c=function(t){return Promise.resolve(t).then(a)};function a(t){try{return t.run()}catch(e){return t.error(e)}}var h=function(t){function e(e,n){var r=this;t.call(this);this.timer=e;this.timeline=n;this._timer=null;this._nextArrival=Infinity;this._runReadyTasksBound=function(){return r._runReadyTasks(r.now())}}if(t)e.__proto__=t;e.prototype=Object.create(t&&t.prototype);e.prototype.constructor=e;e.prototype.now=function t(){return this.timer.now()};e.prototype.scheduleTask=function t(e,n,r,i){var s=this.now()+Math.max(0,n);var u=new o(s,e,r,i,this);this.timeline.add(u);this._scheduleNextRun();return u};e.prototype.relative=function t(e){return new u(e,this)};e.prototype.cancel=function t(e){e.active=false;if(this.timeline.remove(e)){this._reschedule()}};e.prototype.cancelAll=function t(e){this.timeline.removeAll(e);this._reschedule()};e.prototype._reschedule=function t(){if(this.timeline.isEmpty()){this._unschedule()}else{this._scheduleNextRun(this.now())}};e.prototype._unschedule=function t(){this.timer.clearTimer(this._timer);this._timer=null};e.prototype._scheduleNextRun=function t(){if(this.timeline.isEmpty()){return}var e=this.timeline.nextArrival();if(this._timer===null){this._scheduleNextArrival(e)}else if(e<this._nextArrival){this._unschedule();this._scheduleNextArrival(e)}};e.prototype._scheduleNextArrival=function t(e){this._nextArrival=e;var n=Math.max(0,e-this.now());this._timer=this.timer.setTimer(this._runReadyTasksBound,n)};e.prototype._runReadyTasks=function t(){this._timer=null;this.timeline.runTasks(this.now(),a);this._scheduleNextRun()};return e}(s);var f=function t(){this.tasks=[]};f.prototype.nextArrival=function t(){return this.isEmpty()?Infinity:this.tasks[0].time};f.prototype.isEmpty=function t(){return this.tasks.length===0};f.prototype.add=function t(e){p(e,this.tasks)};f.prototype.remove=function t(e){var r=w(y(e),this.tasks);if(r>=0&&r<this.tasks.length){var i=n(e,this.tasks[r].events);if(i>=0){this.tasks[r].events.splice(i,1);return true}}return false};f.prototype.removeAll=function t(e){var n=this;for(var r=0;r<this.tasks.length;++r){k(e,n.tasks[r])}};f.prototype.runTasks=function t(e,n){var r=this;var i=this.tasks;var o=i.length;var s=0;while(s<o&&i[s].time<=e){++s}this.tasks=i.slice(s);for(var u=0;u<s;++u){r.tasks=l(n,i[u].events,r.tasks)}};function l(t,e,n){for(var r=0;r<e.length;++r){var i=e[r];if(i.active){t(i);if(i.period>=0&&i.active){i.time=i.time+i.period;p(i,n)}}}return n}function p(t,e){var n=e.length;var r=y(t);if(n===0){e.push(_(r,[t]));return}var i=w(r,e);if(i>=n){e.push(_(r,[t]))}else{v(t,e,r,i)}}function v(t,e,n,r){var i=e[r];if(n===i.time){m(t,i.events,n)}else{e.splice(r,0,_(n,[t]))}}function m(t,e){if(e.length===0||t.time>=e[e.length-1].time){e.push(t)}else{d(t,e)}}function d(t,e){for(var n=0;n<e.length;n++){if(t.time<e[n].time){e.splice(n,0,t);break}}}function y(t){return Math.floor(t.time)}function k(t,n){n.events=e(t,n.events)}function w(t,e){var n=0;var r=e.length;var i,o;while(n<r){i=Math.floor((n+r)/2);o=e[i];if(t===o.time){return i}else if(t<o.time){r=i}else{n=i+1}}return r}var _=function(t,e){return{time:t,events:e}};var T=function t(e){this._clock=e};T.prototype.now=function t(){return this._clock.now()};T.prototype.setTimer=function t(e,n){return n<=0?x(e):setTimeout(e,n)};T.prototype.clearTimer=function t(e){return e instanceof g?e.cancel():clearTimeout(e)};var g=function t(e){this.f=e;this.active=true};g.prototype.run=function t(){return this.active&&this.f()};g.prototype.error=function t(e){throw e};g.prototype.cancel=function t(){this.active=false};function x(t){var e=new g(t);c(e);return e}var A=function t(e,n){this.origin=n;this.clock=e};A.prototype.now=function t(){return this.clock.now()-this.origin};var R=function t(e,n){this.origin=n;this.hrtime=e};R.prototype.now=function t(){var e=this.hrtime(this.origin);return(e[0]*1e9+e[1])/1e6};var C=function(t){return new A(t,t.now())};var N=function(){return C(performance)};var O=function(){return C(Date)};var b=function(){return new R(process.hrtime,process.hrtime())};var M=function(){if(typeof performance!=="undefined"&&typeof performance.now==="function"){return N()}else if(typeof process!=="undefined"&&typeof process.hrtime==="function"){return b()}return O()};var j=r(function(t,e){return e.asap(t)});var D=i(function(t,e,n){return n.delay(t,e)});var E=i(function(t,e,n){return n.periodic(t,e)});var P=r(function(t,e){return new u(t,e)});var B=r(function(t,e){return new h(t,e)});var H=function(){return new h(I(),new f)};var I=function(){return new T(M())};var S=function(t){return new T(t)};var q=function(){return new f};t.newScheduler=B;t.newDefaultScheduler=H;t.newDefaultTimer=I;t.newClockTimer=S;t.newTimeline=q;t.RelativeClock=A;t.HRTimeClock=R;t.clockRelativeTo=C;t.newPerformanceClock=N;t.newDateClock=O;t.newHRTimeClock=b;t.newPlatformClock=M;t.asap=j;t.delay=D;t.periodic=E;t.schedulerRelativeTo=P;Object.defineProperty(t,"__esModule",{value:true})}); |
{ | ||
"name": "@most/scheduler", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"description": "Reactive programming with lean, functions-only, curried, tree-shakeable API", | ||
@@ -59,4 +59,4 @@ "typings": "type-definitions/index.d.ts", | ||
"@most/prelude": "^1.5.3", | ||
"@most/types": "^0.9.0" | ||
"@most/types": "^0.9.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
101685
Updated@most/types@^0.9.1