Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hypertimer

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hypertimer - npm Package Compare versions

Comparing version 2.1.2 to 2.1.3

6

dist/hypertimer.min.js

@@ -9,4 +9,4 @@ /**

*
* @version 2.1.2
* @date 2015-07-13
* @version 2.1.3
* @date 2015-12-08
*

@@ -28,3 +28,3 @@ * @license

*/
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("ws"),require("debug")):"function"==typeof define&&define.amd?define(["ws","debug"],n):"object"==typeof exports?exports.hypertimer=n(require("ws"),require("debug")):t.hypertimer=n(t.ws,t.debug)}(this,function(t,n){return function(t){function n(r){if(e[r])return e[r].exports;var o=e[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var e={};return n.m=t,n.c=e,n.p="",n(0)}([function(t,n,e){t.exports=e(1)},function(t,n,e){function r(t){function n(){return{paced:y,rate:w,deterministic:g,time:b,master:_,port:T}}function e(t){if(A||t.master)for(var n in t)if("master"!==n&&"slave"!==n)throw new Error('Cannot apply configuration option "'+n+'", timer is configured as slave.')}function r(t){function e(t){var e=n();r(t);var o=n();M.emit("config",o,e)}if("deterministic"in t&&(g=t.deterministic?!0:!1),"paced"in t&&(y=t.paced?!0:!1),"time"in t&&(j=v(t.time),O=a.systemNow(),s(j),b=new Date(j).toISOString()),"rate"in t){var o=Number(t.rate);if(isNaN(o)||0>=o)throw new TypeError("Invalid rate "+JSON.stringify(t.rate)+". Rate must be a positive number");j=M.now(),O=a.systemNow(),w=o}"master"in t&&(A&&(A.destroy(),A=null),_=t.master,null!=t.master&&(A=c(t.master),A.on("change",function(t){e({time:t})}),A.on("config",function(t){e(t)}),A.on("error",function(t){M.emit("error",t)}))),"port"in t&&(S&&(S.destroy(),S=null),T=t.port,t.port&&(S=u(M.now,M.config,t.port),S.on("error",function(t){M.emit("error",t)}))),h(),S&&S.broadcastConfig()}function s(t){for(var n=0;n<I.length;n++){var e=I[n];e.type===f.INTERVAL&&l(e,t)}}function l(t,n){t.occurrence=Math.round((n-t.firstTime)/t.interval),t.time=t.firstTime+t.occurrence*t.interval}function p(t){if(I.length>0){for(var n=I.length-1;n>=0&&I[n].time>t.time;)n--;I.splice(n+1,0,t)}else I.push(t)}function d(t,n){function e(){t.type===f.INTERVAL&&E[t.id]&&(t.occurrence++,t.time=t.firstTime+t.occurrence*t.interval,p(t)),delete E[t.id],n&&n()}E[t.id]=t;try{0==t.callback.length?(t.callback(),e()):t.callback(e)}catch(r){i(M,"error")?M.emit("error",r):console.log("Error",r),e()}}function m(t){for(var n=0;n<I.length&&(I[n].time<=t||!isFinite(I[n].time));)n++;var e=I.splice(0,n);return 0==g&&a.shuffle(e),e}function h(){function t(){function t(){var e=n.shift();e?d(e,t):h()}y||(j=e>j&&isFinite(e)?e:j);var n=m(e);y?(n.forEach(function(t){d(t)}),h()):t()}if(y||!(Object.keys(E).length>0)){var n=I[0];if(N&&(clearTimeout(N),N=null),x&&n){var e=n.time,r=e-M.now(),o=y?r/w:0;N=setTimeout(t,Math.round(o))}}}function v(t){var n="number"==typeof t?t:t instanceof Date?t.valueOf():new Date(t).valueOf();if(isNaN(n))throw new TypeError("Invalid date "+JSON.stringify(t)+". Date, number, or ISOString expected");return n}var y=!0,w=1,g=!0,b=null,_=null,T=null,x=!1,O=null,j=a.systemNow(),I=[],E={},N=null,k=0,S=null,A=null,M=o({});return M.config=function(t){return t&&(e(t),r(t)),n()},M.now=function(){if(y){if(x){var t=a.systemNow()-O,n=t*w;return j+n}return j}return j},M["continue"]=function(){O=a.systemNow(),x=!0,h()},M.pause=function(){j=M.now(),O=null,x=!1,h()},M.getTime=function(){return new Date(M.now())},M.valueOf=M.getTime,M.toString=function(){return M.getTime().toString()},M.setTimeout=function(t,n){var e=k++,r=M.now()+n;if(isNaN(r))throw new TypeError("delay must be a number");return p({id:e,type:f.TIMEOUT,time:r,callback:t}),h(),e},M.setTrigger=function(t,n){var e=k++,r=v(n);return p({id:e,type:f.TRIGGER,time:r,callback:t}),h(),e},M.setInterval=function(t,n,e){var r=k++,o=Number(n);if(isNaN(o))throw new TypeError("interval must be a number");(0>o||!isFinite(o))&&(o=0);var i=void 0!=e?v(e):null,u=M.now(),c=null!=i?i:u+o,a={id:r,type:f.INTERVAL,interval:o,time:c,firstTime:null!=i?i:c,occurrence:0,callback:t};return u>c&&l(a,u),p(a),h(),r},M.clearTimeout=function(t){if(E[t])return void delete E[t];for(var n=0;n<I.length;n++)if(I[n].id===t){I.splice(n,1),h();break}},M.clearTrigger=M.clearTimeout,M.clearInterval=M.clearTimeout,M.list=function(){return I.map(function(t){return t.id})},M.clear=function(){E={},I=[],h()},M.destroy=function(){M.clear(),A&&A.destroy(),S&&S.destroy()},Object.defineProperty(M,"running",{get:function(){return x}}),M.config(t),M["continue"](),M}var o=e(2),i=e(17),u=e(19).createMaster,c=e(34).createSlave,a=e(37),f={TIMEOUT:0,INTERVAL:1,TRIGGER:2};t.exports=r},function(t,n,e){"use strict";var r,o,i,u,c,a,f,s=e(3),l=e(16),p=Function.prototype.apply,d=Function.prototype.call,m=Object.create,h=Object.defineProperty,v=Object.defineProperties,y=Object.prototype.hasOwnProperty,w={configurable:!0,enumerable:!1,writable:!0};r=function(t,n){var e;return l(n),y.call(this,"__ee__")?e=this.__ee__:(e=w.value=m(null),h(this,"__ee__",w),w.value=null),e[t]?"object"==typeof e[t]?e[t].push(n):e[t]=[e[t],n]:e[t]=n,this},o=function(t,n){var e,o;return l(n),o=this,r.call(this,t,e=function(){i.call(o,t,e),p.call(n,this,arguments)}),e.__eeOnceListener__=n,this},i=function(t,n){var e,r,o,i;if(l(n),!y.call(this,"__ee__"))return this;if(e=this.__ee__,!e[t])return this;if(r=e[t],"object"==typeof r)for(i=0;o=r[i];++i)(o===n||o.__eeOnceListener__===n)&&(2===r.length?e[t]=r[i?0:1]:r.splice(i,1));else(r===n||r.__eeOnceListener__===n)&&delete e[t];return this},u=function(t){var n,e,r,o,i;if(y.call(this,"__ee__")&&(o=this.__ee__[t]))if("object"==typeof o){for(e=arguments.length,i=new Array(e-1),n=1;e>n;++n)i[n-1]=arguments[n];for(o=o.slice(),n=0;r=o[n];++n)p.call(r,this,i)}else switch(arguments.length){case 1:d.call(o,this);break;case 2:d.call(o,this,arguments[1]);break;case 3:d.call(o,this,arguments[1],arguments[2]);break;default:for(e=arguments.length,i=new Array(e-1),n=1;e>n;++n)i[n-1]=arguments[n];p.call(o,this,i)}},c={on:r,once:o,off:i,emit:u},a={on:s(r),once:s(o),off:s(i),emit:s(u)},f=v({},a),t.exports=n=function(t){return null==t?m(f):v(Object(t),a)},n.methods=c},function(t,n,e){"use strict";var r,o=e(4),i=e(11),u=e(12),c=e(13);r=t.exports=function(t,n){var e,r,u,a,f;return arguments.length<2||"string"!=typeof t?(a=n,n=t,t=null):a=arguments[2],null==t?(e=u=!0,r=!1):(e=c.call(t,"c"),r=c.call(t,"e"),u=c.call(t,"w")),f={value:n,configurable:e,enumerable:r,writable:u},a?o(i(a),f):f},r.gs=function(t,n,e){var r,a,f,s;return"string"!=typeof t?(f=e,e=n,n=t,t=null):f=arguments[3],null==n?n=void 0:u(n)?null==e?e=void 0:u(e)||(f=e,e=void 0):(f=n,n=e=void 0),null==t?(r=!0,a=!1):(r=c.call(t,"c"),a=c.call(t,"e")),s={get:n,set:e,configurable:r,enumerable:a},f?o(i(f),s):s}},function(t,n,e){"use strict";t.exports=e(5)()?Object.assign:e(6)},function(t,n){"use strict";t.exports=function(){var t,n=Object.assign;return"function"!=typeof n?!1:(t={foo:"raz"},n(t,{bar:"dwa"},{trzy:"trzy"}),t.foo+t.bar+t.trzy==="razdwatrzy")}},function(t,n,e){"use strict";var r=e(7),o=e(10),i=Math.max;t.exports=function(t,n){var e,u,c,a=i(arguments.length,2);for(t=Object(o(t)),c=function(r){try{t[r]=n[r]}catch(o){e||(e=o)}},u=1;a>u;++u)n=arguments[u],r(n).forEach(c);if(void 0!==e)throw e;return t}},function(t,n,e){"use strict";t.exports=e(8)()?Object.keys:e(9)},function(t,n){"use strict";t.exports=function(){try{return Object.keys("primitive"),!0}catch(t){return!1}}},function(t,n){"use strict";var e=Object.keys;t.exports=function(t){return e(null==t?t:Object(t))}},function(t,n){"use strict";t.exports=function(t){if(null==t)throw new TypeError("Cannot use null or undefined");return t}},function(t,n){"use strict";var e=Array.prototype.forEach,r=Object.create,o=function(t,n){var e;for(e in t)n[e]=t[e]};t.exports=function(t){var n=r(null);return e.call(arguments,function(t){null!=t&&o(Object(t),n)}),n}},function(t,n){"use strict";t.exports=function(t){return"function"==typeof t}},function(t,n,e){"use strict";t.exports=e(14)()?String.prototype.contains:e(15)},function(t,n){"use strict";var e="razdwatrzy";t.exports=function(){return"function"!=typeof e.contains?!1:e.contains("dwa")===!0&&e.contains("foo")===!1}},function(t,n){"use strict";var e=String.prototype.indexOf;t.exports=function(t){return e.call(this,t,arguments[1])>-1}},function(t,n){"use strict";t.exports=function(t){if("function"!=typeof t)throw new TypeError(t+" is not a function");return t}},function(t,n,e){"use strict";var r=e(18),o=e(10),i=Object.prototype.hasOwnProperty;t.exports=function(t){var n;return o(t),n=arguments[1],arguments.length>1?i.call(t,"__ee__")&&Boolean(t.__ee__[n]):t.hasOwnProperty("__ee__")&&!r(t.__ee__)}},function(t,n,e){"use strict";var r=e(10),o=Object.prototype.propertyIsEnumerable;t.exports=function(t){var n;r(t);for(n in t)if(o.call(t,n))return!1;return!0}},function(t,n,e){var r=e(20),o=e(22),i=e(32)("hypertimer:master");n.createMaster=function(t,n,e){function u(){var t=n();return delete t.time,delete t.master,delete t.port,t}var c=new r.Server({port:e});return c.on("connection",function(n){i("new connection");var e=o(n);e.on("time",function(n,e){var r=t();e(r),i("send time "+new Date(r).toISOString())});var r=u();i("send config",r),e.send("config",r),n.emitter=e}),c.broadcast=function(t,n){i("broadcast",t,n),c.clients.forEach(function(e){e.emitter.send(t,n)})},c.broadcastConfig=function(){c.broadcast("config",u())},c.destroy=function(){c.close(),i("destroyed")},i("listening at ws://localhost:"+e),c}},function(t,n,e){t.exports="undefined"==typeof window||"undefined"==typeof window.WebSocket?e(21):window.WebSocket},function(n,e){n.exports=t},function(t,n,e){var r=e(2),o=e(23),i=e(32)("hypertimer:socket"),u=6e4;t.exports=function(t){function n(n,e){var r={event:n,data:e};i("send",r),t.send(JSON.stringify(r))}function e(n,e){return new o(function(r,o){var a=c(),s={event:n,id:a,data:e};f[a]={resolve:r,reject:o,timeout:setTimeout(function(){delete f[a],o(new Error("Timeout"))},u)},i("request",s),t.send(JSON.stringify(s))})["catch"](function(t){console.log("ERROR",t)})}function c(){return s++}var a=r({socket:t,send:n,request:e});t.onmessage=function(n){var e=n.data,r=JSON.parse(e);i("receive",r);var o=f[r.id];o?(clearTimeout(o.timeout),delete f[r.id],o.resolve(r.data)):"id"in r?a.emit(r.event,r.data,function(n){var e={id:r.id,data:n};t.readyState===t.OPEN||t.readyState===t.CONNECTING?(i("reply",e),t.send(JSON.stringify(e))):i("cancel reply",e,"(socket is closed)")}):a.emit(r.event,r.data)};var f={},s=0;return a}},function(t,n,e){t.exports="undefined"==typeof window||"undefined"==typeof window.Promise?e(24):window.Promise},function(t,n,e){"use strict";t.exports=e(25),e(29),e(30),e(31)},function(t,n,e){"use strict";function r(t){function n(t){return null===a?void s.push(t):void u(function(){var n=a?t.onFulfilled:t.onRejected;if(null===n)return void(a?t.resolve:t.reject)(f);var e;try{e=n(f)}catch(r){return void t.reject(r)}t.resolve(e)})}function e(t){try{if(t===l)throw new TypeError("A promise cannot be resolved with itself.");if(t&&("object"==typeof t||"function"==typeof t)){var n=t.then;if("function"==typeof n)return void i(n.bind(t),e,r)}a=!0,f=t,c()}catch(o){r(o)}}function r(t){a=!1,f=t,c()}function c(){for(var t=0,e=s.length;e>t;t++)n(s[t]);s=null}if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");var a=null,f=null,s=[],l=this;this.then=function(t,e){return new l.constructor(function(r,i){n(new o(t,e,r,i))})},i(t,e,r)}function o(t,n,e,r){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof n?n:null,this.resolve=e,this.reject=r}function i(t,n,e){var r=!1;try{t(function(t){r||(r=!0,n(t))},function(t){r||(r=!0,e(t))})}catch(o){if(r)return;r=!0,e(o)}}var u=e(26);t.exports=r},function(t,n,e){(function(n,e){function r(){for(;i.next;){i=i.next;var t=i.task;i.task=void 0;var n=i.domain;n&&(i.domain=void 0,n.enter());try{t()}catch(e){if(f)throw n&&n.exit(),setTimeout(r,0),n&&n.enter(),e;setTimeout(function(){throw e},0)}n&&n.exit()}c=!1}function o(t){u=u.next={task:t,domain:f&&n.domain,next:null},c||(c=!0,a())}var i={task:void 0,next:null},u=i,c=!1,a=void 0,f=!1;if("undefined"!=typeof n&&n.nextTick)f=!0,a=function(){n.nextTick(r)};else if("function"==typeof e)a="undefined"!=typeof window?e.bind(window,r):function(){e(r)};else if("undefined"!=typeof MessageChannel){var s=new MessageChannel;s.port1.onmessage=r,a=function(){s.port2.postMessage(0)}}else a=function(){setTimeout(r,0)};t.exports=o}).call(n,e(27),e(28).setImmediate)},function(t,n){function e(){f=!1,u.length?a=u.concat(a):s=-1,a.length&&r()}function r(){if(!f){var t=setTimeout(e);f=!0;for(var n=a.length;n;){for(u=a,a=[];++s<n;)u[s].run();s=-1,n=a.length}u=null,f=!1,clearTimeout(t)}}function o(t,n){this.fun=t,this.array=n}function i(){}var u,c=t.exports={},a=[],f=!1,s=-1;c.nextTick=function(t){var n=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)n[e-1]=arguments[e];a.push(new o(t,n)),1!==a.length||f||setTimeout(r,0)},o.prototype.run=function(){this.fun.apply(null,this.array)},c.title="browser",c.browser=!0,c.env={},c.argv=[],c.version="",c.versions={},c.on=i,c.addListener=i,c.once=i,c.off=i,c.removeListener=i,c.removeAllListeners=i,c.emit=i,c.binding=function(t){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(t){throw new Error("process.chdir is not supported")},c.umask=function(){return 0}},function(t,n,e){(function(t,r){function o(t,n){this._id=t,this._clearFn=n}var i=e(27).nextTick,u=Function.prototype.apply,c=Array.prototype.slice,a={},f=0;n.setTimeout=function(){return new o(u.call(setTimeout,window,arguments),clearTimeout)},n.setInterval=function(){return new o(u.call(setInterval,window,arguments),clearInterval)},n.clearTimeout=n.clearInterval=function(t){t.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(window,this._id)},n.enroll=function(t,n){clearTimeout(t._idleTimeoutId),t._idleTimeout=n},n.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},n._unrefActive=n.active=function(t){clearTimeout(t._idleTimeoutId);var n=t._idleTimeout;n>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},n))},n.setImmediate="function"==typeof t?t:function(t){var e=f++,r=arguments.length<2?!1:c.call(arguments,1);return a[e]=!0,i(function(){a[e]&&(r?t.apply(null,r):t.call(null),n.clearImmediate(e))}),e},n.clearImmediate="function"==typeof r?r:function(t){delete a[t]}}).call(n,e(28).setImmediate,e(28).clearImmediate)},function(t,n,e){"use strict";var r=e(25),o=e(26);t.exports=r,r.prototype.done=function(t,n){var e=arguments.length?this.then.apply(this,arguments):this;e.then(null,function(t){o(function(){throw t})})}},function(t,n,e){"use strict";function r(t){this.then=function(n){return"function"!=typeof n?this:new o(function(e,r){i(function(){try{e(n(t))}catch(o){r(o)}})})}}var o=e(25),i=e(26);t.exports=o,r.prototype=o.prototype;var u=new r(!0),c=new r(!1),a=new r(null),f=new r(void 0),s=new r(0),l=new r("");o.resolve=function(t){if(t instanceof o)return t;if(null===t)return a;if(void 0===t)return f;if(t===!0)return u;if(t===!1)return c;if(0===t)return s;if(""===t)return l;if("object"==typeof t||"function"==typeof t)try{var n=t.then;if("function"==typeof n)return new o(n.bind(t))}catch(e){return new o(function(t,n){n(e)})}return new r(t)},o.all=function(t){var n=Array.prototype.slice.call(t);return new o(function(t,e){function r(i,u){try{if(u&&("object"==typeof u||"function"==typeof u)){var c=u.then;if("function"==typeof c)return void c.call(u,function(t){r(i,t)},e)}n[i]=u,0===--o&&t(n)}catch(a){e(a)}}if(0===n.length)return t([]);for(var o=n.length,i=0;i<n.length;i++)r(i,n[i])})},o.reject=function(t){return new o(function(n,e){e(t)})},o.race=function(t){return new o(function(n,e){t.forEach(function(t){o.resolve(t).then(n,e)})})},o.prototype["catch"]=function(t){return this.then(null,t)}},function(t,n,e){"use strict";var r=e(25),o=e(26);t.exports=r,r.denodeify=function(t,n){return n=n||1/0,function(){var e=this,o=Array.prototype.slice.call(arguments);return new r(function(r,i){for(;o.length&&o.length>n;)o.pop();o.push(function(t,n){t?i(t):r(n)});var u=t.apply(e,o);!u||"object"!=typeof u&&"function"!=typeof u||"function"!=typeof u.then||r(u)})}},r.nodeify=function(t){return function(){var n=Array.prototype.slice.call(arguments),e="function"==typeof n[n.length-1]?n.pop():null,i=this;try{return t.apply(this,arguments).nodeify(e,i)}catch(u){if(null===e||"undefined"==typeof e)return new r(function(t,n){n(u)});o(function(){e.call(i,u)})}}},r.prototype.nodeify=function(t,n){return"function"!=typeof t?this:void this.then(function(e){o(function(){t.call(n,null,e)})},function(e){o(function(){t.call(n,e)})})}},function(t,n,e){var r="undefined"!=typeof window?window.Debug:e(33);t.exports=r||function(){return function(){}}},function(t,e){t.exports=n},function(t,n,e){var r=e(20),o=e(23),i=e(32)("hypertimer:slave"),u=e(22),c=e(35),a=e(36),f=36e5,s=1e3,l=5;n.createSlave=function(t){function n(){function t(){var t=null;return h?o.resolve(t):e(d).then(function(n){t=n})["catch"](function(t){console.log(t)}).then(function(){return a.wait(s)}).then(function(){return t})}return a.repeat(t,l).then(function(t){i("latencies",t);var n=t.filter(function(t){return null!==t}),e=c.median(n)+c.std(n),r=n.filter(function(t){return e>t});return r.length>0?c.mean(r):null}).then(function(t){return h?o.resolve(null):d.request("time").then(function(n){var e=n+t;return d.emit("change",e),e})})["catch"](function(t){d.emit("error",t)})}function e(t){var n=Date.now();return t.request("time").then(function(e){var r=Date.now(),o=(r-n)/2,i=e+o;return m&&(m=!1,t.emit("change",i)),o})}var p=new r(t),d=u(p),m=!0,h=!1,v=null;return p.onopen=function(){i("connected"),n(),v=setInterval(n,f)},d.destroy=function(){h=!0,clearInterval(v),v=null,p.close(),i("destroyed")},d}},function(t,n){n.compare=function(t,n){return t>n?1:n>t?-1:0},n.add=function(t,n){return t+n},n.sum=function(t){return t.reduce(n.add)},n.mean=function(t){return n.sum(t)/t.length},n.std=function(t){return Math.sqrt(n.variance(t))},n.variance=function(t){if(t.length<2)return 0;var e=n.mean(t);return t.map(function(t){return Math.pow(t-e,2)}).reduce(n.add)/(t.length-1)},n.median=function(t){if(t.length<2)return t[0];var e=t.slice().sort(n.compare);return e.length%2===0?(t[t.length/2-1]+t[t.length/2])/2:t[(t.length-1)/2]}},function(t,n,e){var r=e(23);n.wait=function(t){return new r(function(n){setTimeout(n,t)})},n.repeat=function(t,n){return new r(function(e,r){function o(){n>i?(i++,t().then(function(t){u.push(t),o()})):e(u)}var i=0,u=[];o()})},n.whilst=function(t,n){return new r(function(e,r){function o(){t()?n().then(function(){o()}):e()}o()})}},function(t,n){"function"==typeof Date.now?n.systemNow=function(){return Date.now()}:n.systemNow=function(){return(new Date).valueOf()},n.shuffle=function(t){for(var n,e,r=t.length;r;n=Math.floor(Math.random()*r),e=t[--r],t[r]=t[n],t[n]=e);return t}}])});
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("ws"),require("debug")):"function"==typeof define&&define.amd?define(["ws","debug"],n):"object"==typeof exports?exports.hypertimer=n(require("ws"),require("debug")):t.hypertimer=n(t.ws,t.debug)}(this,function(t,n){return function(t){function n(r){if(e[r])return e[r].exports;var o=e[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var e={};return n.m=t,n.c=e,n.p="",n(0)}([function(t,n,e){t.exports=e(1)},function(t,n,e){function r(t){function n(){return{paced:y,rate:g,deterministic:w,time:_,master:b,port:x}}function e(t){if(R||t.master)for(var n in t)if("master"!==n&&"slave"!==n)throw new Error('Cannot apply configuration option "'+n+'", timer is configured as slave.')}function r(t){function e(t){var e=n();r(t);var o=n();D.emit("config",o,e)}if("deterministic"in t&&(w=t.deterministic?!0:!1),"paced"in t&&(y=t.paced?!0:!1),"time"in t&&(j=m(t.time),T=f.systemNow(),s(j),_=new Date(j).toISOString()),"rate"in t){var o=Number(t.rate);if(isNaN(o)||0>=o)throw new TypeError("Invalid rate "+JSON.stringify(t.rate)+". Rate must be a positive number");j=D.now(),T=f.systemNow(),g=o}"master"in t&&(R&&(R.destroy(),R=null),b=t.master,null!=t.master&&(R=c(t.master),R.on("change",function(t){e({time:t})}),R.on("config",function(t){e(t)}),R.on("error",function(t){D.emit("error",t)}))),"port"in t&&(I&&(I.destroy(),I=null),x=t.port,t.port&&(I=u(D.now,D.config,t.port),I.on("error",function(t){D.emit("error",t)}))),v(),I&&I.broadcastConfig()}function s(t){for(var n=0;n<N.length;n++){var e=N[n];e.type===a.INTERVAL&&l(e,t)}}function l(t,n){t.occurrence=Math.round((n-t.firstTime)/t.interval),t.time=t.firstTime+t.occurrence*t.interval}function p(t){if(N.length>0){for(var n=N.length-1;n>=0&&N[n].time>t.time;)n--;N.splice(n+1,0,t)}else N.push(t)}function h(t,n){function e(){t.type===a.INTERVAL&&E[t.id]&&(t.occurrence++,t.time=t.firstTime+t.occurrence*t.interval,p(t)),delete E[t.id],n&&n()}E[t.id]=t;try{0==t.callback.length?(t.callback(),e()):t.callback(e)}catch(r){i(D,"error")?D.emit("error",r):console.log("Error",r),e()}}function d(t){for(var n=0;n<N.length&&(N[n].time<=t||!isFinite(N[n].time));)n++;var e=N.splice(0,n);return 0==w&&f.shuffle(e),e}function v(){function t(){function t(){var e=n.shift();e?h(e,t):v()}y||(j=e>j&&isFinite(e)?e:j);var n=d(e);y?(n.forEach(function(t){h(t)}),v()):t()}if(y||!(Object.keys(E).length>0)){var n=N[0];if(k&&(clearTimeout(k),k=null),O&&n){var e=n.time,r=e-D.now(),o=y?r/g:0;k=setTimeout(t,Math.round(o))}}}function m(t){var n="number"==typeof t?t:t instanceof Date?t.valueOf():new Date(t).valueOf();if(isNaN(n))throw new TypeError("Invalid date "+JSON.stringify(t)+". Date, number, or ISOString expected");return n}var y=!0,g=1,w=!0,_=null,b=null,x=null,O=!1,T=null,j=f.systemNow(),N=[],E={},k=null,S=0,I=null,R=null,D=o({});return D.config=function(t){return t&&(e(t),r(t)),n()},D.now=function(){if(y){if(O){var t=f.systemNow()-T,n=t*g;return j+n}return j}return j},D["continue"]=function(){T=f.systemNow(),O=!0,v()},D.pause=function(){j=D.now(),T=null,O=!1,v()},D.getTime=function(){return new Date(D.now())},D.valueOf=D.getTime,D.toString=function(){return D.getTime().toString()},D.setTimeout=function(t,n){var e=S++,r=D.now()+n;if(isNaN(r))throw new TypeError("delay must be a number");return p({id:e,type:a.TIMEOUT,time:r,callback:t}),v(),e},D.setTrigger=function(t,n){var e=S++,r=m(n);return p({id:e,type:a.TRIGGER,time:r,callback:t}),v(),e},D.setInterval=function(t,n,e){var r=S++,o=Number(n);if(isNaN(o))throw new TypeError("interval must be a number");(0>o||!isFinite(o))&&(o=0);var i=void 0!=e?m(e):null,u=D.now(),c=null!=i?i:u+o,f={id:r,type:a.INTERVAL,interval:o,time:c,firstTime:null!=i?i:c,occurrence:0,callback:t};return u>c&&l(f,u),p(f),v(),r},D.clearTimeout=function(t){if(E[t])return void delete E[t];for(var n=0;n<N.length;n++)if(N[n].id===t){N.splice(n,1),v();break}},D.clearTrigger=D.clearTimeout,D.clearInterval=D.clearTimeout,D.list=function(){return N.map(function(t){return t.id})},D.clear=function(){E={},N=[],v()},D.destroy=function(){D.clear(),R&&R.destroy(),I&&I.destroy()},Object.defineProperty(D,"running",{get:function(){return O}}),D.config(t),D["continue"](),D}var o=e(2),i=e(17),u=e(19).createMaster,c=e(35).createSlave,f=e(38),a={TIMEOUT:0,INTERVAL:1,TRIGGER:2};t.exports=r},function(t,n,e){"use strict";var r,o,i,u,c,f,a,s=e(3),l=e(16),p=Function.prototype.apply,h=Function.prototype.call,d=Object.create,v=Object.defineProperty,m=Object.defineProperties,y=Object.prototype.hasOwnProperty,g={configurable:!0,enumerable:!1,writable:!0};r=function(t,n){var e;return l(n),y.call(this,"__ee__")?e=this.__ee__:(e=g.value=d(null),v(this,"__ee__",g),g.value=null),e[t]?"object"==typeof e[t]?e[t].push(n):e[t]=[e[t],n]:e[t]=n,this},o=function(t,n){var e,o;return l(n),o=this,r.call(this,t,e=function(){i.call(o,t,e),p.call(n,this,arguments)}),e.__eeOnceListener__=n,this},i=function(t,n){var e,r,o,i;if(l(n),!y.call(this,"__ee__"))return this;if(e=this.__ee__,!e[t])return this;if(r=e[t],"object"==typeof r)for(i=0;o=r[i];++i)(o===n||o.__eeOnceListener__===n)&&(2===r.length?e[t]=r[i?0:1]:r.splice(i,1));else(r===n||r.__eeOnceListener__===n)&&delete e[t];return this},u=function(t){var n,e,r,o,i;if(y.call(this,"__ee__")&&(o=this.__ee__[t]))if("object"==typeof o){for(e=arguments.length,i=new Array(e-1),n=1;e>n;++n)i[n-1]=arguments[n];for(o=o.slice(),n=0;r=o[n];++n)p.call(r,this,i)}else switch(arguments.length){case 1:h.call(o,this);break;case 2:h.call(o,this,arguments[1]);break;case 3:h.call(o,this,arguments[1],arguments[2]);break;default:for(e=arguments.length,i=new Array(e-1),n=1;e>n;++n)i[n-1]=arguments[n];p.call(o,this,i)}},c={on:r,once:o,off:i,emit:u},f={on:s(r),once:s(o),off:s(i),emit:s(u)},a=m({},f),t.exports=n=function(t){return null==t?d(a):m(Object(t),f)},n.methods=c},function(t,n,e){"use strict";var r,o=e(4),i=e(11),u=e(12),c=e(13);r=t.exports=function(t,n){var e,r,u,f,a;return arguments.length<2||"string"!=typeof t?(f=n,n=t,t=null):f=arguments[2],null==t?(e=u=!0,r=!1):(e=c.call(t,"c"),r=c.call(t,"e"),u=c.call(t,"w")),a={value:n,configurable:e,enumerable:r,writable:u},f?o(i(f),a):a},r.gs=function(t,n,e){var r,f,a,s;return"string"!=typeof t?(a=e,e=n,n=t,t=null):a=arguments[3],null==n?n=void 0:u(n)?null==e?e=void 0:u(e)||(a=e,e=void 0):(a=n,n=e=void 0),null==t?(r=!0,f=!1):(r=c.call(t,"c"),f=c.call(t,"e")),s={get:n,set:e,configurable:r,enumerable:f},a?o(i(a),s):s}},function(t,n,e){"use strict";t.exports=e(5)()?Object.assign:e(6)},function(t,n){"use strict";t.exports=function(){var t,n=Object.assign;return"function"!=typeof n?!1:(t={foo:"raz"},n(t,{bar:"dwa"},{trzy:"trzy"}),t.foo+t.bar+t.trzy==="razdwatrzy")}},function(t,n,e){"use strict";var r=e(7),o=e(10),i=Math.max;t.exports=function(t,n){var e,u,c,f=i(arguments.length,2);for(t=Object(o(t)),c=function(r){try{t[r]=n[r]}catch(o){e||(e=o)}},u=1;f>u;++u)n=arguments[u],r(n).forEach(c);if(void 0!==e)throw e;return t}},function(t,n,e){"use strict";t.exports=e(8)()?Object.keys:e(9)},function(t,n){"use strict";t.exports=function(){try{return Object.keys("primitive"),!0}catch(t){return!1}}},function(t,n){"use strict";var e=Object.keys;t.exports=function(t){return e(null==t?t:Object(t))}},function(t,n){"use strict";t.exports=function(t){if(null==t)throw new TypeError("Cannot use null or undefined");return t}},function(t,n){"use strict";var e=Array.prototype.forEach,r=Object.create,o=function(t,n){var e;for(e in t)n[e]=t[e]};t.exports=function(t){var n=r(null);return e.call(arguments,function(t){null!=t&&o(Object(t),n)}),n}},function(t,n){"use strict";t.exports=function(t){return"function"==typeof t}},function(t,n,e){"use strict";t.exports=e(14)()?String.prototype.contains:e(15)},function(t,n){"use strict";var e="razdwatrzy";t.exports=function(){return"function"!=typeof e.contains?!1:e.contains("dwa")===!0&&e.contains("foo")===!1}},function(t,n){"use strict";var e=String.prototype.indexOf;t.exports=function(t){return e.call(this,t,arguments[1])>-1}},function(t,n){"use strict";t.exports=function(t){if("function"!=typeof t)throw new TypeError(t+" is not a function");return t}},function(t,n,e){"use strict";var r=e(18),o=e(10),i=Object.prototype.hasOwnProperty;t.exports=function(t){var n;return o(t),n=arguments[1],arguments.length>1?i.call(t,"__ee__")&&Boolean(t.__ee__[n]):t.hasOwnProperty("__ee__")&&!r(t.__ee__)}},function(t,n,e){"use strict";var r=e(10),o=Object.prototype.propertyIsEnumerable;t.exports=function(t){var n;r(t);for(n in t)if(o.call(t,n))return!1;return!0}},function(t,n,e){var r=e(20),o=e(22),i=e(33)("hypertimer:master");n.createMaster=function(t,n,e){function u(){var t=n();return delete t.time,delete t.master,delete t.port,t}var c=new r.Server({port:e});return c.on("connection",function(n){i("new connection");var e=o(n);e.on("time",function(n,e){var r=t();e(r),i("send time "+new Date(r).toISOString())});var r=u();i("send config",r),e.send("config",r),n.emitter=e}),c.broadcast=function(t,n){i("broadcast",t,n),c.clients.forEach(function(e){e.emitter.send(t,n)})},c.broadcastConfig=function(){c.broadcast("config",u())},c.destroy=function(){c.close(),i("destroyed")},i("listening at ws://localhost:"+e),c}},function(t,n,e){t.exports="undefined"==typeof window||"undefined"==typeof window.WebSocket?e(21):window.WebSocket},function(n,e){n.exports=t},function(t,n,e){var r=e(2),o=e(23),i=e(33)("hypertimer:socket"),u=6e4;t.exports=function(t){function n(n,e){var r={event:n,data:e};i("send",r),t.send(JSON.stringify(r))}function e(n,e){return new o(function(r,o){var f=c(),s={event:n,id:f,data:e};a[f]={resolve:r,reject:o,timeout:setTimeout(function(){delete a[f],o(new Error("Timeout"))},u)},i("request",s),t.send(JSON.stringify(s))})["catch"](function(t){console.log("ERROR",t)})}function c(){return s++}var f=r({socket:t,send:n,request:e});t.onmessage=function(n){var e=n.data,r=JSON.parse(e);i("receive",r);var o=a[r.id];o?(clearTimeout(o.timeout),delete a[r.id],o.resolve(r.data)):"id"in r?f.emit(r.event,r.data,function(n){var e={id:r.id,data:n};t.readyState===t.OPEN||t.readyState===t.CONNECTING?(i("reply",e),t.send(JSON.stringify(e))):i("cancel reply",e,"(socket is closed)")}):f.emit(r.event,r.data)};var a={},s=0;return f}},function(t,n,e){t.exports="undefined"==typeof window||"undefined"==typeof window.Promise?e(24):window.Promise},function(t,n,e){"use strict";t.exports=e(25)},function(t,n,e){"use strict";t.exports=e(26),e(28),e(29),e(30),e(31)},function(t,n,e){"use strict";function r(){}function o(t){try{return t.then}catch(n){return m=n,y}}function i(t,n){try{return t(n)}catch(e){return m=e,y}}function u(t,n,e){try{t(n,e)}catch(r){return m=r,y}}function c(t){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._37=0,this._12=null,this._59=[],t!==r&&d(t,this)}function f(t,n,e){return new t.constructor(function(o,i){var u=new c(r);u.then(o,i),a(t,new h(n,e,u))})}function a(t,n){for(;3===t._37;)t=t._12;return 0===t._37?void t._59.push(n):void v(function(){var e=1===t._37?n.onFulfilled:n.onRejected;if(null===e)return void(1===t._37?s(n.promise,t._12):l(n.promise,t._12));var r=i(e,t._12);r===y?l(n.promise,m):s(n.promise,r)})}function s(t,n){if(n===t)return l(t,new TypeError("A promise cannot be resolved with itself."));if(n&&("object"==typeof n||"function"==typeof n)){var e=o(n);if(e===y)return l(t,m);if(e===t.then&&n instanceof c)return t._37=3,t._12=n,void p(t);if("function"==typeof e)return void d(e.bind(n),t)}t._37=1,t._12=n,p(t)}function l(t,n){t._37=2,t._12=n,p(t)}function p(t){for(var n=0;n<t._59.length;n++)a(t,t._59[n]);t._59=null}function h(t,n,e){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof n?n:null,this.promise=e}function d(t,n){var e=!1,r=u(t,function(t){e||(e=!0,s(n,t))},function(t){e||(e=!0,l(n,t))});e||r!==y||(e=!0,l(n,m))}var v=e(27),m=null,y={};t.exports=c,c._99=r,c.prototype.then=function(t,n){if(this.constructor!==c)return f(this,t,n);var e=new c(r);return a(this,new h(t,n,e)),e}},function(t,n){(function(n){"use strict";function e(t){c.length||(u(),f=!0),c[c.length]=t}function r(){for(;a<c.length;){var t=a;if(a+=1,c[t].call(),a>s){for(var n=0,e=c.length-a;e>n;n++)c[n]=c[n+a];c.length-=a,a=0}}c.length=0,a=0,f=!1}function o(t){var n=1,e=new l(t),r=document.createTextNode("");return e.observe(r,{characterData:!0}),function(){n=-n,r.data=n}}function i(t){return function(){function n(){clearTimeout(e),clearInterval(r),t()}var e=setTimeout(n,0),r=setInterval(n,50)}}t.exports=e;var u,c=[],f=!1,a=0,s=1024,l=n.MutationObserver||n.WebKitMutationObserver;u="function"==typeof l?o(r):i(r),e.requestFlush=u,e.makeRequestCallFromTimer=i}).call(n,function(){return this}())},function(t,n,e){"use strict";var r=e(26);t.exports=r,r.prototype.done=function(t,n){var e=arguments.length?this.then.apply(this,arguments):this;e.then(null,function(t){setTimeout(function(){throw t},0)})}},function(t,n,e){"use strict";var r=e(26);t.exports=r,r.prototype["finally"]=function(t){return this.then(function(n){return r.resolve(t()).then(function(){return n})},function(n){return r.resolve(t()).then(function(){throw n})})}},function(t,n,e){"use strict";function r(t){var n=new o(o._99);return n._37=1,n._12=t,n}var o=e(26);t.exports=o;var i=r(!0),u=r(!1),c=r(null),f=r(void 0),a=r(0),s=r("");o.resolve=function(t){if(t instanceof o)return t;if(null===t)return c;if(void 0===t)return f;if(t===!0)return i;if(t===!1)return u;if(0===t)return a;if(""===t)return s;if("object"==typeof t||"function"==typeof t)try{var n=t.then;if("function"==typeof n)return new o(n.bind(t))}catch(e){return new o(function(t,n){n(e)})}return r(t)},o.all=function(t){var n=Array.prototype.slice.call(t);return new o(function(t,e){function r(u,c){if(c&&("object"==typeof c||"function"==typeof c)){if(c instanceof o&&c.then===o.prototype.then){for(;3===c._37;)c=c._12;return 1===c._37?r(u,c._12):(2===c._37&&e(c._12),void c.then(function(t){r(u,t)},e))}var f=c.then;if("function"==typeof f){var a=new o(f.bind(c));return void a.then(function(t){r(u,t)},e)}}n[u]=c,0===--i&&t(n)}if(0===n.length)return t([]);for(var i=n.length,u=0;u<n.length;u++)r(u,n[u])})},o.reject=function(t){return new o(function(n,e){e(t)})},o.race=function(t){return new o(function(n,e){t.forEach(function(t){o.resolve(t).then(n,e)})})},o.prototype["catch"]=function(t){return this.then(null,t)}},function(t,n,e){"use strict";var r=e(26),o=e(32);t.exports=r,r.denodeify=function(t,n){return n=n||1/0,function(){var e=this,o=Array.prototype.slice.call(arguments,0,n>0?n:0);return new r(function(n,r){o.push(function(t,e){t?r(t):n(e)});var i=t.apply(e,o);!i||"object"!=typeof i&&"function"!=typeof i||"function"!=typeof i.then||n(i)})}},r.nodeify=function(t){return function(){var n=Array.prototype.slice.call(arguments),e="function"==typeof n[n.length-1]?n.pop():null,i=this;try{return t.apply(this,arguments).nodeify(e,i)}catch(u){if(null===e||"undefined"==typeof e)return new r(function(t,n){n(u)});o(function(){e.call(i,u)})}}},r.prototype.nodeify=function(t,n){return"function"!=typeof t?this:void this.then(function(e){o(function(){t.call(n,null,e)})},function(e){o(function(){t.call(n,e)})})}},function(t,n,e){"use strict";function r(){if(f.length)throw f.shift()}function o(t){var n;n=c.length?c.pop():new i,n.task=t,u(n)}function i(){this.task=null}var u=e(27),c=[],f=[],a=u.makeRequestCallFromTimer(r);t.exports=o,i.prototype.call=function(){try{this.task.call()}catch(t){o.onerror?o.onerror(t):(f.push(t),a())}finally{this.task=null,c[c.length]=this}}},function(t,n,e){var r="undefined"!=typeof window?window.Debug:e(34);t.exports=r||function(){return function(){}}},function(t,e){t.exports=n},function(t,n,e){var r=e(20),o=e(23),i=e(33)("hypertimer:slave"),u=e(22),c=e(36),f=e(37),a=36e5,s=1e3,l=5;n.createSlave=function(t){function n(){function t(){var t=null;return v?o.resolve(t):e(h).then(function(n){t=n})["catch"](function(t){console.log(t)}).then(function(){return f.wait(s)}).then(function(){return t})}return f.repeat(t,l).then(function(t){i("latencies",t);var n=t.filter(function(t){return null!==t}),e=c.median(n)+c.std(n),r=n.filter(function(t){return e>t});return r.length>0?c.mean(r):null}).then(function(t){return v?o.resolve(null):h.request("time").then(function(n){var e=n+t;return h.emit("change",e),e})})["catch"](function(t){h.emit("error",t)})}function e(t){var n=Date.now();return t.request("time").then(function(e){var r=Date.now(),o=(r-n)/2,i=e+o;return d&&(d=!1,t.emit("change",i)),o})}var p=new r(t),h=u(p),d=!0,v=!1,m=null;return p.onopen=function(){i("connected"),n(),m=setInterval(n,a)},h.destroy=function(){v=!0,clearInterval(m),m=null,p.close(),i("destroyed")},h}},function(t,n){n.compare=function(t,n){return t>n?1:n>t?-1:0},n.add=function(t,n){return t+n},n.sum=function(t){return t.reduce(n.add)},n.mean=function(t){return n.sum(t)/t.length},n.std=function(t){return Math.sqrt(n.variance(t))},n.variance=function(t){if(t.length<2)return 0;var e=n.mean(t);return t.map(function(t){return Math.pow(t-e,2)}).reduce(n.add)/(t.length-1)},n.median=function(t){if(t.length<2)return t[0];var e=t.slice().sort(n.compare);return e.length%2===0?(t[t.length/2-1]+t[t.length/2])/2:t[(t.length-1)/2]}},function(t,n,e){var r=e(23);n.wait=function(t){return new r(function(n){setTimeout(n,t)})},n.repeat=function(t,n){return new r(function(e,r){function o(){n>i?(i++,t().then(function(t){u.push(t),o()})):e(u)}var i=0,u=[];o()})},n.whilst=function(t,n){return new r(function(e,r){function o(){t()?n().then(function(){o()}):e()}o()})}},function(t,n){"function"==typeof Date.now?n.systemNow=function(){return Date.now()}:n.systemNow=function(){return(new Date).valueOf()},n.shuffle=function(t){for(var n,e,r=t.length;r;n=Math.floor(Math.random()*r),e=t[--r],t[r]=t[n],t[n]=e);return t}}])});
//# sourceMappingURL=hypertimer.map
# History
## 2015-12-08, version 2.1.3
- Upgraded dependencies to the latest versions.
## 2015-07-13, version 2.1.2

@@ -5,0 +10,0 @@

{
"name": "hypertimer",
"version": "2.1.2",
"version": "2.1.3",
"description": "Time control for simulations",

@@ -22,20 +22,20 @@ "author": "Jos de Jong <wjosdejong@gmail.com> (https://github.com/josdejong)",

"dependencies": {
"body-parser": "^1.12.0",
"debug": "^2.1.1",
"event-emitter": "^0.3.3",
"node-uuid": "^1.4.2",
"promise": "^6.1.0",
"ws": "^0.7.1"
"body-parser": "1.14.1",
"debug": "2.2.0",
"event-emitter": "0.3.4",
"node-uuid": "1.4.7",
"promise": "7.0.4",
"ws": "0.8.1"
},
"devDependencies": {
"async": "^0.9.0",
"browserify": "^8.1.3",
"freeport": "^1.0.4",
"gulp": "^3.8.11",
"gulp-util": "^3.0.3",
"istanbul": "^0.3.6",
"mocha": "^2.1.0",
"seed-random": "^2.2.0",
"uglify-js": "^2.4.16",
"webpack": "^1.5.3"
"async": "1.5.0",
"browserify": "12.0.1",
"freeport": "1.0.5",
"gulp": "3.9.0",
"gulp-util": "3.0.7",
"istanbul": "0.4.1",
"mocha": "2.3.4",
"seed-random": "2.2.0",
"uglify-js": "2.6.1",
"webpack": "1.12.9"
},

@@ -42,0 +42,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc