From 39b6e5c65ac47f60cd43a1fbeece5cd4c834c254 Mon Sep 17 00:00:00 2001 From: Eli Doran Date: Mon, 12 Dec 2016 16:28:32 -0500 Subject: [PATCH] code: only call Date.parse(val) once 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: https://github.com/npm/nopt/pull/76 --- lib/nopt.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nopt.js b/lib/nopt.js index 2cf25d7..2287ea9 100644 --- a/lib/nopt.js +++ b/lib/nopt.js @@ -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) }