From a2ae7fe4fa927d5d93ac34c5e342659e44583be3 Mon Sep 17 00:00:00 2001 From: Wilfried Hounyo Date: Fri, 20 Oct 2017 19:14:52 -0400 Subject: [PATCH] Add Timeline Docs --- dist/amd/Display.debug.js | 252 +- dist/amd/Display.js | 252 +- dist/amd/Display.min.debug.js | 2 +- dist/amd/Display.min.js | 2 +- dist/amd/DisplayCoordinator.debug.js | 51 +- dist/amd/DisplayCoordinator.js | 51 +- dist/amd/Displays.debug.js | 255 +- dist/amd/Displays.js | 255 +- dist/amd/Displays.min.debug.js | 2 +- dist/amd/Displays.min.js | 2 +- dist/amd/Timeline.debug.js | 48 +- dist/amd/Timeline.js | 48 +- dist/commonjs2/Display.debug.js | 252 +- dist/commonjs2/Display.js | 252 +- dist/commonjs2/Display.min.debug.js | 2 +- dist/commonjs2/Display.min.js | 2 +- dist/commonjs2/DisplayCoordinator.debug.js | 51 +- dist/commonjs2/DisplayCoordinator.js | 51 +- dist/commonjs2/Displays.debug.js | 255 +- dist/commonjs2/Displays.js | 255 +- dist/commonjs2/Displays.min.debug.js | 2 +- dist/commonjs2/Displays.min.js | 2 +- dist/commonjs2/Timeline.debug.js | 48 +- dist/commonjs2/Timeline.js | 48 +- dist/umd/Display.debug.js | 252 +- dist/umd/Display.js | 252 +- dist/umd/Display.min.debug.js | 2 +- dist/umd/Display.min.js | 2 +- dist/umd/DisplayCoordinator.debug.js | 51 +- dist/umd/DisplayCoordinator.js | 51 +- dist/umd/Displays.debug.js | 255 +- dist/umd/Displays.js | 255 +- dist/umd/Displays.min.debug.js | 2 +- dist/umd/Displays.min.js | 2 +- dist/umd/Timeline.debug.js | 48 +- dist/umd/Timeline.js | 48 +- dist/var/Display.debug.js | 252 +- dist/var/Display.js | 252 +- dist/var/Display.min.debug.js | 2 +- dist/var/Display.min.js | 2 +- dist/var/DisplayCoordinator.debug.js | 51 +- dist/var/DisplayCoordinator.js | 51 +- dist/var/Displays.debug.js | 255 +- dist/var/Displays.js | 255 +- dist/var/Displays.min.debug.js | 2 +- dist/var/Displays.min.js | 2 +- dist/var/Timeline.debug.js | 48 +- dist/var/Timeline.js | 48 +- docs/API.json | 6816 ++++++++++++++++---- docs/API.md | 255 +- docs/index.html | 1530 ++++- src/timeline.js | 43 +- 52 files changed, 11111 insertions(+), 2413 deletions(-) diff --git a/dist/amd/Display.debug.js b/dist/amd/Display.debug.js index 9de04de..43a0479 100644 --- a/dist/amd/Display.debug.js +++ b/dist/amd/Display.debug.js @@ -78,7 +78,11 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons var NOT_FOUND = "NOTFOUND"; /** - * Class representing a time action. + * TimeAction is the class representing a time Action that can occur in a Timeline. + * + * @param {function} func Reference to a function to call on trigger + * @param {Object} args A list of arguments to pass to the func on trigger. + * @param {String} name (** optional **) A name for the TimeAction */ var TimeAction = function () { @@ -97,6 +101,11 @@ var TimeAction = function () { value: function toString() { return 'TimeAction:(' + this.name + ')'; } + + /** + * Trigger an action by calling *func* and passing it *args* passed from initialization. + */ + }, { key: "trigger", value: function trigger() { @@ -110,6 +119,14 @@ var TimeAction = function () { ; +/** + * Timeline with many actions + * + * @param {Object} args Object containing Timeline args. + * @param {String} [args.name="undefined"] The name of the Timeline. + * @param {Number} [args.treshold=5] The treshold for calling TimeActions + */ + var Timeline = function () { function Timeline(args) { _classCallCheck(this, Timeline); @@ -124,6 +141,15 @@ var Timeline = function () { value: function toString() { return '(' + this.name + ')'; } + + /** + * Add a time action to the timeline. + * @param {Number} time The time value at which to perform the action + * @param {function} action The function to call when trigger + * @param {Array} [args=[]] The args to pass to function on trigger + * @param {String} [name="undefined"] The name of the TimeAction + */ + }, { key: "addTimeAction", value: function addTimeAction(time, action) { @@ -135,6 +161,12 @@ var Timeline = function () { } this.time_actions[time] = new TimeAction(action, args, name); } + + /** + * This function triggers the TimeAction on the Timeline at the given time if there is one. + * @param {Number} time The time value at which the action is at. + */ + }, { key: "callTimeAction", value: function callTimeAction(time) { @@ -142,6 +174,13 @@ var Timeline = function () { this.time_actions[time].trigger(); } } + + /** + * This function triggers the nearest TimeAction on the Timeline within the treshold + * of the Timeline. + * @param {Number} time The time value to call action within treshold for. + */ + }, { key: "callNearestTimeAction", value: function callNearestTimeAction(time) { @@ -156,6 +195,13 @@ var Timeline = function () { this.time_actions[t].trigger(); } } + + /** + * This function is a helper to get the nearest time value within the Timeline's treshold + * @param {Number} time The time to look within Timeline treshold + * @return {Number} The value within treshold. "NOT_FOUND" if no value within treshold. + */ + }, { key: "getNearestTime", value: function getNearestTime(time) { @@ -191,14 +237,22 @@ var _timeline = __webpack_require__(0); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -/** -* MODES is different modes a display may have -* Normal is the default Display mode -* User is a state where user is interacting with the Display instance -* Note: Implementation depends on Display -**/ +// An object with modes available to a Display. +// MODES are used to track Display modes. +// Such as User Interaction Mode vs Normal Display Mode. var MODES = { NORMAL: 0, USER: 1 }; +/** + * The Base class for all Displays. + * + * @param {Object} args An object with arguments to initialize the display. + * + * @param {String} args.name Name of Display Instance + * @param {Number} args.timeline_treshold A treshold of error for picking a time action for the display + * + * @param {Object} args.context (** optional**) Reference to DisplayCoordinator's context + */ + var Display = function () { function Display(args) { _classCallCheck(this, Display); @@ -217,6 +271,13 @@ var Display = function () { value: function toString() { return '(' + this.name + ')'; } + + /** + * Set the context for the Display. + * + * @param {Object} context DisplayCoordinator's context + */ + }, { key: "setContext", value: function setContext(context) { @@ -225,9 +286,11 @@ var Display = function () { this.context.emitter.on("pause", this.handlePause.bind(this)); this.context.emitter.on("continue", this.handleContinue.bind(this)); } + /** - * This function set's the Display instance as being ready. - **/ + * Set the the Display's ready state to True. + * + */ }, { key: "setAsReady", @@ -237,27 +300,34 @@ var Display = function () { this.context.emitter.emit("ready"); } } + /** - * This is just a getter to check if the dislay ready. - **/ + * Check if Display is ready + * + * @return {Boolean} True if Ready, False otherwise + */ }, { key: "ready", value: function ready() { return this.m_ready; } + /** - * This set's the display as being the primary display. - **/ + * Set the Display as the Primary Display for a performance. + */ }, { key: "setAsPrimaryDisplay", value: function setAsPrimaryDisplay() { this.is_primary_display = true; } + /** - * This is a getter to check if a display is the primary display - **/ + * Check if the Display is the PrimaryDisplay for the performance + * + * @return {Boolean} True if PrimaryDisplay, False otherwise + */ }, { key: "isPrimaryDisplay", @@ -268,12 +338,17 @@ var Display = function () { return false; } } + /** - * Note: Tick should dependent per display. - * By default it ticks by 1 however it can be overwritten - * by a display implementation. - * *** Only Primary Display should tick. - **/ + * This function is responsible for controling time flow for a performance + * if the Display is the PrimaryDisplay in a performance. + * + * ** Note ** Your Display implementation may override this to properly handle + * time tick as needed. + * * By default, this function increments the time flow by 1 and emits it to all + * listeners in the performance. + * * Ensure that the Display is the PrimaryDisplay before controlling time. + */ }, { key: "tick", @@ -283,41 +358,35 @@ var Display = function () { this.context.time += 1; } } - /** - * Seek skips to a given time. - * @t : Time to skip to - **/ - }, { - key: "seek", - value: function seek(t) { - this.timeline.callTimeAction(t); - } /** - ** Helper to enable user mode - * Only use this if UserMode is needed - * - **/ + * This function sets the Display mode to user mode. + * + * ** Note ** + * Only use this if user mode is needed + */ }, { key: "enableUserMode", value: function enableUserMode() { - return this.mode = MODES.USER; + this.mode = MODES.USER; } + /** - ** Helper to disable user mode - * Only use this if UserMode is used - * - **/ + * This function changes the Display mode to Normal mode. + * + */ }, { key: "releaseUserMode", value: function releaseUserMode() { - return this.mode = MODES.NORMAL; + this.mode = MODES.NORMAL; } + /** - * Getter to check if in UserMode - **/ + * Check if Display is in user mode + * @return {Boolean} True if in user mode, False otherwise + */ }, { key: "isInUserMode", @@ -327,39 +396,124 @@ var Display = function () { } return false; } + /** - * Listener for tick actions - * Handles call to Timeline for current tick. - **/ + * Handles tick events for the Display. + * + * ** Note ** + * When a tick event is emitted in the performance, this function get's trigered. + * + * You may overwrite this function to better handle your Display implementation's + * case. + * * By default it calls the nearest TimeAction at the current performance time. + */ }, { key: "handleTick", value: function handleTick() { this.timeline.callTimeAction(this.context.time); } + /** - * Listener for pause action - * Handles call to Timeline for current tick. - **/ + * This function handles any pause event triggered by in a performance. + * + * ** Note ** + * By default it calls the Display's pause function. + * * This may be overwritten to handle pause events differently for the Display implementation. + * @TODO Implement handlePause default action + */ }, { key: "handlePause", value: function handlePause() {} + + /** + * This function handles any continue event triggered by in a performance. Ussually after a pause. + * + * ** Note ** + * By default it calls the Display's play function. + * + * * This may be overwritten to handle continue events differently for the Display implementation. + * @TODO Implement handleContinue default action + */ + }, { key: "handleContinue", value: function handleContinue() {} + + /** + * This function is a placeholder to perform any setup the Display needs done.. + * + * ** Note ** + * You **need** to overwrite this function to do handle anything the Display needs + * to setup. + * + * It is a good idea to mark the Display as ready here. Or in render(). + * + */ + }, { key: "setup", value: function setup() {} + + /** + * This function is a placeholder to be overwritten to handle any rendering that + * needs to performed at startup after setup in the performance. + * + * ** Note ** + * You **need** to overwrite this function to do handle anything the Display needs + * to render. + * + * (** optional **) This can return a value to be appended to the DisplayCoordinator's Stage. + */ + }, { key: "render", value: function render() {} + + /** + * This function pauses the Display and does not respond to Ticks + * + * @TODO Implement pause default Action. + */ + + }, { + key: "pause", + value: function pause() {} + + /** + * This function removes the Display from a pause state and performs the action + * from the Display's timeline at the current performance time (context.time). + * + * ** Note ** + * You may overwrite this function to do what you'd prefer in your Display implementation. + * @TODO Implement play default Action. + */ + }, { key: "play", value: function play() {} + + /** + * This function skips to a given time for the Display. + * + * @param {Number} t The time to skip to. + */ + }, { - key: "pause", - value: function pause() {} + key: "seek", + value: function seek(t) { + this.timeline.callTimeAction(t); + } + + /** + * This function resets the Display's timeline back to 0 + * + * ** Note ** + * You may overwrite this function to do what you'd prefer in your Display implementation. + * @TODO Implement reset default Action. + */ + }, { key: "reset", value: function reset() {} diff --git a/dist/amd/Display.js b/dist/amd/Display.js index 9de04de..43a0479 100644 --- a/dist/amd/Display.js +++ b/dist/amd/Display.js @@ -78,7 +78,11 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons var NOT_FOUND = "NOTFOUND"; /** - * Class representing a time action. + * TimeAction is the class representing a time Action that can occur in a Timeline. + * + * @param {function} func Reference to a function to call on trigger + * @param {Object} args A list of arguments to pass to the func on trigger. + * @param {String} name (** optional **) A name for the TimeAction */ var TimeAction = function () { @@ -97,6 +101,11 @@ var TimeAction = function () { value: function toString() { return 'TimeAction:(' + this.name + ')'; } + + /** + * Trigger an action by calling *func* and passing it *args* passed from initialization. + */ + }, { key: "trigger", value: function trigger() { @@ -110,6 +119,14 @@ var TimeAction = function () { ; +/** + * Timeline with many actions + * + * @param {Object} args Object containing Timeline args. + * @param {String} [args.name="undefined"] The name of the Timeline. + * @param {Number} [args.treshold=5] The treshold for calling TimeActions + */ + var Timeline = function () { function Timeline(args) { _classCallCheck(this, Timeline); @@ -124,6 +141,15 @@ var Timeline = function () { value: function toString() { return '(' + this.name + ')'; } + + /** + * Add a time action to the timeline. + * @param {Number} time The time value at which to perform the action + * @param {function} action The function to call when trigger + * @param {Array} [args=[]] The args to pass to function on trigger + * @param {String} [name="undefined"] The name of the TimeAction + */ + }, { key: "addTimeAction", value: function addTimeAction(time, action) { @@ -135,6 +161,12 @@ var Timeline = function () { } this.time_actions[time] = new TimeAction(action, args, name); } + + /** + * This function triggers the TimeAction on the Timeline at the given time if there is one. + * @param {Number} time The time value at which the action is at. + */ + }, { key: "callTimeAction", value: function callTimeAction(time) { @@ -142,6 +174,13 @@ var Timeline = function () { this.time_actions[time].trigger(); } } + + /** + * This function triggers the nearest TimeAction on the Timeline within the treshold + * of the Timeline. + * @param {Number} time The time value to call action within treshold for. + */ + }, { key: "callNearestTimeAction", value: function callNearestTimeAction(time) { @@ -156,6 +195,13 @@ var Timeline = function () { this.time_actions[t].trigger(); } } + + /** + * This function is a helper to get the nearest time value within the Timeline's treshold + * @param {Number} time The time to look within Timeline treshold + * @return {Number} The value within treshold. "NOT_FOUND" if no value within treshold. + */ + }, { key: "getNearestTime", value: function getNearestTime(time) { @@ -191,14 +237,22 @@ var _timeline = __webpack_require__(0); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -/** -* MODES is different modes a display may have -* Normal is the default Display mode -* User is a state where user is interacting with the Display instance -* Note: Implementation depends on Display -**/ +// An object with modes available to a Display. +// MODES are used to track Display modes. +// Such as User Interaction Mode vs Normal Display Mode. var MODES = { NORMAL: 0, USER: 1 }; +/** + * The Base class for all Displays. + * + * @param {Object} args An object with arguments to initialize the display. + * + * @param {String} args.name Name of Display Instance + * @param {Number} args.timeline_treshold A treshold of error for picking a time action for the display + * + * @param {Object} args.context (** optional**) Reference to DisplayCoordinator's context + */ + var Display = function () { function Display(args) { _classCallCheck(this, Display); @@ -217,6 +271,13 @@ var Display = function () { value: function toString() { return '(' + this.name + ')'; } + + /** + * Set the context for the Display. + * + * @param {Object} context DisplayCoordinator's context + */ + }, { key: "setContext", value: function setContext(context) { @@ -225,9 +286,11 @@ var Display = function () { this.context.emitter.on("pause", this.handlePause.bind(this)); this.context.emitter.on("continue", this.handleContinue.bind(this)); } + /** - * This function set's the Display instance as being ready. - **/ + * Set the the Display's ready state to True. + * + */ }, { key: "setAsReady", @@ -237,27 +300,34 @@ var Display = function () { this.context.emitter.emit("ready"); } } + /** - * This is just a getter to check if the dislay ready. - **/ + * Check if Display is ready + * + * @return {Boolean} True if Ready, False otherwise + */ }, { key: "ready", value: function ready() { return this.m_ready; } + /** - * This set's the display as being the primary display. - **/ + * Set the Display as the Primary Display for a performance. + */ }, { key: "setAsPrimaryDisplay", value: function setAsPrimaryDisplay() { this.is_primary_display = true; } + /** - * This is a getter to check if a display is the primary display - **/ + * Check if the Display is the PrimaryDisplay for the performance + * + * @return {Boolean} True if PrimaryDisplay, False otherwise + */ }, { key: "isPrimaryDisplay", @@ -268,12 +338,17 @@ var Display = function () { return false; } } + /** - * Note: Tick should dependent per display. - * By default it ticks by 1 however it can be overwritten - * by a display implementation. - * *** Only Primary Display should tick. - **/ + * This function is responsible for controling time flow for a performance + * if the Display is the PrimaryDisplay in a performance. + * + * ** Note ** Your Display implementation may override this to properly handle + * time tick as needed. + * * By default, this function increments the time flow by 1 and emits it to all + * listeners in the performance. + * * Ensure that the Display is the PrimaryDisplay before controlling time. + */ }, { key: "tick", @@ -283,41 +358,35 @@ var Display = function () { this.context.time += 1; } } - /** - * Seek skips to a given time. - * @t : Time to skip to - **/ - }, { - key: "seek", - value: function seek(t) { - this.timeline.callTimeAction(t); - } /** - ** Helper to enable user mode - * Only use this if UserMode is needed - * - **/ + * This function sets the Display mode to user mode. + * + * ** Note ** + * Only use this if user mode is needed + */ }, { key: "enableUserMode", value: function enableUserMode() { - return this.mode = MODES.USER; + this.mode = MODES.USER; } + /** - ** Helper to disable user mode - * Only use this if UserMode is used - * - **/ + * This function changes the Display mode to Normal mode. + * + */ }, { key: "releaseUserMode", value: function releaseUserMode() { - return this.mode = MODES.NORMAL; + this.mode = MODES.NORMAL; } + /** - * Getter to check if in UserMode - **/ + * Check if Display is in user mode + * @return {Boolean} True if in user mode, False otherwise + */ }, { key: "isInUserMode", @@ -327,39 +396,124 @@ var Display = function () { } return false; } + /** - * Listener for tick actions - * Handles call to Timeline for current tick. - **/ + * Handles tick events for the Display. + * + * ** Note ** + * When a tick event is emitted in the performance, this function get's trigered. + * + * You may overwrite this function to better handle your Display implementation's + * case. + * * By default it calls the nearest TimeAction at the current performance time. + */ }, { key: "handleTick", value: function handleTick() { this.timeline.callTimeAction(this.context.time); } + /** - * Listener for pause action - * Handles call to Timeline for current tick. - **/ + * This function handles any pause event triggered by in a performance. + * + * ** Note ** + * By default it calls the Display's pause function. + * * This may be overwritten to handle pause events differently for the Display implementation. + * @TODO Implement handlePause default action + */ }, { key: "handlePause", value: function handlePause() {} + + /** + * This function handles any continue event triggered by in a performance. Ussually after a pause. + * + * ** Note ** + * By default it calls the Display's play function. + * + * * This may be overwritten to handle continue events differently for the Display implementation. + * @TODO Implement handleContinue default action + */ + }, { key: "handleContinue", value: function handleContinue() {} + + /** + * This function is a placeholder to perform any setup the Display needs done.. + * + * ** Note ** + * You **need** to overwrite this function to do handle anything the Display needs + * to setup. + * + * It is a good idea to mark the Display as ready here. Or in render(). + * + */ + }, { key: "setup", value: function setup() {} + + /** + * This function is a placeholder to be overwritten to handle any rendering that + * needs to performed at startup after setup in the performance. + * + * ** Note ** + * You **need** to overwrite this function to do handle anything the Display needs + * to render. + * + * (** optional **) This can return a value to be appended to the DisplayCoordinator's Stage. + */ + }, { key: "render", value: function render() {} + + /** + * This function pauses the Display and does not respond to Ticks + * + * @TODO Implement pause default Action. + */ + + }, { + key: "pause", + value: function pause() {} + + /** + * This function removes the Display from a pause state and performs the action + * from the Display's timeline at the current performance time (context.time). + * + * ** Note ** + * You may overwrite this function to do what you'd prefer in your Display implementation. + * @TODO Implement play default Action. + */ + }, { key: "play", value: function play() {} + + /** + * This function skips to a given time for the Display. + * + * @param {Number} t The time to skip to. + */ + }, { - key: "pause", - value: function pause() {} + key: "seek", + value: function seek(t) { + this.timeline.callTimeAction(t); + } + + /** + * This function resets the Display's timeline back to 0 + * + * ** Note ** + * You may overwrite this function to do what you'd prefer in your Display implementation. + * @TODO Implement reset default Action. + */ + }, { key: "reset", value: function reset() {} diff --git a/dist/amd/Display.min.debug.js b/dist/amd/Display.min.debug.js index fea9413..dd3ec5b 100644 --- a/dist/amd/Display.min.debug.js +++ b/dist/amd/Display.min.debug.js @@ -1 +1 @@ -define("Display",[],function(){return function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=8)}({0:function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(e,t){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:"undefined";i(this,e),this.action=t,this.args=n,this.name=r}return r(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),a=function(){function e(t){i(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return r(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(n)&&(n=[n]),this.time_actions[e]=new o(t,n,i)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:"undefined";i(this,e),this.action=t,this.args=n,this.name=r}return r(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),a=function(){function e(t){i(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return r(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(n)&&(n=[n]),this.time_actions[e]=new o(t,n,i)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:"undefined";i(this,e),this.action=t,this.args=n,this.name=r}return r(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),a=function(){function e(t){i(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return r(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(n)&&(n=[n]),this.time_actions[e]=new o(t,n,i)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:"undefined";i(this,e),this.action=t,this.args=n,this.name=r}return r(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),a=function(){function e(t){i(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return r(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(n)&&(n=[n]),this.time_actions[e]=new o(t,n,i)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:"undefined";n(this,e),this.action=t,this.args=i,this.name=r}return r(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),o=function(){function e(t){n(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return r(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(i)&&(i=[i]),this.time_actions[e]=new s(t,i,n)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t0&&r._listeners.length>this._maxListeners&&(r._listeners.warned=!0,c.call(this,r._listeners.length,s))):r._listeners=t,!0;s=e.shift()}return!0}var y=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},p=10;h.EventEmitter2=h,h.prototype.delimiter=".",h.prototype.setMaxListeners=function(e){e!==o&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},h.prototype.event="",h.prototype.once=function(e,t){return this._once(e,t,!1)},h.prototype.prependOnceListener=function(e,t){return this._once(e,t,!0)},h.prototype._once=function(e,t,i){return this._many(e,1,t,i),this},h.prototype.many=function(e,t,i){return this._many(e,t,i,!1)},h.prototype.prependMany=function(e,t,i){return this._many(e,t,i,!0)},h.prototype._many=function(e,t,i,n){function r(){return 0==--t&&s.off(e,r),i.apply(this,arguments)}var s=this;if("function"!=typeof i)throw new Error("many only accepts instances of Function");return r._origin=i,this._on(e,r,n),s},h.prototype.emit=function(){this._events||a.call(this);var e=arguments[0];if("newListener"===e&&!this.newListener&&!this._events.newListener)return!1;var t,i,n,r,s,o=arguments.length;if(this._all&&this._all.length){if(s=this._all.slice(),o>3)for(t=new Array(o),r=0;r3)for(t=new Array(o-1),r=1;r3)for(t=new Array(l),r=1;r3)for(t=new Array(l-1),r=1;r0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,c.call(this,this._events[e].length,e))):this._events[e]=t,this)},h.prototype.off=function(e,t){function i(e){if(e!==o){var t=Object.keys(e);for(var n in t){var r=t[n],a=e[r];a instanceof Function||"object"!==(void 0===a?"undefined":s(a))||null===a||(Object.keys(a).length>0&&i(e[r]),0===Object.keys(a).length&&delete e[r])}}}if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var n,r=[];if(this.wildcard){var a="string"==typeof e?e.split(this.delimiter):e.slice();r=u.call(this,null,a,this.listenerTree,0)}else{if(!this._events[e])return this;n=this._events[e],r.push({_listeners:n})}for(var l=0;l0){for(t=this._all,i=0,n=t.length;i1)for(var i=1;i2&&void 0!==arguments[2]?arguments[2]:"undefined";n(this,e),this.action=t,this.args=i,this.name=s}return s(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),o=function(){function e(t){n(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return s(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(i)&&(i=[i]),this.time_actions[e]=new r(t,i,n)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t0&&s._listeners.length>this._maxListeners&&(s._listeners.warned=!0,c.call(this,s._listeners.length,r))):s._listeners=t,!0;r=e.shift()}return!0}var y=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},p=10;h.EventEmitter2=h,h.prototype.delimiter=".",h.prototype.setMaxListeners=function(e){e!==o&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},h.prototype.event="",h.prototype.once=function(e,t){return this._once(e,t,!1)},h.prototype.prependOnceListener=function(e,t){return this._once(e,t,!0)},h.prototype._once=function(e,t,i){return this._many(e,1,t,i),this},h.prototype.many=function(e,t,i){return this._many(e,t,i,!1)},h.prototype.prependMany=function(e,t,i){return this._many(e,t,i,!0)},h.prototype._many=function(e,t,i,n){function s(){return 0==--t&&r.off(e,s),i.apply(this,arguments)}var r=this;if("function"!=typeof i)throw new Error("many only accepts instances of Function");return s._origin=i,this._on(e,s,n),r},h.prototype.emit=function(){this._events||a.call(this);var e=arguments[0];if("newListener"===e&&!this.newListener&&!this._events.newListener)return!1;var t,i,n,s,r,o=arguments.length;if(this._all&&this._all.length){if(r=this._all.slice(),o>3)for(t=new Array(o),s=0;s3)for(t=new Array(o-1),s=1;s3)for(t=new Array(l),s=1;s3)for(t=new Array(l-1),s=1;s0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,c.call(this,this._events[e].length,e))):this._events[e]=t,this)},h.prototype.off=function(e,t){function i(e){if(e!==o){var t=Object.keys(e);for(var n in t){var s=t[n],a=e[s];a instanceof Function||"object"!==(void 0===a?"undefined":r(a))||null===a||(Object.keys(a).length>0&&i(e[s]),0===Object.keys(a).length&&delete e[s])}}}if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var n,s=[];if(this.wildcard){var a="string"==typeof e?e.split(this.delimiter):e.slice();s=u.call(this,null,a,this.listenerTree,0)}else{if(!this._events[e])return this;n=this._events[e],s.push({_listeners:n})}for(var l=0;l0){for(t=this._all,i=0,n=t.length;i1)for(var i=1;i2&&void 0!==arguments[2]?arguments[2]:"undefined";n(this,e),this.action=t,this.args=i,this.name=r}return r(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),o=function(){function e(t){n(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return r(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(i)&&(i=[i]),this.time_actions[e]=new s(t,i,n)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t0&&r._listeners.length>this._maxListeners&&(r._listeners.warned=!0,c.call(this,r._listeners.length,s))):r._listeners=t,!0;s=e.shift()}return!0}var y=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},p=10;h.EventEmitter2=h,h.prototype.delimiter=".",h.prototype.setMaxListeners=function(e){e!==o&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},h.prototype.event="",h.prototype.once=function(e,t){return this._once(e,t,!1)},h.prototype.prependOnceListener=function(e,t){return this._once(e,t,!0)},h.prototype._once=function(e,t,i){return this._many(e,1,t,i),this},h.prototype.many=function(e,t,i){return this._many(e,t,i,!1)},h.prototype.prependMany=function(e,t,i){return this._many(e,t,i,!0)},h.prototype._many=function(e,t,i,n){function r(){return 0==--t&&s.off(e,r),i.apply(this,arguments)}var s=this;if("function"!=typeof i)throw new Error("many only accepts instances of Function");return r._origin=i,this._on(e,r,n),s},h.prototype.emit=function(){this._events||a.call(this);var e=arguments[0];if("newListener"===e&&!this.newListener&&!this._events.newListener)return!1;var t,i,n,r,s,o=arguments.length;if(this._all&&this._all.length){if(s=this._all.slice(),o>3)for(t=new Array(o),r=0;r3)for(t=new Array(o-1),r=1;r3)for(t=new Array(l),r=1;r3)for(t=new Array(l-1),r=1;r0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,c.call(this,this._events[e].length,e))):this._events[e]=t,this)},h.prototype.off=function(e,t){function i(e){if(e!==o){var t=Object.keys(e);for(var n in t){var r=t[n],a=e[r];a instanceof Function||"object"!==(void 0===a?"undefined":s(a))||null===a||(Object.keys(a).length>0&&i(e[r]),0===Object.keys(a).length&&delete e[r])}}}if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var n,r=[];if(this.wildcard){var a="string"==typeof e?e.split(this.delimiter):e.slice();r=u.call(this,null,a,this.listenerTree,0)}else{if(!this._events[e])return this;n=this._events[e],r.push({_listeners:n})}for(var l=0;l0){for(t=this._all,i=0,n=t.length;i1)for(var i=1;i2&&void 0!==arguments[2]?arguments[2]:"undefined";n(this,e),this.action=t,this.args=i,this.name=s}return s(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),o=function(){function e(t){n(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return s(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(i)&&(i=[i]),this.time_actions[e]=new r(t,i,n)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t0&&s._listeners.length>this._maxListeners&&(s._listeners.warned=!0,c.call(this,s._listeners.length,r))):s._listeners=t,!0;r=e.shift()}return!0}var y=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},p=10;h.EventEmitter2=h,h.prototype.delimiter=".",h.prototype.setMaxListeners=function(e){e!==o&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},h.prototype.event="",h.prototype.once=function(e,t){return this._once(e,t,!1)},h.prototype.prependOnceListener=function(e,t){return this._once(e,t,!0)},h.prototype._once=function(e,t,i){return this._many(e,1,t,i),this},h.prototype.many=function(e,t,i){return this._many(e,t,i,!1)},h.prototype.prependMany=function(e,t,i){return this._many(e,t,i,!0)},h.prototype._many=function(e,t,i,n){function s(){return 0==--t&&r.off(e,s),i.apply(this,arguments)}var r=this;if("function"!=typeof i)throw new Error("many only accepts instances of Function");return s._origin=i,this._on(e,s,n),r},h.prototype.emit=function(){this._events||a.call(this);var e=arguments[0];if("newListener"===e&&!this.newListener&&!this._events.newListener)return!1;var t,i,n,s,r,o=arguments.length;if(this._all&&this._all.length){if(r=this._all.slice(),o>3)for(t=new Array(o),s=0;s3)for(t=new Array(o-1),s=1;s3)for(t=new Array(l),s=1;s3)for(t=new Array(l-1),s=1;s0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,c.call(this,this._events[e].length,e))):this._events[e]=t,this)},h.prototype.off=function(e,t){function i(e){if(e!==o){var t=Object.keys(e);for(var n in t){var s=t[n],a=e[s];a instanceof Function||"object"!==(void 0===a?"undefined":r(a))||null===a||(Object.keys(a).length>0&&i(e[s]),0===Object.keys(a).length&&delete e[s])}}}if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var n,s=[];if(this.wildcard){var a="string"==typeof e?e.split(this.delimiter):e.slice();s=u.call(this,null,a,this.listenerTree,0)}else{if(!this._events[e])return this;n=this._events[e],s.push({_listeners:n})}for(var l=0;l0){for(t=this._all,i=0,n=t.length;i1)for(var i=1;i2&&void 0!==arguments[2]?arguments[2]:"undefined";i(this,e),this.action=t,this.args=n,this.name=r}return r(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),a=function(){function e(t){i(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return r(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(n)&&(n=[n]),this.time_actions[e]=new o(t,n,i)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:"undefined";i(this,e),this.action=t,this.args=n,this.name=r}return r(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),a=function(){function e(t){i(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return r(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(n)&&(n=[n]),this.time_actions[e]=new o(t,n,i)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:"undefined";i(this,e),this.action=t,this.args=n,this.name=r}return r(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),a=function(){function e(t){i(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return r(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(n)&&(n=[n]),this.time_actions[e]=new o(t,n,i)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:"undefined";i(this,e),this.action=t,this.args=n,this.name=r}return r(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),a=function(){function e(t){i(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return r(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(n)&&(n=[n]),this.time_actions[e]=new o(t,n,i)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:"undefined";n(this,e),this.action=t,this.args=i,this.name=r}return r(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),o=function(){function e(t){n(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return r(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(i)&&(i=[i]),this.time_actions[e]=new s(t,i,n)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t0&&r._listeners.length>this._maxListeners&&(r._listeners.warned=!0,c.call(this,r._listeners.length,s))):r._listeners=t,!0;s=e.shift()}return!0}var y=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},p=10;h.EventEmitter2=h,h.prototype.delimiter=".",h.prototype.setMaxListeners=function(e){e!==o&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},h.prototype.event="",h.prototype.once=function(e,t){return this._once(e,t,!1)},h.prototype.prependOnceListener=function(e,t){return this._once(e,t,!0)},h.prototype._once=function(e,t,i){return this._many(e,1,t,i),this},h.prototype.many=function(e,t,i){return this._many(e,t,i,!1)},h.prototype.prependMany=function(e,t,i){return this._many(e,t,i,!0)},h.prototype._many=function(e,t,i,n){function r(){return 0==--t&&s.off(e,r),i.apply(this,arguments)}var s=this;if("function"!=typeof i)throw new Error("many only accepts instances of Function");return r._origin=i,this._on(e,r,n),s},h.prototype.emit=function(){this._events||a.call(this);var e=arguments[0];if("newListener"===e&&!this.newListener&&!this._events.newListener)return!1;var t,i,n,r,s,o=arguments.length;if(this._all&&this._all.length){if(s=this._all.slice(),o>3)for(t=new Array(o),r=0;r3)for(t=new Array(o-1),r=1;r3)for(t=new Array(l),r=1;r3)for(t=new Array(l-1),r=1;r0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,c.call(this,this._events[e].length,e))):this._events[e]=t,this)},h.prototype.off=function(e,t){function i(e){if(e!==o){var t=Object.keys(e);for(var n in t){var r=t[n],a=e[r];a instanceof Function||"object"!==(void 0===a?"undefined":s(a))||null===a||(Object.keys(a).length>0&&i(e[r]),0===Object.keys(a).length&&delete e[r])}}}if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var n,r=[];if(this.wildcard){var a="string"==typeof e?e.split(this.delimiter):e.slice();r=u.call(this,null,a,this.listenerTree,0)}else{if(!this._events[e])return this;n=this._events[e],r.push({_listeners:n})}for(var l=0;l0){for(t=this._all,i=0,n=t.length;i1)for(var i=1;i2&&void 0!==arguments[2]?arguments[2]:"undefined";n(this,e),this.action=t,this.args=i,this.name=s}return s(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),o=function(){function e(t){n(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return s(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(i)&&(i=[i]),this.time_actions[e]=new r(t,i,n)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t0&&s._listeners.length>this._maxListeners&&(s._listeners.warned=!0,c.call(this,s._listeners.length,r))):s._listeners=t,!0;r=e.shift()}return!0}var y=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},p=10;h.EventEmitter2=h,h.prototype.delimiter=".",h.prototype.setMaxListeners=function(e){e!==o&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},h.prototype.event="",h.prototype.once=function(e,t){return this._once(e,t,!1)},h.prototype.prependOnceListener=function(e,t){return this._once(e,t,!0)},h.prototype._once=function(e,t,i){return this._many(e,1,t,i),this},h.prototype.many=function(e,t,i){return this._many(e,t,i,!1)},h.prototype.prependMany=function(e,t,i){return this._many(e,t,i,!0)},h.prototype._many=function(e,t,i,n){function s(){return 0==--t&&r.off(e,s),i.apply(this,arguments)}var r=this;if("function"!=typeof i)throw new Error("many only accepts instances of Function");return s._origin=i,this._on(e,s,n),r},h.prototype.emit=function(){this._events||a.call(this);var e=arguments[0];if("newListener"===e&&!this.newListener&&!this._events.newListener)return!1;var t,i,n,s,r,o=arguments.length;if(this._all&&this._all.length){if(r=this._all.slice(),o>3)for(t=new Array(o),s=0;s3)for(t=new Array(o-1),s=1;s3)for(t=new Array(l),s=1;s3)for(t=new Array(l-1),s=1;s0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,c.call(this,this._events[e].length,e))):this._events[e]=t,this)},h.prototype.off=function(e,t){function i(e){if(e!==o){var t=Object.keys(e);for(var n in t){var s=t[n],a=e[s];a instanceof Function||"object"!==(void 0===a?"undefined":r(a))||null===a||(Object.keys(a).length>0&&i(e[s]),0===Object.keys(a).length&&delete e[s])}}}if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var n,s=[];if(this.wildcard){var a="string"==typeof e?e.split(this.delimiter):e.slice();s=u.call(this,null,a,this.listenerTree,0)}else{if(!this._events[e])return this;n=this._events[e],s.push({_listeners:n})}for(var l=0;l0){for(t=this._all,i=0,n=t.length;i1)for(var i=1;i2&&void 0!==arguments[2]?arguments[2]:"undefined";n(this,e),this.action=t,this.args=i,this.name=r}return r(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),o=function(){function e(t){n(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return r(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(i)&&(i=[i]),this.time_actions[e]=new s(t,i,n)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t0&&r._listeners.length>this._maxListeners&&(r._listeners.warned=!0,c.call(this,r._listeners.length,s))):r._listeners=t,!0;s=e.shift()}return!0}var y=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},p=10;h.EventEmitter2=h,h.prototype.delimiter=".",h.prototype.setMaxListeners=function(e){e!==o&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},h.prototype.event="",h.prototype.once=function(e,t){return this._once(e,t,!1)},h.prototype.prependOnceListener=function(e,t){return this._once(e,t,!0)},h.prototype._once=function(e,t,i){return this._many(e,1,t,i),this},h.prototype.many=function(e,t,i){return this._many(e,t,i,!1)},h.prototype.prependMany=function(e,t,i){return this._many(e,t,i,!0)},h.prototype._many=function(e,t,i,n){function r(){return 0==--t&&s.off(e,r),i.apply(this,arguments)}var s=this;if("function"!=typeof i)throw new Error("many only accepts instances of Function");return r._origin=i,this._on(e,r,n),s},h.prototype.emit=function(){this._events||a.call(this);var e=arguments[0];if("newListener"===e&&!this.newListener&&!this._events.newListener)return!1;var t,i,n,r,s,o=arguments.length;if(this._all&&this._all.length){if(s=this._all.slice(),o>3)for(t=new Array(o),r=0;r3)for(t=new Array(o-1),r=1;r3)for(t=new Array(l),r=1;r3)for(t=new Array(l-1),r=1;r0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,c.call(this,this._events[e].length,e))):this._events[e]=t,this)},h.prototype.off=function(e,t){function i(e){if(e!==o){var t=Object.keys(e);for(var n in t){var r=t[n],a=e[r];a instanceof Function||"object"!==(void 0===a?"undefined":s(a))||null===a||(Object.keys(a).length>0&&i(e[r]),0===Object.keys(a).length&&delete e[r])}}}if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var n,r=[];if(this.wildcard){var a="string"==typeof e?e.split(this.delimiter):e.slice();r=u.call(this,null,a,this.listenerTree,0)}else{if(!this._events[e])return this;n=this._events[e],r.push({_listeners:n})}for(var l=0;l0){for(t=this._all,i=0,n=t.length;i1)for(var i=1;i2&&void 0!==arguments[2]?arguments[2]:"undefined";n(this,e),this.action=t,this.args=i,this.name=s}return s(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),o=function(){function e(t){n(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return s(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(i)&&(i=[i]),this.time_actions[e]=new r(t,i,n)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t0&&s._listeners.length>this._maxListeners&&(s._listeners.warned=!0,c.call(this,s._listeners.length,r))):s._listeners=t,!0;r=e.shift()}return!0}var y=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},p=10;h.EventEmitter2=h,h.prototype.delimiter=".",h.prototype.setMaxListeners=function(e){e!==o&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},h.prototype.event="",h.prototype.once=function(e,t){return this._once(e,t,!1)},h.prototype.prependOnceListener=function(e,t){return this._once(e,t,!0)},h.prototype._once=function(e,t,i){return this._many(e,1,t,i),this},h.prototype.many=function(e,t,i){return this._many(e,t,i,!1)},h.prototype.prependMany=function(e,t,i){return this._many(e,t,i,!0)},h.prototype._many=function(e,t,i,n){function s(){return 0==--t&&r.off(e,s),i.apply(this,arguments)}var r=this;if("function"!=typeof i)throw new Error("many only accepts instances of Function");return s._origin=i,this._on(e,s,n),r},h.prototype.emit=function(){this._events||a.call(this);var e=arguments[0];if("newListener"===e&&!this.newListener&&!this._events.newListener)return!1;var t,i,n,s,r,o=arguments.length;if(this._all&&this._all.length){if(r=this._all.slice(),o>3)for(t=new Array(o),s=0;s3)for(t=new Array(o-1),s=1;s3)for(t=new Array(l),s=1;s3)for(t=new Array(l-1),s=1;s0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,c.call(this,this._events[e].length,e))):this._events[e]=t,this)},h.prototype.off=function(e,t){function i(e){if(e!==o){var t=Object.keys(e);for(var n in t){var s=t[n],a=e[s];a instanceof Function||"object"!==(void 0===a?"undefined":r(a))||null===a||(Object.keys(a).length>0&&i(e[s]),0===Object.keys(a).length&&delete e[s])}}}if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var n,s=[];if(this.wildcard){var a="string"==typeof e?e.split(this.delimiter):e.slice();s=u.call(this,null,a,this.listenerTree,0)}else{if(!this._events[e])return this;n=this._events[e],s.push({_listeners:n})}for(var l=0;l0){for(t=this._all,i=0,n=t.length;i1)for(var i=1;i2&&void 0!==arguments[2]?arguments[2]:"undefined";i(this,e),this.action=t,this.args=n,this.name=r}return r(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),a=function(){function e(t){i(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return r(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(n)&&(n=[n]),this.time_actions[e]=new o(t,n,i)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:"undefined";i(this,e),this.action=t,this.args=n,this.name=o}return o(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),a=function(){function e(t){i(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return o(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(n)&&(n=[n]),this.time_actions[e]=new r(t,n,i)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:"undefined";i(this,e),this.action=t,this.args=n,this.name=r}return r(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),a=function(){function e(t){i(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return r(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(n)&&(n=[n]),this.time_actions[e]=new o(t,n,i)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:"undefined";i(this,e),this.action=t,this.args=n,this.name=o}return o(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),a=function(){function e(t){i(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return o(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(n)&&(n=[n]),this.time_actions[e]=new r(t,n,i)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:"undefined";n(this,e),this.action=t,this.args=i,this.name=s}return s(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),o=function(){function e(t){n(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return s(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(i)&&(i=[i]),this.time_actions[e]=new r(t,i,n)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t0&&s._listeners.length>this._maxListeners&&(s._listeners.warned=!0,c.call(this,s._listeners.length,r))):s._listeners=t,!0;r=e.shift()}return!0}var p=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},y=10;h.EventEmitter2=h,h.prototype.delimiter=".",h.prototype.setMaxListeners=function(e){e!==o&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},h.prototype.event="",h.prototype.once=function(e,t){return this._once(e,t,!1)},h.prototype.prependOnceListener=function(e,t){return this._once(e,t,!0)},h.prototype._once=function(e,t,i){return this._many(e,1,t,i),this},h.prototype.many=function(e,t,i){return this._many(e,t,i,!1)},h.prototype.prependMany=function(e,t,i){return this._many(e,t,i,!0)},h.prototype._many=function(e,t,i,n){function s(){return 0==--t&&r.off(e,s),i.apply(this,arguments)}var r=this;if("function"!=typeof i)throw new Error("many only accepts instances of Function");return s._origin=i,this._on(e,s,n),r},h.prototype.emit=function(){this._events||a.call(this);var e=arguments[0];if("newListener"===e&&!this.newListener&&!this._events.newListener)return!1;var t,i,n,s,r,o=arguments.length;if(this._all&&this._all.length){if(r=this._all.slice(),o>3)for(t=new Array(o),s=0;s3)for(t=new Array(o-1),s=1;s3)for(t=new Array(l),s=1;s3)for(t=new Array(l-1),s=1;s0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,c.call(this,this._events[e].length,e))):this._events[e]=t,this)},h.prototype.off=function(e,t){function i(e){if(e!==o){var t=Object.keys(e);for(var n in t){var s=t[n],a=e[s];a instanceof Function||"object"!==(void 0===a?"undefined":r(a))||null===a||(Object.keys(a).length>0&&i(e[s]),0===Object.keys(a).length&&delete e[s])}}}if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var n,s=[];if(this.wildcard){var a="string"==typeof e?e.split(this.delimiter):e.slice();s=u.call(this,null,a,this.listenerTree,0)}else{if(!this._events[e])return this;n=this._events[e],s.push({_listeners:n})}for(var l=0;l0){for(t=this._all,i=0,n=t.length;i1)for(var i=1;i2&&void 0!==arguments[2]?arguments[2]:"undefined";n(this,e),this.action=t,this.args=i,this.name=s}return s(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),o=function(){function e(t){n(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return s(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(i)&&(i=[i]),this.time_actions[e]=new r(t,i,n)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t0&&s._listeners.length>this._maxListeners&&(s._listeners.warned=!0,c.call(this,s._listeners.length,r))):s._listeners=t,!0;r=e.shift()}return!0}var p=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},y=10;h.EventEmitter2=h,h.prototype.delimiter=".",h.prototype.setMaxListeners=function(e){e!==o&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},h.prototype.event="",h.prototype.once=function(e,t){return this._once(e,t,!1)},h.prototype.prependOnceListener=function(e,t){return this._once(e,t,!0)},h.prototype._once=function(e,t,i){return this._many(e,1,t,i),this},h.prototype.many=function(e,t,i){return this._many(e,t,i,!1)},h.prototype.prependMany=function(e,t,i){return this._many(e,t,i,!0)},h.prototype._many=function(e,t,i,n){function s(){return 0==--t&&r.off(e,s),i.apply(this,arguments)}var r=this;if("function"!=typeof i)throw new Error("many only accepts instances of Function");return s._origin=i,this._on(e,s,n),r},h.prototype.emit=function(){this._events||a.call(this);var e=arguments[0];if("newListener"===e&&!this.newListener&&!this._events.newListener)return!1;var t,i,n,s,r,o=arguments.length;if(this._all&&this._all.length){if(r=this._all.slice(),o>3)for(t=new Array(o),s=0;s3)for(t=new Array(o-1),s=1;s3)for(t=new Array(l),s=1;s3)for(t=new Array(l-1),s=1;s0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,c.call(this,this._events[e].length,e))):this._events[e]=t,this)},h.prototype.off=function(e,t){function i(e){if(e!==o){var t=Object.keys(e);for(var n in t){var s=t[n],a=e[s];a instanceof Function||"object"!==(void 0===a?"undefined":r(a))||null===a||(Object.keys(a).length>0&&i(e[s]),0===Object.keys(a).length&&delete e[s])}}}if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var n,s=[];if(this.wildcard){var a="string"==typeof e?e.split(this.delimiter):e.slice();s=u.call(this,null,a,this.listenerTree,0)}else{if(!this._events[e])return this;n=this._events[e],s.push({_listeners:n})}for(var l=0;l0){for(t=this._all,i=0,n=t.length;i1)for(var i=1;i2&&void 0!==arguments[2]?arguments[2]:"undefined";n(this,e),this.action=t,this.args=i,this.name=s}return s(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),o=function(){function e(t){n(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return s(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(i)&&(i=[i]),this.time_actions[e]=new r(t,i,n)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t0&&s._listeners.length>this._maxListeners&&(s._listeners.warned=!0,c.call(this,s._listeners.length,r))):s._listeners=t,!0;r=e.shift()}return!0}var p=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},y=10;h.EventEmitter2=h,h.prototype.delimiter=".",h.prototype.setMaxListeners=function(e){e!==o&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},h.prototype.event="",h.prototype.once=function(e,t){return this._once(e,t,!1)},h.prototype.prependOnceListener=function(e,t){return this._once(e,t,!0)},h.prototype._once=function(e,t,i){return this._many(e,1,t,i),this},h.prototype.many=function(e,t,i){return this._many(e,t,i,!1)},h.prototype.prependMany=function(e,t,i){return this._many(e,t,i,!0)},h.prototype._many=function(e,t,i,n){function s(){return 0==--t&&r.off(e,s),i.apply(this,arguments)}var r=this;if("function"!=typeof i)throw new Error("many only accepts instances of Function");return s._origin=i,this._on(e,s,n),r},h.prototype.emit=function(){this._events||a.call(this);var e=arguments[0];if("newListener"===e&&!this.newListener&&!this._events.newListener)return!1;var t,i,n,s,r,o=arguments.length;if(this._all&&this._all.length){if(r=this._all.slice(),o>3)for(t=new Array(o),s=0;s3)for(t=new Array(o-1),s=1;s3)for(t=new Array(l),s=1;s3)for(t=new Array(l-1),s=1;s0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,c.call(this,this._events[e].length,e))):this._events[e]=t,this)},h.prototype.off=function(e,t){function i(e){if(e!==o){var t=Object.keys(e);for(var n in t){var s=t[n],a=e[s];a instanceof Function||"object"!==(void 0===a?"undefined":r(a))||null===a||(Object.keys(a).length>0&&i(e[s]),0===Object.keys(a).length&&delete e[s])}}}if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var n,s=[];if(this.wildcard){var a="string"==typeof e?e.split(this.delimiter):e.slice();s=u.call(this,null,a,this.listenerTree,0)}else{if(!this._events[e])return this;n=this._events[e],s.push({_listeners:n})}for(var l=0;l0){for(t=this._all,i=0,n=t.length;i1)for(var i=1;i2&&void 0!==arguments[2]?arguments[2]:"undefined";n(this,e),this.action=t,this.args=i,this.name=s}return s(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),o=function(){function e(t){n(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return s(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(i)&&(i=[i]),this.time_actions[e]=new r(t,i,n)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t0&&s._listeners.length>this._maxListeners&&(s._listeners.warned=!0,c.call(this,s._listeners.length,r))):s._listeners=t,!0;r=e.shift()}return!0}var p=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},y=10;h.EventEmitter2=h,h.prototype.delimiter=".",h.prototype.setMaxListeners=function(e){e!==o&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},h.prototype.event="",h.prototype.once=function(e,t){return this._once(e,t,!1)},h.prototype.prependOnceListener=function(e,t){return this._once(e,t,!0)},h.prototype._once=function(e,t,i){return this._many(e,1,t,i),this},h.prototype.many=function(e,t,i){return this._many(e,t,i,!1)},h.prototype.prependMany=function(e,t,i){return this._many(e,t,i,!0)},h.prototype._many=function(e,t,i,n){function s(){return 0==--t&&r.off(e,s),i.apply(this,arguments)}var r=this;if("function"!=typeof i)throw new Error("many only accepts instances of Function");return s._origin=i,this._on(e,s,n),r},h.prototype.emit=function(){this._events||a.call(this);var e=arguments[0];if("newListener"===e&&!this.newListener&&!this._events.newListener)return!1;var t,i,n,s,r,o=arguments.length;if(this._all&&this._all.length){if(r=this._all.slice(),o>3)for(t=new Array(o),s=0;s3)for(t=new Array(o-1),s=1;s3)for(t=new Array(l),s=1;s3)for(t=new Array(l-1),s=1;s0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,c.call(this,this._events[e].length,e))):this._events[e]=t,this)},h.prototype.off=function(e,t){function i(e){if(e!==o){var t=Object.keys(e);for(var n in t){var s=t[n],a=e[s];a instanceof Function||"object"!==(void 0===a?"undefined":r(a))||null===a||(Object.keys(a).length>0&&i(e[s]),0===Object.keys(a).length&&delete e[s])}}}if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var n,s=[];if(this.wildcard){var a="string"==typeof e?e.split(this.delimiter):e.slice();s=u.call(this,null,a,this.listenerTree,0)}else{if(!this._events[e])return this;n=this._events[e],s.push({_listeners:n})}for(var l=0;l0){for(t=this._all,i=0,n=t.length;i1)for(var i=1;i2&&void 0!==arguments[2]?arguments[2]:"undefined";i(this,e),this.action=t,this.args=n,this.name=r}return r(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),a=function(){function e(t){i(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return r(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(n)&&(n=[n]),this.time_actions[e]=new o(t,n,i)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:"undefined";i(this,e),this.action=t,this.args=n,this.name=r}return r(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),a=function(){function e(t){i(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return r(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(n)&&(n=[n]),this.time_actions[e]=new o(t,n,i)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:"undefined";i(this,e),this.action=t,this.args=n,this.name=r}return r(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),a=function(){function e(t){i(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return r(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(n)&&(n=[n]),this.time_actions[e]=new o(t,n,i)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:"undefined";i(this,e),this.action=t,this.args=n,this.name=r}return r(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),a=function(){function e(t){i(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return r(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(n)&&(n=[n]),this.time_actions[e]=new o(t,n,i)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:"undefined";n(this,e),this.action=t,this.args=i,this.name=r}return r(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),o=function(){function e(t){n(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return r(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(i)&&(i=[i]),this.time_actions[e]=new s(t,i,n)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t0&&r._listeners.length>this._maxListeners&&(r._listeners.warned=!0,c.call(this,r._listeners.length,s))):r._listeners=t,!0;s=e.shift()}return!0}var y=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},p=10;h.EventEmitter2=h,h.prototype.delimiter=".",h.prototype.setMaxListeners=function(e){e!==o&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},h.prototype.event="",h.prototype.once=function(e,t){return this._once(e,t,!1)},h.prototype.prependOnceListener=function(e,t){return this._once(e,t,!0)},h.prototype._once=function(e,t,i){return this._many(e,1,t,i),this},h.prototype.many=function(e,t,i){return this._many(e,t,i,!1)},h.prototype.prependMany=function(e,t,i){return this._many(e,t,i,!0)},h.prototype._many=function(e,t,i,n){function r(){return 0==--t&&s.off(e,r),i.apply(this,arguments)}var s=this;if("function"!=typeof i)throw new Error("many only accepts instances of Function");return r._origin=i,this._on(e,r,n),s},h.prototype.emit=function(){this._events||a.call(this);var e=arguments[0];if("newListener"===e&&!this.newListener&&!this._events.newListener)return!1;var t,i,n,r,s,o=arguments.length;if(this._all&&this._all.length){if(s=this._all.slice(),o>3)for(t=new Array(o),r=0;r3)for(t=new Array(o-1),r=1;r3)for(t=new Array(l),r=1;r3)for(t=new Array(l-1),r=1;r0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,c.call(this,this._events[e].length,e))):this._events[e]=t,this)},h.prototype.off=function(e,t){function i(e){if(e!==o){var t=Object.keys(e);for(var n in t){var r=t[n],a=e[r];a instanceof Function||"object"!==(void 0===a?"undefined":s(a))||null===a||(Object.keys(a).length>0&&i(e[r]),0===Object.keys(a).length&&delete e[r])}}}if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var n,r=[];if(this.wildcard){var a="string"==typeof e?e.split(this.delimiter):e.slice();r=u.call(this,null,a,this.listenerTree,0)}else{if(!this._events[e])return this;n=this._events[e],r.push({_listeners:n})}for(var l=0;l0){for(t=this._all,i=0,n=t.length;i1)for(var i=1;i2&&void 0!==arguments[2]?arguments[2]:"undefined";n(this,e),this.action=t,this.args=i,this.name=s}return s(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),o=function(){function e(t){n(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return s(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(i)&&(i=[i]),this.time_actions[e]=new r(t,i,n)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t0&&s._listeners.length>this._maxListeners&&(s._listeners.warned=!0,c.call(this,s._listeners.length,r))):s._listeners=t,!0;r=e.shift()}return!0}var y=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},p=10;h.EventEmitter2=h,h.prototype.delimiter=".",h.prototype.setMaxListeners=function(e){e!==o&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},h.prototype.event="",h.prototype.once=function(e,t){return this._once(e,t,!1)},h.prototype.prependOnceListener=function(e,t){return this._once(e,t,!0)},h.prototype._once=function(e,t,i){return this._many(e,1,t,i),this},h.prototype.many=function(e,t,i){return this._many(e,t,i,!1)},h.prototype.prependMany=function(e,t,i){return this._many(e,t,i,!0)},h.prototype._many=function(e,t,i,n){function s(){return 0==--t&&r.off(e,s),i.apply(this,arguments)}var r=this;if("function"!=typeof i)throw new Error("many only accepts instances of Function");return s._origin=i,this._on(e,s,n),r},h.prototype.emit=function(){this._events||a.call(this);var e=arguments[0];if("newListener"===e&&!this.newListener&&!this._events.newListener)return!1;var t,i,n,s,r,o=arguments.length;if(this._all&&this._all.length){if(r=this._all.slice(),o>3)for(t=new Array(o),s=0;s3)for(t=new Array(o-1),s=1;s3)for(t=new Array(l),s=1;s3)for(t=new Array(l-1),s=1;s0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,c.call(this,this._events[e].length,e))):this._events[e]=t,this)},h.prototype.off=function(e,t){function i(e){if(e!==o){var t=Object.keys(e);for(var n in t){var s=t[n],a=e[s];a instanceof Function||"object"!==(void 0===a?"undefined":r(a))||null===a||(Object.keys(a).length>0&&i(e[s]),0===Object.keys(a).length&&delete e[s])}}}if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var n,s=[];if(this.wildcard){var a="string"==typeof e?e.split(this.delimiter):e.slice();s=u.call(this,null,a,this.listenerTree,0)}else{if(!this._events[e])return this;n=this._events[e],s.push({_listeners:n})}for(var l=0;l0){for(t=this._all,i=0,n=t.length;i1)for(var i=1;i2&&void 0!==arguments[2]?arguments[2]:"undefined";n(this,e),this.action=t,this.args=i,this.name=r}return r(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),o=function(){function e(t){n(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return r(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(i)&&(i=[i]),this.time_actions[e]=new s(t,i,n)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t0&&r._listeners.length>this._maxListeners&&(r._listeners.warned=!0,c.call(this,r._listeners.length,s))):r._listeners=t,!0;s=e.shift()}return!0}var y=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},p=10;h.EventEmitter2=h,h.prototype.delimiter=".",h.prototype.setMaxListeners=function(e){e!==o&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},h.prototype.event="",h.prototype.once=function(e,t){return this._once(e,t,!1)},h.prototype.prependOnceListener=function(e,t){return this._once(e,t,!0)},h.prototype._once=function(e,t,i){return this._many(e,1,t,i),this},h.prototype.many=function(e,t,i){return this._many(e,t,i,!1)},h.prototype.prependMany=function(e,t,i){return this._many(e,t,i,!0)},h.prototype._many=function(e,t,i,n){function r(){return 0==--t&&s.off(e,r),i.apply(this,arguments)}var s=this;if("function"!=typeof i)throw new Error("many only accepts instances of Function");return r._origin=i,this._on(e,r,n),s},h.prototype.emit=function(){this._events||a.call(this);var e=arguments[0];if("newListener"===e&&!this.newListener&&!this._events.newListener)return!1;var t,i,n,r,s,o=arguments.length;if(this._all&&this._all.length){if(s=this._all.slice(),o>3)for(t=new Array(o),r=0;r3)for(t=new Array(o-1),r=1;r3)for(t=new Array(l),r=1;r3)for(t=new Array(l-1),r=1;r0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,c.call(this,this._events[e].length,e))):this._events[e]=t,this)},h.prototype.off=function(e,t){function i(e){if(e!==o){var t=Object.keys(e);for(var n in t){var r=t[n],a=e[r];a instanceof Function||"object"!==(void 0===a?"undefined":s(a))||null===a||(Object.keys(a).length>0&&i(e[r]),0===Object.keys(a).length&&delete e[r])}}}if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var n,r=[];if(this.wildcard){var a="string"==typeof e?e.split(this.delimiter):e.slice();r=u.call(this,null,a,this.listenerTree,0)}else{if(!this._events[e])return this;n=this._events[e],r.push({_listeners:n})}for(var l=0;l0){for(t=this._all,i=0,n=t.length;i1)for(var i=1;i2&&void 0!==arguments[2]?arguments[2]:"undefined";n(this,e),this.action=t,this.args=i,this.name=s}return s(e,[{key:"toString",value:function(){return"TimeAction:("+this.name+")"}},{key:"trigger",value:function(){console.log(this,this.args),this.action.apply(this,this.args)}}]),e}(),o=function(){function e(t){n(this,e),this.time_actions={},this.name=t.name||"undefined",this.treshold=t.treshold||5}return s(e,[{key:"toString",value:function(){return"("+this.name+")"}},{key:"addTimeAction",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"undefined";"[object Array]"!==Object.prototype.toString.call(i)&&(i=[i]),this.time_actions[e]=new r(t,i,n)}},{key:"callTimeAction",value:function(e){this.time_actions.hasOwnProperty(e)&&this.time_actions[e].trigger()}},{key:"callNearestTimeAction",value:function(e){var t;"NOTFOUND"!=(t=this.time_actions.hasOwnProperty(e)?e:this.getNearestTime(e))&&this.time_actions.hasOwnProperty(t)&&this.time_actions[t].trigger()}},{key:"getNearestTime",value:function(e){for(var t=1;t0&&s._listeners.length>this._maxListeners&&(s._listeners.warned=!0,c.call(this,s._listeners.length,r))):s._listeners=t,!0;r=e.shift()}return!0}var y=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},p=10;h.EventEmitter2=h,h.prototype.delimiter=".",h.prototype.setMaxListeners=function(e){e!==o&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},h.prototype.event="",h.prototype.once=function(e,t){return this._once(e,t,!1)},h.prototype.prependOnceListener=function(e,t){return this._once(e,t,!0)},h.prototype._once=function(e,t,i){return this._many(e,1,t,i),this},h.prototype.many=function(e,t,i){return this._many(e,t,i,!1)},h.prototype.prependMany=function(e,t,i){return this._many(e,t,i,!0)},h.prototype._many=function(e,t,i,n){function s(){return 0==--t&&r.off(e,s),i.apply(this,arguments)}var r=this;if("function"!=typeof i)throw new Error("many only accepts instances of Function");return s._origin=i,this._on(e,s,n),r},h.prototype.emit=function(){this._events||a.call(this);var e=arguments[0];if("newListener"===e&&!this.newListener&&!this._events.newListener)return!1;var t,i,n,s,r,o=arguments.length;if(this._all&&this._all.length){if(r=this._all.slice(),o>3)for(t=new Array(o),s=0;s3)for(t=new Array(o-1),s=1;s3)for(t=new Array(l),s=1;s3)for(t=new Array(l-1),s=1;s0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,c.call(this,this._events[e].length,e))):this._events[e]=t,this)},h.prototype.off=function(e,t){function i(e){if(e!==o){var t=Object.keys(e);for(var n in t){var s=t[n],a=e[s];a instanceof Function||"object"!==(void 0===a?"undefined":r(a))||null===a||(Object.keys(a).length>0&&i(e[s]),0===Object.keys(a).length&&delete e[s])}}}if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var n,s=[];if(this.wildcard){var a="string"==typeof e?e.split(this.delimiter):e.slice();s=u.call(this,null,a,this.listenerTree,0)}else{if(!this._events[e])return this;n=this._events[e],s.push({_listeners:n})}for(var l=0;l0){for(t=this._all,i=0,n=t.length;i1)for(var i=1;idisplaysJS
  • - on - + href='#display' + class=" toggle-sibling"> + Display + -
  • - - -
  • - MODES +
  • - - -
  • - setAsReady - - -
  • - - -
  • - ready + - - -
  • - - -
  • - setAsPrimaryDisplay - - -
  • - - -
  • - isPrimaryDisplay - +
  • - tick - + href='#timeaction' + class=" toggle-sibling"> + TimeAction + -
  • - - -
  • - seek +
  • - - -
  • - enableUserMode - - -
  • - - -
  • - releaseUserMode + - - -
  • - - -
  • - isInUserMode - - -
  • - - -
  • - handleTick - +
  • - handlePause - + href='#timeline' + class=" toggle-sibling"> + Timeline + -
  • - - -
  • - TimeAction +
  • @@ -178,19 +242,18 @@

    displaysJS

    -

    - on +

    + Display

    -

    Handle case where a display is not in sync or -needs all other displays to pause.*

    +

    The Base class for all Displays.

    -
    on
    +
    new Display(args: Object)
    @@ -202,11 +265,64 @@

    +
    Parameters
    +
    + +
    +
    + args (Object) + An object with arguments to initialize the display. - +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + +
    NameDescription
    args.name String + Name of Display Instance +
    args.timeline_treshold Number + A treshold of error for picking a time action for the display +
    args.context Object + ( + optional +) Reference to DisplayCoordinator's context +
    + +
    + +
    @@ -216,31 +332,29 @@

    - - - - -
    + -
    - -

    - MODES -

    - - -
    +
    Instance Members
    +
    + +
    +
    +
    + + setContext(context) +
    +
    + +
    -
    - -

    - setAsReady -

    - - -
    +
    +
    +
    + + setAsReady() +
    +
    + +
    + +
    +
    +
    + + ready() +
    +
    + +
    + +
    +
    +
    + + setAsPrimaryDisplay() +
    +
    + +
    + +
    +
    +
    + + isPrimaryDisplay() +
    +
    + +
    + +
    +
    +
    + + tick() +
    +
    + +
    + +
    +
    +
    + + enableUserMode() +
    +
    + +
    + +
    +
    +
    + + releaseUserMode() +
    +
    + +
    + +
    +
    +
    + + isInUserMode() +
    +
    + +
    + +
    +
    +
    + + handleTick() +
    +
    + +
    + +
    +
    +
    + + handlePause() +
    +
    + +
    + +
    +
    +
    + + handleContinue() +
    +
    + +
    + +
    +
    +
    + + setup() +
    +
    + +
    + +
    +
    +
    + + render() +
    +
    + +
    + +
    +
    +
    + + pause() +
    +
    + +
    + +
    +
    +
    + + play() +
    +
    + +
    + +
    +
    +
    + + seek(t) +
    +
    + +
    -
    - -

    - tick -

    - - -
    +
    +
    +
    + + reset() +
    +
    + +
    + +
    @@ -514,18 +1275,18 @@

    -

    - seek +

    + TimeAction

    -

    Seek skips to a given time.

    +

    TimeAction is the class representing a time Action that can occur in a Timeline.

    -
    seek(t: any)
    +
    new TimeAction(func: function, args: Object, name: String)
    @@ -542,8 +1303,30 @@

    - t (any) - + func (function) + Reference to a function to call on trigger + +
    + +
    + +
    +
    + args (Object) + A list of arguments to pass to the func on trigger. + +
    + +
    + +
    +
    + name (String + = "undefined") + ( + optional +) A name for the TimeAction +
    @@ -562,33 +1345,25 @@

    - +
    Instance Members
    +
    -

    - - - - -
    +
    +
    +
    + + trigger() +
    +
    + +
    + + @@ -624,21 +1409,18 @@

    -

    - releaseUserMode +

    + Timeline

    -
      -
    • Helper to disable user mode -Only use this if UserMode is used
    • -
    +

    Timeline with many actions

    -
    releaseUserMode()
    +
    new Timeline(args: Object)
    @@ -650,11 +1432,57 @@

    +
    Parameters
    +
    + +
    +
    + args (Object) + Object containing Timeline args. +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameDescription
    args.name String + (default "undefined") + The name of the Timeline. +
    args.treshold Number + (default 5) + The treshold for calling TimeActions +
    + +
    + +
    @@ -664,28 +1492,29 @@

    -

    - - - -
    + -
    - -

    - isInUserMode -

    - - -
    +
    Instance Members
    +
    + +
    +
    +
    + + addTimeAction(time, action, args, name) +
    +
    + +
    -
    - -

    - handleTick -

    - - -
    +
    +
    +
    + + callTimeAction(time) +
    +
    + +
    -
    - -

    - handlePause -

    - - -
    +
    +
    +
    + + callNearestTimeAction(time) +
    +
    + +
    -
    - -

    - TimeAction -

    - - -
    +
    +
    +
    + + getNearestTime(time) +
    +
    + +
    +
    diff --git a/src/timeline.js b/src/timeline.js index aa19016..39765b0 100644 --- a/src/timeline.js +++ b/src/timeline.js @@ -1,8 +1,13 @@ "use strict"; + const NOT_FOUND = "NOTFOUND"; /** - * Class representing a time action. + * TimeAction is the class representing a time Action that can occur in a Timeline. + * + * @param {function} func Reference to a function to call on trigger + * @param {Object} args A list of arguments to pass to the func on trigger. + * @param {String} name (** optional **) A name for the TimeAction */ class TimeAction { constructor(func, args, name="undefined") { @@ -13,12 +18,23 @@ class TimeAction { toString() { return 'TimeAction:(' + this.name + ')'; } + + /** + * Trigger an action by calling *func* and passing it *args* passed from initialization. + */ trigger(){ console.log(this, this.args); this.action.apply(this, this.args); } }; +/** + * Timeline with many actions + * + * @param {Object} args Object containing Timeline args. + * @param {String} [args.name="undefined"] The name of the Timeline. + * @param {Number} [args.treshold=5] The treshold for calling TimeActions + */ class Timeline { constructor(args) { this.time_actions = {}; @@ -28,17 +44,36 @@ class Timeline { toString() { return '(' + this.name + ')'; } + + /** + * Add a time action to the timeline. + * @param {Number} time The time value at which to perform the action + * @param {function} action The function to call when trigger + * @param {Array} [args=[]] The args to pass to function on trigger + * @param {String} [name="undefined"] The name of the TimeAction + */ addTimeAction(time, action, args=[], name="undefined"){ if( !(Object.prototype.toString.call( args ) === '[object Array]') ) { args = [args]; } this.time_actions[time] = new TimeAction(action, args, name); } + + /** + * This function triggers the TimeAction on the Timeline at the given time if there is one. + * @param {Number} time The time value at which the action is at. + */ callTimeAction(time){ if (this.time_actions.hasOwnProperty(time)) { this.time_actions[time].trigger() } } + + /** + * This function triggers the nearest TimeAction on the Timeline within the treshold + * of the Timeline. + * @param {Number} time The time value to call action within treshold for. + */ callNearestTimeAction(time){ var t; if (this.time_actions.hasOwnProperty(time)) { @@ -51,6 +86,12 @@ class Timeline { this.time_actions[t].trigger() } } + + /** + * This function is a helper to get the nearest time value within the Timeline's treshold + * @param {Number} time The time to look within Timeline treshold + * @return {Number} The value within treshold. "NOT_FOUND" if no value within treshold. + */ getNearestTime(time){ for (var i = 1; i < this.treshold; i++) { if (this.time_actions.hasOwnProperty(time+i)) {