Skip to content

Commit

Permalink
refactor for loops
Browse files Browse the repository at this point in the history
  • Loading branch information
LCluber committed Apr 8, 2021
1 parent 315569b commit 587fccb
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 64 deletions.
34 changes: 13 additions & 21 deletions dist/ctrltab.iife.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,11 @@ var CtrlTab = (function (exports) {
alt: false,
shift: false
};
this.setCtrlKeys(ctrlKeys);

if (ctrlKeys) {
this.setCtrlKeys(ctrlKeys);
}

this.asciiCodes = asciiCodes;
}

Expand All @@ -233,7 +237,7 @@ var CtrlTab = (function (exports) {
_proto.setCtrlKeys = function setCtrlKeys(ctrlKeys) {
for (var property in this.ctrlKeys) {
if (this.ctrlKeys.hasOwnProperty(property)) {
this.ctrlKeys[property] = ctrlKeys && ctrlKeys.hasOwnProperty(property) && ctrlKeys[property] ? true : false;
this.ctrlKeys[property] = ctrlKeys[property] ? true : false;
}
}
};
Expand All @@ -253,7 +257,7 @@ var CtrlTab = (function (exports) {
this.repeat = (options === null || options === void 0 ? void 0 : options.repeat) ? true : false;
this.callback = callback;

if (options && options.hasOwnProperty("scope")) {
if (options === null || options === void 0 ? void 0 : options.scope) {
this.callback = this.callback.bind(options.scope);
}
}
Expand Down Expand Up @@ -401,15 +405,9 @@ var CtrlTab = (function (exports) {
};

_proto.getCmd = function getCmd(name) {
for (var _iterator3 = _createForOfIteratorHelperLoose(this.commands), _step3; !(_step3 = _iterator3()).done;) {
var command = _step3.value;

if (command.name == name) {
return command;
}
}

return null;
return this.commands.find(function (command) {
return command.name == name;
}) || null;
};

Group.sortCmds = function sortCmds(commands) {
Expand Down Expand Up @@ -499,15 +497,9 @@ var CtrlTab = (function (exports) {
};

_proto.getGroup = function getGroup(name) {
for (var _iterator3 = _createForOfIteratorHelperLoose(this.groups), _step3; !(_step3 = _iterator3()).done;) {
var group = _step3.value;

if (group.name === name) {
return group;
}
}

return null;
return this.groups.find(function (group) {
return group.name === name;
}) || null;
};

_proto.getCmd = function getCmd(groupName, commandName) {
Expand Down
2 changes: 1 addition & 1 deletion dist/ctrltab.iife.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 13 additions & 21 deletions dist/ctrltab.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,11 @@ var DefaultInputs = /*#__PURE__*/function () {
alt: false,
shift: false
};
this.setCtrlKeys(ctrlKeys);

if (ctrlKeys) {
this.setCtrlKeys(ctrlKeys);
}

this.asciiCodes = asciiCodes;
}

Expand All @@ -168,7 +172,7 @@ var DefaultInputs = /*#__PURE__*/function () {
_proto.setCtrlKeys = function setCtrlKeys(ctrlKeys) {
for (var property in this.ctrlKeys) {
if (this.ctrlKeys.hasOwnProperty(property)) {
this.ctrlKeys[property] = ctrlKeys && ctrlKeys.hasOwnProperty(property) && ctrlKeys[property] ? true : false;
this.ctrlKeys[property] = ctrlKeys[property] ? true : false;
}
}
};
Expand All @@ -188,7 +192,7 @@ var Command = /*#__PURE__*/function () {
this.repeat = (options === null || options === void 0 ? void 0 : options.repeat) ? true : false;
this.callback = callback;

if (options && options.hasOwnProperty("scope")) {
if (options === null || options === void 0 ? void 0 : options.scope) {
this.callback = this.callback.bind(options.scope);
}
}
Expand Down Expand Up @@ -336,15 +340,9 @@ var Group = /*#__PURE__*/function () {
};

_proto.getCmd = function getCmd(name) {
for (var _iterator3 = _createForOfIteratorHelperLoose(this.commands), _step3; !(_step3 = _iterator3()).done;) {
var command = _step3.value;

if (command.name == name) {
return command;
}
}

return null;
return this.commands.find(function (command) {
return command.name == name;
}) || null;
};

Group.sortCmds = function sortCmds(commands) {
Expand Down Expand Up @@ -434,15 +432,9 @@ var Keyboard = /*#__PURE__*/function () {
};

_proto.getGroup = function getGroup(name) {
for (var _iterator3 = _createForOfIteratorHelperLoose(this.groups), _step3; !(_step3 = _iterator3()).done;) {
var group = _step3.value;

if (group.name === name) {
return group;
}
}

return null;
return this.groups.find(function (group) {
return group.name === name;
}) || null;
};

_proto.getCmd = function getCmd(groupName, commandName) {
Expand Down
Loading

0 comments on commit 587fccb

Please sign in to comment.