Use 'Object.values' and 'Object.keys' instead of '_.each(object)'

This commit is contained in:
Hongarc 2018-12-01 12:33:23 +07:00
parent bd8009386d
commit 96ddb5041a
9 changed files with 52 additions and 33 deletions

View file

@ -406,8 +406,9 @@ var Level = Sandbox.extend({
}
var matched = false;
_.each(Commands.commands.getCommandsThatCount(), function(map) {
_.each(map, function(regex) {
var commandsThatCount = Commands.commands.getCommandsThatCount();
Object.values(commandsThatCount).forEach(function(map) {
Object.values(map).forEach(function(regex) {
matched = matched || regex.test(command.get('rawStr'));
});
});

View file

@ -75,8 +75,10 @@ ParseWaterfall.prototype.expandAllShortcuts = function(commandStr) {
};
ParseWaterfall.prototype.expandShortcut = function(commandStr, shortcutMap) {
_.each(shortcutMap, function(map, vcs) {
_.each(map, function(regex, method) {
Object.keys(shortcutMap).forEach(function(vcs) {
var map = shortcutMap[vcs];
Object.keys(map).forEach(function(method) {
var regex = map[method];
var results = regex.exec(commandStr);
if (results) {
commandStr = vcs + ' ' + method + ' ' + commandStr.slice(results[0].length);