Skip to content

Commit

Permalink
filled out labels subtraction function
Browse files Browse the repository at this point in the history
  • Loading branch information
FireLemons committed Feb 6, 2022
1 parent 1a236f2 commit eb8ee4c
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,20 @@ function subtractLabels (labels, labelDifference) {
if (!Array.isArray(labelDifference)) {
throw new TypeError('Param labelDifference must be an array')
}

const labelsCopy = Object.assign({}, labels)
let isLabelSubtracted = false

for (const label of labelDifference) {
if (label in labelsCopy) {
delete labelsCopy[label]
isLabelSubtracted = true
}
}

if (isLabelSubtracted) {
return Object.keys(labelsCopy)
}
}

// Validates a list of lables contains only strings
Expand Down Expand Up @@ -460,7 +474,8 @@ async function main () {
}

const issueNumber = issueNumberMatchCapture[1]
console.log(await getIssueLabels(parseInt(issueNumber)))
const issueLables = await getIssueLabels(parseInt(issueNumber))
console.log(subtractLabels(issueLables, column_labels['labels']))
}
//const cardsLabeledCount = await labelCards(cards, column_labels['labels'])

Expand Down

0 comments on commit eb8ee4c

Please sign in to comment.