Skip to content

Commit

Permalink
maybeCoerceNumber(): adapt for Array's
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Jul 11, 2019
1 parent 17ca3bd commit a8eb70b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,11 @@ function parse (args, opts) {
const shouldCoerceNumber = isNumber(value) && configuration['parse-numbers'] && (
Number.isSafeInteger(Math.floor(value))
)
if (shouldCoerceNumber || (!isUndefined(value) && checkAllAliases(key, flags.numbers))) value = Number(value)
if (shouldCoerceNumber || (!isUndefined(value) && checkAllAliases(key, flags.numbers))) {
value = Array.isArray(value)
? value.map(function(val) {return maybeCoerceNumber (key, val)})
: Number(value)
}
}
return value
}
Expand Down

0 comments on commit a8eb70b

Please sign in to comment.