From b7ebee985b0292eda5234c4555a13ee59914252a Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Sun, 22 Oct 2017 23:51:33 -0400 Subject: [PATCH] refactor indexOfItemById --- lib/browser/api/menu.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/browser/api/menu.js b/lib/browser/api/menu.js index 174acd7d91..bacebc702c 100644 --- a/lib/browser/api/menu.js +++ b/lib/browser/api/menu.js @@ -10,7 +10,7 @@ var nextGroupId = 0 // Search between separators to find a radio menu item and return its group id, // otherwise generate a group id. -var generateGroupId = function (items, pos) { +function generateGroupId (items, pos) { var i, item, j, k, ref1, ref2, ref3 if (pos > 0) { for (i = j = ref1 = pos - 1; ref1 <= 0 ? j <= 0 : j >= 0; i = ref1 <= 0 ? ++j : --j) { @@ -37,19 +37,16 @@ var generateGroupId = function (items, pos) { } // Returns the index of item according to |id|. -var indexOfItemById = function (items, id) { - var i, item, j, len - for (i = j = 0, len = items.length; j < len; i = ++j) { - item = items[i] - if (item.id === id) { - return i - } +function indexOfItemById (items, id) { + for (let idx = 0; idx < items.length; idx += 1) { + const item = items[idx] + if (item.id === id) return idx } return -1 } // Returns the index of where to insert the item according to |position|. -var indexToInsertByPosition = function (items, position) { +function indexToInsertByPosition (items, position) { var insertIndex if (!position) { return items.length