Skip to content

Commit

Permalink
refactor: remove Array.forEach used in place of Array.some/find
Browse files Browse the repository at this point in the history
  • Loading branch information
mleguen authored and bcoe committed Oct 9, 2019
1 parent eab0cb6 commit afcaecb
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions index.js
Expand Up @@ -748,16 +748,11 @@ function parse (args, opts) {
})
}

// check if a flag is set for any of a key's aliases.
// return the 1st set flag for any of a key's aliases (or false if no flag set)
function checkAllAliases (key, flag) {
var isSet = false
var toCheck = [].concat(flags.aliases[key] || [], key)

toCheck.forEach(function (key) {
if (flag.hasOwnProperty(key)) isSet = flag[key]
})

return isSet
let setAlias = toCheck.find(key => flag.hasOwnProperty(key))
return setAlias ? flag[setAlias] : false
}

function hasAnyFlag (key) {
Expand Down

0 comments on commit afcaecb

Please sign in to comment.