if(MIDAS == undefined) { var MIDAS = {}; } MIDAS.InputParser = function() { var self = this; this.parse = function(string, commands) { var words = string.split(" "); var command = words[0]; if (!isValidCommand(command, commands)) { return {"error": true, "errorMessage":string}; } var data = words.splice(1); var result = { "command":command ,"data":data }; return result; }; function isValidCommand(command, commands) { for(var i = 0; i < commands.length; i++) { if(command == commands[i]) { return true; } } return false; }; };