From 45dd92ff814c2798a719cf0209d67dc8e2fda5de Mon Sep 17 00:00:00 2001 From: Benjamin Lannon Date: Sat, 5 Mar 2022 10:54:46 -0500 Subject: [PATCH] moving label toLowercase code up to top of function --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 972f174..ac43651 100644 --- a/index.js +++ b/index.js @@ -82,15 +82,15 @@ function diffLabels(oldLabels, newLabels) { // each entry has two values // { type: 'create' | 'update' | 'delete', label } - let oldLabelsNames = oldLabels.map((label) => label.name); - let newLabelsNames = newLabels.map((label) => label.name); + let oldLabelsNames = oldLabels.map((label) => label.name.toLowerCase()); + let newLabelsNames = newLabels.map((label) => label.name.toLowerCase()); let labelModList = []; oldLabelsNames.forEach((oLabel) => { // when using `includes` with strings, the match is case-sensitive // so we first lowercase both strings when comparing - if (newLabelsNames.toLowerCase().includes(oLabel.toLowerCase())) { + if (newLabelsNames.includes(oLabel)) { const oldLabel = oldLabels.filter((l) => l.name === oLabel)[0]; const newLabel = newLabels.filter((l) => l.name === oLabel)[0];