Skip to content

Commit

Permalink
code: only call Date.parse(val) once
Browse files Browse the repository at this point in the history
If it's going to create a problem preventing the debug call then it'll
create the problem even when it's the last arg to debug. So, might as
well do it once, first, and then use that result in the debug call.

Credit: @elidoran
Reviewed-By: @othiym23
PR-URL: #76
  • Loading branch information
elidoran authored and othiym23 committed Dec 13, 2016
1 parent 356e58e commit 39b6e5c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/nopt.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ function validateNumber (data, k, val) {
}

function validateDate (data, k, val) {
debug("validate Date %j %j %j", k, val, Date.parse(val))
var s = Date.parse(val)
debug("validate Date %j %j %j", k, val, s)
if (isNaN(s)) return false
data[k] = new Date(val)
}
Expand Down

0 comments on commit 39b6e5c

Please # to comment.