Skip to content

Commit

Permalink
chore: change for of and break if the iterator is too large
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpmule committed Oct 26, 2023
1 parent 16558c2 commit fab13f6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/ApiRequestEditorElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ export class ApiRequestEditorElement extends AmfHelperMixin(
let newOperationSelected = null;

// loop throught a list of endpoints and find the operation with the same lexical value
endpoints.forEach((endpoint) => {
for (const endpoint of endpoints) {
const supportedOperation = this._ensureArray(endpoint[opKey]);
// if the operation is not supported by the endpoint, skip it
if (!supportedOperation) {
Expand All @@ -657,7 +657,11 @@ export class ApiRequestEditorElement extends AmfHelperMixin(
return lexicalValue === lexicalValueOld;
});
}
});
// if the operation is found, break the loop
if (newOperationSelected) {
break;
}
};
// if the operation is not found, return the previous selection
if (!newOperationSelected) {
return this.selected;
Expand Down

0 comments on commit fab13f6

Please sign in to comment.