Skip to content

Commit

Permalink
Refactoring For loop
Browse files Browse the repository at this point in the history
A refactoring in order to remove a for loop and possibly optimize this a bit.
  • Loading branch information
Miguel Solano authored Dec 27, 2017
1 parent d98bf3c commit 981e35b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ var commands = module.exports.commands = [
]

module.exports.isCommand = function(command) {
command = command.toLowerCase()
for (var i=0, len=commands.length; i<len; i++) {
if (commands[i].toLowerCase() === command) {
return true
}
}
command = command.toLowerCase();
var lowerCaseCommands = commands.map(function (item) {
return item.toLowerCase();
});
return lowerCaseCommands.indexOf(command) !== -1 ? true : false;
}

0 comments on commit 981e35b

Please sign in to comment.